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.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 24 posts - 1 through 24 (of 24 total)
  • Author
    Posts
  • #27341
    HADI
    Participant

    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.

    #27348
    WC Vendors Support
    Participant

    Beautifully done. 🙂 I’ve put this all into a KnowledgeBase article, too:

    https://www.wcvendors.com/kb/integration-woocommerce-product-gift-wrap/

    #27438
    Rafi
    Participant

    Can 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. Thanks

    #27465
    WC Vendors Support
    Participant

    Rafi: It’s time you read the WC Vendors Pro Setup Guide. It’s in the KnowledgeBase. 😉

    #27556
    David R
    Participant

    That’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?

    #27557
    HADI
    Participant

    I 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.

    #30488
    Joe
    Participant

    This 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?

    #30491
    Joe
    Participant

    Got it fixed. Double check your theme stylesheets people as that’s what it was!

    #31024
    Gabriel
    Participant

    Hi 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

    #31028
    WC Vendors Support
    Participant

    @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

    #31029
    Gabriel
    Participant

    did 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?

    #31030
    Gabriel
    Participant

    it still does not work 🙁

    #31032
    WC Vendors Support
    Participant

    Nope, 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. 🙂

    #31033
    Gabriel
    Participant

    Ok. 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. Works

    #31038
    WC Vendors Support
    Participant

    Success! Thanks for the added screenshots for the benefit of all. Always appreciate helpful forum community contributions!

    #32882
    HADI
    Participant

    I’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?

    #52601
    Ima
    Participant

    Hello @had_hc,

    I am having an exactly same problem…
    It won’t save the change I make with this checkbox.

    #52602
    HADI
    Participant

    @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');
    #52797
    Ima
    Participant

    @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…

    #52882
    HADI
    Participant

    @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’ )

    #55653
    Nadav
    Participant

    Hi 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,
    Nadav

    #55685
    Anna
    Member

    Hello 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.php

    2. 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

    #55699
    Nadav
    Participant

    Brilliant, thanks Anna!

    #70264
    marie mour
    Participant

    Sorry 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.

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