Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Marketplace › Edit wcfm-view-products-manage-tabs.php
- This topic has 8 replies, 2 voices, and was last updated 4 years, 8 months ago by Sushobhan.
- AuthorPosts
- April 11, 2020 at 12:55 am #117800ashley.youngukParticipant
Hello
I am trying to edit the template file wcfmu-view-products.php, I’m trying to edit the attributes section of that file by adding a class and changing the title or various sections however my changes are not showing. I then found that the same options are in the file wcfm-view-products-manage-tabs.php which is a file I cannot edit as it will be overwritten when I update the plugin.
Can you help?
- April 11, 2020 at 12:58 am #117801ashley.youngukParticipant
Actually if I edit wcfm-view-products.php not wcfmu-view-products.php my edits are shown. How would I edit that file?
- April 18, 2020 at 2:29 pm #120279SushobhanKeymaster
Hello,
Sorry for the delay in response.
Normally, it is not needed to override a file. The first approach should be, using the hooks and filters to change a certain behavior. Having said that, there might be situations where template override is required.
Please provide me details about your requirement and I’ll be happy to help you out. Also, a snapshot, marking your requirements would be very helpful.
Thanks - April 18, 2020 at 9:23 pm #120372ashley.youngukParticipant
Hi
I actually got it wrong – the file I need to edit is ‘class-wcfm-frontend.php’ which is located in wc-frontend-manager/core. Line 860 – 868. I would like to add my class to the labels and change the label title to a span.For example this is the edit I would like to do:
"is_visible" => array('label' => __('Visible on product page<span>Would you like this attribute display on your products page for your customers to see?</span>', 'wc-frontend-manager'), 'type' => 'checkbox', 'value' => 'enable', 'class' => 'wcfm-checkbox wcfm_ele simple variable external grouped booking', 'label_class' => 'wcfm_title wcfm_ele simple variable external grouped booking checkbox_title krafters-other-heading'),
As you can see I added a span within the tile and a class to the label class.
This section of code displays the admin generated attributes on the ‘Add Product’ form therefore I cannot edit the template file as this only edits the section where vendors can create their own attributes.
Thank you,
- April 19, 2020 at 1:29 am #120450ashley.youngukParticipant
I’ve made the edits to that section of code, is there a way to put it into a function?
// Attribute wise level if( !apply_filters( 'wcfm_is_allow_add_attribute_term_'.$att_taxonomy, true, $att_taxonomy ) ) { $allow_add_term = ''; } $attrlimit = apply_filters( 'wcfm_attribute_limit_'.$att_taxonomy, $attrlimit, $att_taxonomy ); $attributes = apply_filters( 'wcfm_product_custom_attributes_data', apply_filters( 'wcfm_product_custom_attribute_date_'.$att_taxonomy, $attributes, $att_taxonomy ) ); $WCFM->wcfm_fields->wcfm_generate_form_field( apply_filters( 'wcfm_product_custom_attributes', apply_filters( 'wcfm_product_custom_attribute_'.$att_taxonomy, array( "select_attributes_".$att_taxonomy => array( 'type' => 'multiinput', 'class' => 'wcfm-text wcfm_select_attributes wcfm_ele simple variable external grouped booking', 'label_class' => 'wcfm_title krafters-att-main', 'value' => $attributes, 'options' => array( "term_name" => array('type' => 'hidden'), "is_active" => array('label' => __('Enable this attribute?', 'wc-frontend-manager'), 'type' => 'checkbox', 'value' => 'enable', 'attributes' => array( 'title' => __( 'Check to associate this attribute with the product', 'wc-frontend-manager' ) ), 'class' => 'wcfm-checkbox wcfm_ele attribute_ele simple variable external grouped booking', 'label_class' => 'krafters-att-active wcfm_title wcfm_ele simple variable external grouped booking checkbox_title'), "name" => array('label' => __('Name', 'wc-frontend-manager'), 'type' => 'text', 'attributes' => array( 'readonly' => true ), 'class' => 'variation_ele_hide', 'label_class' => 'krafters-att-heading variation_ele_hide'), "value" => array('label' => wc_attribute_label( $att_taxonomy ), 'type' => 'select', 'custom_attributes' => array( 'attrlimit' => $attrlimit ), 'attributes' => array( 'multiple' => 'multiple', 'style' => 'width: 60%;' ), 'class' => 'wcfm-select wcfm_ele simple variable external grouped booking ' . $allow_add_term, 'label_class' => 'wcfm_title wcfm_ele attribute_ele simple variable external grouped booking'), "is_visible" => array('label' => __('Visible on the product page <span>Do you want your customers to see this attribute<br>in the item information on the product page</span>', 'wc-frontend-manager'), 'type' => 'checkbox', 'value' => 'enable', 'class' => 'wcfm-checkbox wcfm_ele simple variable external grouped booking ', 'label_class' => 'wcfm_title wcfm_ele simple variable external grouped booking checkbox_title krafters-other-heading'), "is_variation" => array('label' => __('Use as Variation <span>Enabling this option allows you to define different<br>pricing and stock options for this attribute.</span>', 'wc-frontend-manager'), 'type' => 'checkbox', 'value' => 'enable', 'class' => 'wcfm-checkbox wcfm_ele variable variable-subscription', 'label_class' => 'wcfm_title checkbox_title wcfm_ele variable variable-subscription krafters-other-heading'), "tax_name" => array('type' => 'hidden'), "is_taxonomy" => array('type' => 'hidden') )) ), 'select_attributes_'.$att_taxonomy, $att_taxonomy, $attributes ), 'select_attributes_'.$att_taxonomy, $att_taxonomy, $attributes ) ); }
The only other change I would like to make is to style the attribute name, this bit:
<p class="select_attributes_pa_colour_value_0 wcfm_title wcfm_ele attribute_ele simple variable external grouped booking"><strong>Colour</strong></p>
But generically without having to do each attribute
- April 19, 2020 at 12:07 pm #120544SushobhanKeymaster
Please never edit any core files. Never ever! You will end up loosing all the changes when you update the plugin. Also it’s a bad practice.
As I told you earlier “The right way” is to use appropriate hooks and filters. Please use the following snippet for your purpose-add_filter( 'product_simple_fields_attributes', function($attribute_fields) { if ( isset( $attribute_fields['attributes']['options']['is_visible'] ) ) { $attribute_fields['attributes']['options']['is_visible']['label'] = 'Visible on the product page <span>Would you like this attribute display on your products page for your customers to see?</span>'; $attribute_fields['attributes']['options']['is_visible']['label_class'] = $attribute_fields['attributes']['options']['is_visible']['label_class'] . ' krafters-other-heading'; } return $attribute_fields; } ); add_filter( 'wcfm_product_custom_attributes', function($attribute_fields) { foreach ( $attribute_fields as $attr_taxonomy => $data ) { if ( isset( $data['options']['is_visible'] ) ) { $attribute_fields[$attr_taxonomy]['options']['is_visible']['label'] = 'Visible on the product page <span>Would you like this attribute display on your products page for your customers to see?</span>'; $attribute_fields[$attr_taxonomy]['options']['is_visible']['label_class'] = $data['options']['is_visible']['label_class'] . ' krafters-other-heading'; } } return $attribute_fields; } );
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
Thanks! - April 19, 2020 at 12:17 pm #120548ashley.youngukParticipant
Amazing – fyi I didn’t actually update the core, I only made the changes so you could see what I needed. I never edit core files! 🙂
- April 19, 2020 at 12:51 pm #120553ashley.youngukParticipant
So the last bit was styling this
<p class="select_attributes_pa_colour_value_0 wcfm_title wcfm_ele attribute_ele simple variable external grouped booking"><strong>Colour</strong></p>
I want to target all without have to use .select_attributes_pa_colour_value_0
Thank you
- April 20, 2020 at 10:04 pm #121076SushobhanKeymaster
Hi,
The code snippet I provided already append a class “krafters-other-heading” with each attribute field label. So you can use that class to select these headings.
Thanks!
- AuthorPosts
- You must be logged in to reply to this topic.