wcfm-santa

A deal you can't resist! Get upto 35% Off on this entire cyber week.

CLAIM OFFER
02Day 13Hr 05Min 11Sec
wcfm-santa

Edit wcfm-view-products-manage-tabs.php

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Marketplace Edit wcfm-view-products-manage-tabs.php

Viewing 8 reply threads
  • Author
    Posts
    • #117800
      ashley.younguk
      Participant

      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?

    • #117801
      ashley.younguk
      Participant

      Actually if I edit wcfm-view-products.php not wcfmu-view-products.php my edits are shown. How would I edit that file?

    • #120279
      Sushobhan
      Keymaster

      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

    • #120372
      ashley.younguk
      Participant

      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,

    • #120450
      ashley.younguk
      Participant

      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

    • #120544
      Sushobhan
      Keymaster

      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!

    • #120548
      ashley.younguk
      Participant

      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! 🙂

    • #120553
      ashley.younguk
      Participant

      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

    • #121076
      Sushobhan
      Keymaster

      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!

Viewing 8 reply threads
  • You must be logged in to reply to this topic.