Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Marketplace › Custom vendor field
Tagged: custom fields, vendors
- This topic has 11 replies, 2 voices, and was last updated 4 years, 5 months ago by Sarmistha Chakraborty.
- AuthorPosts
- May 7, 2020 at 3:02 am #127736crzy4prpleParticipant
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.
- May 7, 2020 at 12:55 pm #127904Sarmistha ChakrabortyMember
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.
- May 7, 2020 at 8:05 pm #128071crzy4prpleParticipant
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. - May 7, 2020 at 8:55 pm #128095Sarmistha ChakrabortyMember
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.
- May 7, 2020 at 9:32 pm #128104crzy4prpleParticipant
It’s creating the tab, but not pulling the information.
- May 7, 2020 at 9:58 pm #128111Sarmistha ChakrabortyMember
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. - May 8, 2020 at 12:56 am #128165crzy4prpleParticipant
I copied and pasted the code you gave me, I’m not sure what to do next?
- May 8, 2020 at 6:00 pm #128413Sarmistha ChakrabortyMember
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.
- May 26, 2020 at 10:21 pm #135504crzy4prpleParticipant
If I want to do the same thing for a field labeled “Mileage” how would I go about that?
- May 26, 2020 at 10:30 pm #135510Sarmistha ChakrabortyMember
Hello,
Follow the reply #128413.
To get field value the code will be –get_user_meta( $vendor_id, 'mileage', true )
Thanks.
- May 26, 2020 at 10:31 pm #135512crzy4prpleParticipant
I’m using snippets, so do I need to create a new snippet?
- May 27, 2020 at 8:12 pm #135891Sarmistha ChakrabortyMember
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.
- AuthorPosts
- You must be logged in to reply to this topic.