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.
Thank you to all of our customers!
- This topic has 27 replies, 5 voices, and was last updated 8 years, 4 months ago by Jan-Philipp Wittrin.
-
AuthorPosts
-
November 20, 2015 at 10:04 am #16112NicolasParticipant
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
November 20, 2015 at 2:22 pm #16137WC Vendors SupportParticipantOf course! You can customize and add or remove anything you like.
November 20, 2015 at 2:34 pm #16143NicolasParticipantThanks for your answer.
Also, it’s fully compatible with WPML, right?Thanks
November 20, 2015 at 2:37 pm #16145WC Vendors SupportParticipantHi @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
December 1, 2015 at 3:17 am #17206NicolasParticipantHello Ben
how can I add the custom field to the frontend?
Thanks
December 1, 2015 at 3:34 am #17209JamieKeymasterHi @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.
December 1, 2015 at 3:38 am #17210NicolasParticipantHi 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…)
December 3, 2015 at 11:23 am #17476NicolasParticipantHello Jamie
any news?
thanks
NicolasDecember 3, 2015 at 11:28 am #17478WC Vendors SupportParticipant@digitalchild is finishing up moving his home right now, he’ll get back to you shortly.
December 5, 2015 at 2:48 pm #17686NicolasParticipant@digitalchild is still moving? 😉
December 5, 2015 at 3:11 pm #17687WC Vendors SupportParticipantReminds 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. 😉
December 5, 2015 at 3:15 pm #17688NicolasParticipant@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.
December 5, 2015 at 3:38 pm #17689WC Vendors SupportParticipantI 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. 🙂
December 7, 2015 at 7:59 pm #17897JamieKeymasterHello!
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.
December 8, 2015 at 5:38 am #17956NicolasParticipantThanks you very much !!!
Enjoy your moving… 🙂
December 8, 2015 at 12:10 pm #17983NicolasParticipantJamie, 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
NicolasDecember 9, 2015 at 10:36 pm #18133Karen ThomasParticipantFollowing this one 🙂
December 10, 2015 at 3:39 pm #18182Jan-Philipp WittrinParticipantI 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.December 11, 2015 at 6:31 am #18205NicolasParticipantThank 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…)
December 11, 2015 at 7:33 am #18206Jan-Philipp WittrinParticipantHi 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.
December 14, 2015 at 10:42 pm #18489Karen ThomasParticipantHi 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
December 15, 2015 at 4:47 am #18509NicolasParticipantKaren
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/
December 16, 2015 at 11:19 am #18615Jan-Philipp WittrinParticipantHi @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
December 16, 2015 at 2:31 pm #18632Karen ThomasParticipantThanks 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
December 16, 2015 at 4:11 pm #18640Karen ThomasParticipantHi 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
December 17, 2015 at 12:39 am #18676WC Vendors SupportParticipantYour first PHP lesson. 🙂
The last line of the array gets no comma. Remove the comma on line 50.
December 17, 2015 at 3:20 am #18681Karen ThomasParticipantAww 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 50Line 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
December 17, 2015 at 9:52 am #18687Jan-Philipp WittrinParticipantHi 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
-
AuthorPosts
- The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.