Custom vendor field

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!

Viewing 10 reply threads
  • Author
    Posts
    • #127736
      crzy4prple
      Participant

      I’ve added a customer vendor field “Licensing”. I’d like that information to display on a tab after product description.

      The Licensing is unique to the vendors many products.

      I’m using a custom tab plugin so I can just add short code if I knew how to pull that field.

    • #127904

      Hello,

      I’ve added a customer vendor field “Licensing”.
      >> Can you let us know how you add that field? and where you added this field? In your product manage dashboard or vendor profile?
      So that we can help you to how you get the field value.

      Thanks.

    • #128071
      crzy4prple
      Participant

      I added via the vendor profile. It’s specific to each vendor, I want to attach it to their many products.

      Attachments:
      You must be logged in to view attached files.
    • #128095

      Hello,

      Try the below code n your theme’s functions.php

      add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
      function woo_new_product_tab( $tabs ) {
      
          $tabs['vendor_info_tab'] = array(
              'title'     => __( 'Additional Information', 'woocommerce' ),
              'priority'  => 10,
              'callback'  => 'woo_new_product_tab_content'
          );
          return $tabs;
      }
      function woo_new_product_tab_content()  {
          // The new tab content
          $product_id = get_the_ID();
          $vendor_id   = wcfm_get_vendor_id_by_post( $product_id );
          echo'<p>'.get_user_meta( $vendor_id, 'licensing', true ).'</p>';
      }

      Thanks.

    • #128104
      crzy4prple
      Participant

      It’s creating the tab, but not pulling the information.

    • #128111

      Hi,

      The “licensing” in this code – (in get_user_meta( $vendor_id, ‘licensing’, true )) will be your field label value(all in small letters)(PFA)

      Thanks.

      Attachments:
      You must be logged in to view attached files.
    • #128165
      crzy4prple
      Participant

      I copied and pasted the code you gave me, I’m not sure what to do next?

    • #128413

      Hello,

      In “Registration Form Custom Fields” where you added the “Licensing” field(WCFM dashboard -> Settings -> Vendor Registration)(see previously attached screenshot), your entered value in “Label” field (example – Licensing), you have to put the label field value(all in small letters) in this code –

      add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
      function woo_new_product_tab( $tabs ) {
      
          $tabs['vendor_info_tab'] = array(
              'title'     => __( 'Additional Information', 'woocommerce' ),
              'priority'  => 10,
              'callback'  => 'woo_new_product_tab_content'
          );
          return $tabs;
      }
      function woo_new_product_tab_content()  {
          // The new tab content
          $product_id = get_the_ID();
          $vendor_id   = wcfm_get_vendor_id_by_post( $product_id );
          echo'<p>'.get_user_meta( $vendor_id, 'licensing', true ).'</p>'; //replace "licensing" with your label field value
      }

      If you still unable to do that, we need your site access, we will do it for you.

      Thanks.

    • #135504
      crzy4prple
      Participant

      If I want to do the same thing for a field labeled “Mileage” how would I go about that?

      • #135510

        Hello,

        Follow the reply #128413.
        To get field value the code will be – get_user_meta( $vendor_id, 'mileage', true )

        Thanks.

    • #135512
      crzy4prple
      Participant

      I’m using snippets, so do I need to create a new snippet?

    • #135891

      Hello,

      Modify this code –

      add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
      function woo_new_product_tab( $tabs ) {
      
          $tabs['vendor_info_tab'] = array(
              'title'     => __( 'Additional Information', 'woocommerce' ),
              'priority'  => 10,
              'callback'  => 'woo_new_product_tab_content'
          );
      
         $tabs['vendor_mileage_tab'] = array(
              'title'     => __( 'Mileage Information', 'woocommerce' ),
              'priority'  => 12,
              'callback'  => 'woo_mileage_product_tab_content'
          );
          return $tabs;
      }

      And add below function –

      
      function woo_mileage_product_tab_content() {
      // The new tab content
          $product_id = get_the_ID();
          $vendor_id   = wcfm_get_vendor_id_by_post( $product_id );
          echo'<p>'.get_user_meta(  $vendor_id, 'mileage', true ).'</p>';
      }

      Ref: https://wisdmlabs.com/blog/add-custom-tab-woocommerce-product-page/

      Thanks.

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