Home › Forums › WC Vendors Pro Support › SHARING: Add gift wrapping option
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 23 replies, 10 voices, and was last updated 6 years, 8 months ago by marie mour.
-
AuthorPosts
-
March 19, 2016 at 1:52 pm #27341HADIParticipant
I wanted to add gift wrapping option for the buyer on my site. But this will be totally up to each vendor for each of their product whether or not they want this option to be enabled or not. The Woocommerce Product Add-on was too complicated for me to understand. So I found this simple gift wrapping plugin n it seems to be simple enough. Cut to the chase, i’ve managed to add the enable/disable option along with the wrapping fee/cost in the vendor’s dashboard product edit.
Here’s what I did;
//I add this at product-edit.php <?php WCVendors_Pro_Form_Helper::input( array( 'post_id' => $object_id, 'id' => 'wcv_custom_product_gift_wrapper_enable', 'label' => __( 'Let buyer choose product to be wrapped?', 'wcvendors-pro' ), 'type' => 'checkbox' ) ); WCVendors_Pro_Form_Helper::input( array( 'type' => 'text', 'post_id' => $object_id, 'id' => 'wcv_custom_product_gift_wrap_price', 'label' => __( 'Wrapping cost', 'wcvendors-pro' ), 'placeholder' => __( '0', 'wcvendors-pro' ), 'desc_tip' => 'true', 'description' => __( 'Leave blank if wrapping is free.', 'wcvendors-pro' ), ) ); ?> //then I add this to function.php function wcv_enable_gift_wrap ($post_id) { $wcv_enable_wrap = get_post_meta( $post_id, 'wcv_custom_product_gift_wrapper_enable', true ); $wcv_gift_wrap_cost = get_post_meta( $post_id, 'wcv_custom_product_gift_wrap_price', true ); if ( $wcv_enable_wrap = 'yes' ) { update_post_meta( $post_id, '_is_gift_wrappable', $wcv_enable_wrap ); update_post_meta( $post_id, '_gift_wrap_cost', $wcv_gift_wrap_cost ); } } add_action ('wcv_save_product','wcv_enable_gift_wrap');
It works fine at my site. Do point out any issue with this code (security or something critical?) if there is any since I’m very new to this world of programming.
March 19, 2016 at 2:31 pm #27348WC Vendors SupportParticipantBeautifully done. 🙂 I’ve put this all into a KnowledgeBase article, too:
https://www.wcvendors.com/kb/integration-woocommerce-product-gift-wrap/
March 21, 2016 at 2:43 am #27438RafiParticipantCan you tell me please that where we can find this file (product-edit.php template). Please explain the exact directory. I found it in WC Vendors pro, Woocommerce & in my OneSocial Theme files, But didn’t find this file.
Looking for your quick response. ThanksMarch 21, 2016 at 11:19 am #27465WC Vendors SupportParticipantRafi: It’s time you read the WC Vendors Pro Setup Guide. It’s in the KnowledgeBase. 😉
March 22, 2016 at 8:50 am #27556David RParticipantThat’s great, HADI. Do you know how easy it might be to adapt this to present users with a few radio buttons, each with it’s own price?
March 22, 2016 at 9:04 am #27557HADIParticipantI do believe it’s possible. Just change the input type to radio, add the prices options that you want and use the same id (wcv_custom_product_gift_wrap_price). I think either Ben’s or Jamie’s gist page at github have example of various type of input for the product form.
April 22, 2016 at 1:02 pm #30488JoeParticipantThis looks great, and I got it working to a point… seems like on the product page it shows “Gift wrap this item for xx” but there is no option displaying to check yes?
April 22, 2016 at 3:19 pm #30491JoeParticipantGot it fixed. Double check your theme stylesheets people as that’s what it was!
April 29, 2016 at 12:00 am #31024GabrielParticipantHi everyone,
I am trying very hard to make this work …and it does not 🙁
1. I installed WooCommerce Product Gift Wrap
2. I added the code in function.php of my child theme (see attachments)
3. I added the code to product-edit.php (wc-vendors-pro/templates/dashboard/product-edit.php)
Can you look at my attachment and tell me where I go wrong?Thanks a lot
April 29, 2016 at 12:04 am #31028WC Vendors SupportParticipant@ggoaga — Social Marketplace overrides the product-edit.php template. You’re editing the plugins version of it. You’d want to add it to the Social Marketplace theme folder by copying it to /wp-content/themes/yourtheme-child/wc-vendors/dashboard/product-edit.php and then edit that version with your customizations. Rule #1 — Never edit a file in your plugin directory, always template it out first.
Cheers
April 29, 2016 at 12:20 am #31029GabrielParticipantdid you mean: themes/onesocial-child/wc-vendors-pro/templates/product-edit.php ?
I copied product-edit.php from the plugin there ( i created those folders first)
is this good?April 29, 2016 at 12:24 am #31030GabrielParticipantit still does not work 🙁
April 29, 2016 at 12:48 am #31032WC Vendors SupportParticipantNope, I mean
/themes/yourtheme-child/wc-vendors/dashboard/product-edit.php
— There’s no pro in the template directory, it’s all /wc-vendors/Try adding some text, like “ABCDEFG” and save the template. Then, load up the product add/edit form and see if you can see the ABCDEFG text on the page. If you don’t, the template changes arent working and you have to keep at it. 🙂
April 29, 2016 at 12:54 am #31033GabrielParticipantOk. I finally got it right. 🙂
It is 4 screenshots, and I want to share it with screenshots for other like me that do not read the headers of the files 🙂
1. I installed WooCommerce Product Gift Wrap
2. I added the code in function.php of my child theme (onesocial-child/functions.php)
3. Go to cpanel on your hosting account, file manager, /wp-content/themes/onesocial-child/ and create this directory /wc-vendors/ and then /dashboard/, copy in this directory product-edit.php from this address: /wp-content/plugins/wc-vendors-pro/templates/dashboard/product-edit.php.
Now you have this path: onesocial-child/wc-vendors/dashboard/product-edit.php Go there and add the code where you want to show up.
See screen shots.
4. WorksApril 29, 2016 at 1:01 am #31038WC Vendors SupportParticipantSuccess! Thanks for the added screenshots for the benefit of all. Always appreciate helpful forum community contributions!
May 20, 2016 at 8:08 pm #32882HADIParticipantI’m having a problem with the gift wrap enable checkbox here. I can check and save it. However, when I uncheck and save it, it is still checked afterwards. Anybody else having this issue?
oh yeah, I’ve updated a bit the function for this as below;
function wcv_enable_gift_wrap ($post_id) { $wcv_enable_wrap = get_post_meta( $post_id, 'wcv_custom_product_gift_wrapper_enable', true ); $wcv_gift_wrap_cost = get_post_meta( $post_id, 'wcv_custom_product_gift_wrap_price', true ); if ( $wcv_enable_wrap == 'yes' ) { update_post_meta( $post_id, '_is_gift_wrappable', $wcv_enable_wrap ); update_post_meta( $post_id, '_gift_wrap_cost', $wcv_gift_wrap_cost ); } elseif ( $wcv_enable_wrap == 'no' ) { update_post_meta( $post_id, '_is_gift_wrappable', $wcv_enable_wrap ); } }
The if argument used to be with only ‘=’ which caused the gift wrap to be enabled when changes is saved no matter you check the enable box or not. So, when changed to ‘==’ instead, it behaves as it should, only enabled when checked. And also i added the update_post_meta when box is unchecked, so that the gift wrap option can be off when you uncheck the enable box in product edit form. But as I said above, i’m having trouble to keep the box unchecked when saved. Anybody having this issue as well?
January 10, 2017 at 3:32 am #52601ImaParticipantHello @had_hc,
I am having an exactly same problem…
It won’t save the change I make with this checkbox.January 10, 2017 at 3:41 am #52602HADIParticipant@imacocokara, I use the below code to save the checkbox changes.
function save_gift_enable ($post_id){ if ( ! empty( $_POST[ 'wcv_custom_product_gift_wrapper_enable' ] ) ) { update_post_meta( $post_id, 'wcv_custom_product_gift_wrapper_enable', 'yes' ); } else { update_post_meta( $post_id, 'wcv_custom_product_gift_wrapper_enable', '' ); } } add_action ('wcv_save_product','save_gift_enable');
January 12, 2017 at 8:00 am #52797ImaParticipant@had_hc, Thank you for sharing!
I tried your code, and now I can save the change I make with the checkbox!!However, “wrapping option” is still displaying on frontend product page, even I uncheck the gift wrap enable checkbox…
January 12, 2017 at 9:19 pm #52882HADIParticipant@imacocokara, there was some small error in the code at the first post. See post #32882 where i corrected the code. The ‘if’ conditional should be ( $wcv_enable_wrap == ‘yes’ )
February 10, 2017 at 4:37 am #55653NadavParticipantHi all,
I’ve done everything explained in the Knowledge Base and on this page – but nothing happens. Presumably vendors should see the option to gift wrap (or to add Express Shipping, as I’m trying to use this for) toward the bottom of the Create Product page, as seen in the screenshot provided by Gabriel?
As shown in my screenshots, I:
1/ Added the WooCommerce Product Gift Wrap plugin
2/ Added the required code to function.php
3/ Copied product-edit.php to /themes/onesocial-child/wc-vendors/dashboard/product-edit.php, and added the code
4/ But it still doesn’t show up.Is it possible I haven’t copied the code in correctly? Or that I’ve missed a step?
Thanks,
NadavFebruary 10, 2017 at 9:11 am #55685AnnaMemberHello Nadav,
Copied product-edit.php to /themes/onesocial-child/wc-vendors/dashboard/product-edit.php, and added the code
For that theme, you need one extra folder in your file path since they’ve already modified that template.
1. Take the template from here, so you keep whatever modifications buddyboss made :
plugins/buddyboss-marketplace/templates/wc-vendors/dashboard/product-edit.php2. Add your modifications.
3. Save it to your child theme using this path (extra folder bb-marketplace):
themes/onesocial-child/bb-marketplace/wc-vendors/dashboard/product-edit.php
February 10, 2017 at 11:11 am #55699NadavParticipantBrilliant, thanks Anna!
July 17, 2017 at 8:11 pm #70264marie mourParticipantSorry to add onto this, thought better than to do a new thread as it may help others.
Added this to child product-edit, working great, used a custom meta (wholesale price) which I’m stoked about.How/Which template do I add this to – to make this an option on each variation? Ideally near the price boxes. I don’t see an obvious template file to edit.
-
AuthorPosts
- The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.