Home Forums WC Vendors Pro Support customize product fields in the frontend

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 28 posts - 1 through 28 (of 28 total)
  • Author
    Posts
  • #16112
    Nicolas
    Participant

    Hello

    I would like to know if it is possible, in the pro version, to customize product fields in the frontend?

    For instance if I am selling food I would like the vendors to fill in an “ingredients” field…

    Is it possible?

    Thanks

    #16137
    WC Vendors Support
    Participant

    Of course! You can customize and add or remove anything you like.

    #16143
    Nicolas
    Participant

    Thanks for your answer.
    Also, it’s fully compatible with WPML, right?

    Thanks

    #16145
    WC Vendors Support
    Participant

    Hi @nico

    Both free and Pro are WMPL ready. There is an existing bug that doesnt allow the Pro Dashboard menu to be translated, but that is fixed for v1.1.1 being released in the next day or two. Beyond that, you’ll be good to go. There’s a number of mo/po files for Free already provided, and Pro has a few, just not as many yet since the mo/po files are submitted by members like you and Pro is a little new to have a ton yet. 🙂

    The refund policy is simple: No refunds. WC Vendors Free will tell you if this is a good platform for you, and you can test it on http://dev.wcvendors.com/dashboard/ login vendor1 password vendor1 to play around and make sure. 🙂 We feel that between these two, that makes for a more than suitable trial period.

    Cheers

    Ben

    #17206
    Nicolas
    Participant

    Hello Ben

    how can I add the custom field to the frontend?

    Thanks

    #17209
    Jamie
    Keymaster

    Hi @nico,

    What custom field would you like on the front end? Something for another plugin or just a new field that you want to be able to store and then reference in the templates?

    cheers,

    Jamie.

    #17210
    Nicolas
    Participant

    Hi Jamie

    I am selling cosmetics. So I need to add an “ingredients” field.
    It’s just another tab in the product page, next to description, shipping, rating…

    And I would like that when a vendor add his products, he also is presented with this “ingredient” field to fill in (and if there is a way to make its filling mandatory it would be even better…)

    #17476
    Nicolas
    Participant

    Hello Jamie

    any news?

    thanks
    Nicolas

    #17478
    WC Vendors Support
    Participant

    @digitalchild is finishing up moving his home right now, he’ll get back to you shortly.

    #17686
    Nicolas
    Participant

    @digitalchild is still moving? 😉

    #17687
    WC Vendors Support
    Participant

    Reminds me of that T-Shirt that says “Let me drop EVERYTHING I’m doing and work on YOUR problem”.

    Yea, he’s still moving. Remember, we do these requests when we have time for them. This is usually a paid customization, as we support the plugin base, but customizing it is up to you. At Jamie’s good grace, when he can, he’ll get back to you for this extra work you’re asking of him. 😉

    #17688
    Nicolas
    Participant

    @Ben The first question I asked, BEFORE buying the plugin was if it was possible to customize the frontend fields.
    You answered me it was.

    I’m just asking how to do that, nothing more.

    #17689
    WC Vendors Support
    Participant

    I understand fully. 🙂 Customizing it *is up to you*. We help, when we can, and right now Jamie is moving a thousand miles. He’ll get there when he can. 🙂

    #17897
    Jamie
    Keymaster

    Hello!

    I’m still moving but I’ll answer the question with an example.

    https://gist.github.com/digitalchild/cbbb83c972aedebc51f4

    This gives you the code to create a text field called dispatch days that will be saved automatically and then the relevant code you need to display this in your front end templates.

    Here is one that does the ingredients you want, this is the entire template.

    https://gist.github.com/digitalchild/4ea5922073803ddc5e5d

    To display the ingredients on the front end you’d have to edit the product single template to echo the meta field you want. See the first example for the code to modify for this.

    cheers,

    Jamie.

    #17956
    Nicolas
    Participant

    Thanks you very much !!!

    Enjoy your moving… 🙂

    #17983
    Nicolas
    Participant

    @digitalchild

    Jamie, thanks very much.
    Regarding the second template, it’s quite obvious what I should do with it. (I am not a developer AT ALL so I have to figure out some things 🙂 )

    Regarding the first one, I used your example to put this in product-edit.php

    <!– Ingredients –>
    <?php
    WCVendors_Pro_Form_Helper::textarea( array(
    ‘post_id’ => $object_id,
    ‘id’ => ‘_wcv_custom_product_ingredients’,
    ‘label’ => __( ‘Ingredients’, ‘wcvendors-pro’ ),
    ‘placeholder’ => __( ‘Ingredients’, ‘wcvendors-pro’ ),
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘The product ingredients’, ‘wcvendors-pro’ ),
    ) );
    $Ingredients = get_post_meta ($product_id, ‘_wcv_custom_product_ingredients’, true );
    ?>
    <p><?php echo $Ingredients; ?></p>

    It does indeed display in the frontend form, but neither on the admin’s dashboard, nor on the product page in the shop.

    What did I miss?

    Thanks
    Nicolas

    #18133
    Karen Thomas
    Participant

    Following this one 🙂

    #18182
    Jan-Philipp Wittrin
    Participant

    I solved these issues with a combination of Advanced Custom Fields (for the Admin Backend (and even the frontend if you want to get more geeky)). In ACF I would make a text field with the id ‘_wcv_custom_product_ingredients’ and say that the custom field should be shown on product edit in the admin and then use the code like above in the product-edit.php

    The field you can then echo into your single product or archive with echo get post meta (like above the last bit of code) or with the ACF own -> the_field (‘_wcv_custom_product_ingredients’);

    Don’t forget the overide the Woocommerce template:
    https://www.skyverge.com/blog/how-to-override-woocommerce-template-files/

    By using the same ID in ACF the field gets populated in the backend.
    The combination of ACF and WC Vendors works pretty well.

    #18205
    Nicolas
    Participant

    Thank you very much @Laika

    Now I can display what I need. I just need to figure out how to display it as a new tab (with Description, Reviews, Vendor Rating & Shipping…)

    #18206
    Jan-Philipp Wittrin
    Participant

    Hi Nicolas.

    In functions.php you add a new woo tab like this (untested):

    
    	$tabs['test_tab'] = array(
    		'title' 	=> __( 'New Product Tab', 'woocommerce' ),
    		'priority' 	=> 50,
    		'callback' 	=> 'woo_new_product_tab_content'
    	);
    
    	return $tabs;
    
    }
    function woo_new_product_tab_content() {
    
    	// The new tab content
    
    	echo '<h2>New Product Tab</h2>';
    	echo '<p>Here\'s your new product tab.</p>';
    
    }
    

    And then within the function you can call your custom field. F.e. like this.

    
    global $post;
    
    $product = wc_get_product( $post->ID );
    
    $description = $post->post_content;
    $shipping = $product->get_weight();
    
    $custom_meta = get_post_meta( $post->ID, 'your_meta_key', true );
    

    Source: https://wordpress.org/support/topic/how-to-add-custom-fields-in-custom-product-tabs-in-woocommerce-1

    Cheers.

    #18489
    Karen Thomas
    Participant

    Hi my tiny mind is melting trying to do this 🙁 hope you can help.

    I already have an ACF field called ‘dispatch_times’. This appears in my wp-admin product forms.

    Could anyone help me with the final tasks (sorry I know you’ve explained but I’m still struggling to understand and a little bit scared truth be told as I’m not a developer):

    1. Add my ACF field ‘dispatch_times’ to the shiny new front end ProductEdit form
    2. Add the contents of my ‘dispatch days’ field to my website single product page (I’d like it to appear directly under my product description)

    Thank you so much for anyone’s time,

    Karen

    #18509
    Nicolas
    Participant

    Karen

    I also struggled so I’m not sure I am the best person to help you, but since I really appreciated when others helped me, I try to return the favor…

    For 1. you should probably adapt lines 41 to 51 of the second document provided by Jamie in this post.
    For 2. If you just want it displayed under you product description you can just use what @Laika described in his first answer :

    The field you can then echo into your single product or archive with echo get post meta (like above the last bit of code) or with the ACF own -> the_field (‘_wcv_custom_product_ingredients’);

    Don’t forget the overide the Woocommerce template:
    https://www.skyverge.com/blog/how-to-override-woocommerce-template-files/

    BUT…

    If what you need is editiong the product tabs you should read this : https://docs.woothemes.com/document/editing-product-data-tabs/

    #18615
    Jan-Philipp Wittrin
    Participant

    Hi @Conscious Crafties,

    I noticed it is important that your custom field name starts with

    _wcv_custom_product_….

    so. in your case: ‘_wcv_custom_product_dispatch_times’

    Then it should work. At least it worked for me 🙂

    Cheers,

    Jan-Philipp

    #18632
    Karen Thomas
    Participant

    Thanks a million both! Sorry for delay I’ve not been very well. I’m going to pluck up the courage to try it now! Wish me luck!

    Thanks for your help! 😀 ,

    Karen

    #18640
    Karen Thomas
    Participant

    Hi all,

    Just for testing I didn’t alter the code and used the Ingredients code to see what happened.
    Added this to: /wp-content/themes/deli/wc-vendors/dashboard/product-edit.php
    (wasn’t sure if I was to use the copied theme template or not):

    Then went to vendor account, tried to Add Product and got this error:

    What am I doing wrong? Sorry I’m totally lost when it comes to code!

    Thank you for all your help,

    Karen

    #18676
    WC Vendors Support
    Participant

    Your first PHP lesson. 🙂

    The last line of the array gets no comma. Remove the comma on line 50.

    #18681
    Karen Thomas
    Participant

    Aww thanks Ben love lessons 🙂

    So I removed the comma on the last array:

    <!– Ingredients –>
    <?php
    WCVendors_Pro_Form_Helper::textarea( array(
    ‘post_id’ => $object_id,
    ‘id’ => ‘_wcv_custom_product_ingredients’,
    ‘label’ => __( ‘Ingredients’, ‘wcvendors-pro’ ),
    ‘placeholder’ => __( ‘Ingredients’, ‘wcvendors-pro’ ),
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘The product ingredients’, ‘wcvendors-pro’ )
    ) );
    $Ingredients = get_post_meta ($product_id, ‘_wcv_custom_product_ingredients’, true );
?>
<p><?php echo $Ingredients; ?></p>

    Then tried to add product and got this error:
    Parse error: syntax error, unexpected ‘product’ (T_STRING) in /home/consciouscraftie/public_html/wp-content/themes/deli/wc-vendors/dashboard/product-edit.php on line 50

    Line 50 is description

    Can I have lesson 2 please Ben 🙂


    @Laika
    @nico
    I’d ideally like to integrate with my existing ACF field. I exported the PHP for my ACF dispatch info field and got this. Is there a way of using this in my product-edit.php? Sorry I’m not a developer. Appreciate any help you can offer…

    if(function_exists("register_field_group"))
    {
    	register_field_group(array (
    		'id' => 'acf_dispatch-info',
    		'title' => 'Dispatch info',
    		'fields' => array (
    			array (
    				'key' => 'field_55636916e7a83',
    				'label' => 'Handmade in XX Days',
    				'name' => '_wcv_custom_product_dispatch_times',
    				'type' => 'text',
    				'required' => 1,
    				'default_value' => '',
    				'placeholder' => 'Number of DAYS to make and post',
    				'prepend' => '',
    				'append' => 'days',
    				'formatting' => 'html',
    				'maxlength' => '',
    			),
    		),
    		'location' => array (
    			array (
    				array (
    					'param' => 'post_type',
    					'operator' => '==',
    					'value' => 'product',
    					'order_no' => 0,
    					'group_no' => 0,
    				),
    			),
    		),
    		'options' => array (
    			'position' => 'side',
    			'layout' => 'default',
    			'hide_on_screen' => array (
    			),
    		),
    		'menu_order' => 1,
    	));
    }
    
    

    Many thanks,

    Karen

    #18687
    Jan-Philipp Wittrin
    Participant

    Hi Karen,

    into your header above <?php wp_header;?>

    
    <?php acf_form_head();?> // to generate frontend form

    and then into your product-edit.php

    <?php $options = array(
    
    	/* (string) Unique identifier for the form. Defaults to 'acf-form' */
    	'id' => 'field_55636916e7a83', // the ID from your export
    	'post_id'	=> $post_id, // untested, but most likely, because in product-form class of WC Vendors
    
    	'form' => false, // because you don't want submit buttom
    
    ....
    
    ?>
    
    <?php acf_form( $options ); ?>

    I am not a developer either, but trial and error usually works well 😉

    Let us know if it worked please.

    Cheers, jp

Viewing 28 posts - 1 through 28 (of 28 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.