Home Forums WoodMart support forum Free Gifts & Woocommerce Product Bundles

Free Gifts & Woocommerce Product Bundles

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #648834

    spnutratea
    Participant

    Hi Xtemos,

    There is an issue with the Free Gifts and WooCommerce Product Bundles.

    I am trying to exclude the Free Gifts from the WooCommerce Product Bundle product page, but it doesn’t seem to be working properly.

    Could you kindly take a look and assist us in fixing the issue? Snapshots and links are shared in the private content area.

    Kind regards
    SP

    #648853

    Artem Temos
    Keymaster

    Hello,

    It should work without any problems. Please send us your admin access so we can check it.

    Kind Regards

    #651148

    spnutratea
    Participant

    Hi Artem,

    Please find the credentials in your private content area.

    Could I urge you not to change any coding for the bundle page? The Bundle page link I have shared in your private area.

    Kind regards
    SP

    #651450

    Artem Temos
    Keymaster

    It is not possible to create such a condition at the moment. We will add a special hook in our next theme update and give you a custom code to the child theme to achieve this.

    #652086

    spnutratea
    Participant

    Hi Artem,

    Thank you for letting me know about the issue. I look forward to the custom code and the next update.

    After applying patch #647894, we’ve encountered an issue with the subtotal calculation. Visitors are currently receiving both freebies and discounts with their orders.

    At the moment, free gifts are being added to the cart based on the subtotal before any discount or coupon code is applied, and before the shipping address is entered.

    Would it be possible to modify the logic so that free gifts are applied based on the subtotal after the discount is applied, but before shipping costs are calculated?

    I look forward to hearing from you.

    Kind Regards
    Satya

    #652108

    Artem Temos
    Keymaster

    Hello,

    Here is a custom code to change the way conditions work for bundles

    if ( ! function_exists( 'woodmart_exclude_adding_gifts_for_bundle_products' ) ) {
    	/**
    	 * Exclude adding gifts for bundle products.
    	 *
    	 * @param bool  $is_active Determines if the gift rule is active.
    	 * @param array $gift_rule The gift rule being checked.
    	 * @param array $cart_item The cart item being evaluated.
    	 *
    	 * @return bool Returns false if the product is a bundle or part of a bundle, otherwise returns $is_active.
    	 */
    	function woodmart_exclude_adding_gifts_for_bundle_products( $is_active, $gift_rule, $cart_item ) {
    		$product = $cart_item['data'];
    
    		if ( isset( $cart_item['bundled_by'] ) || 'bundle' === $product->get_type() ) {
    			return false;
    		}
    
    		return $is_active;
    	}
    
    	add_filter( 'woodmart_check_free_gifts_condition', 'woodmart_exclude_adding_gifts_for_bundle_products', 10, 3 );
    }

    As for the second issue, could you please clarify what you mean and send us some screenshots or video so we can better understand what you mean?

    Kind Regards

    #652212

    spnutratea
    Participant

    Hi Artem,

    Thank you for the code snippet I will check it and get back to you later today.

    Snapshot 1: Is showing all free gifts are added to the shopping cart: https://prnt.sc/6ppSMMDLv7f8

    The rule: https://prnt.sc/Ox-kb2YL6KG0

    At the moment, free gifts are being added to the cart based on the subtotal before any discount or coupon code is applied, and before the shipping address is entered.

    £41.93 – Minus discount code £6.29 = £35.64

    Subtotal thresholds: Can we please modify the logic so that free gifts are applied after the discount is applied to the cart.

    Kind regards
    SP

    #652393

    Artem Temos
    Keymaster

    Hello,

    To change the logic, use the following option for Free gifts https://monosnap.com/file/5wlh4YdG13euYC3ezmktlBSkJkqW6g

    Kind Regards

    #652516

    spnutratea
    Participant

    Hi Artem,

    Thank you for your reply. Now it seems working as expected.

    The code snippet for the bundle products is not working :(.

    Also, we want to offer a couple of different free products with the bundles. Will the code above conflict with the new free products?

    I look forward to hearing from you.

    Warm regards
    SP

    #652563

    Artem Temos
    Keymaster

    Hello,

    Sorry, we are a bit confused. Could you please explain with some examples how the custom code should work for you?

    Kind Regards

    #652613

    spnutratea
    Participant

    This code snippet is not working: I have shared the snapshot and link in the private content area.

    if ( ! function_exists( ‘woodmart_exclude_adding_gifts_for_bundle_products’ ) ) {
    /**
    * Exclude adding gifts for bundle products.
    *
    * @param bool $is_active Determines if the gift rule is active.
    * @param array $gift_rule The gift rule being checked.
    * @param array $cart_item The cart item being evaluated.
    *
    * @return bool Returns false if the product is a bundle or part of a bundle, otherwise returns $is_active.
    */
    function woodmart_exclude_adding_gifts_for_bundle_products( $is_active, $gift_rule, $cart_item ) {
    $product = $cart_item[‘data’];

    if ( isset( $cart_item[‘bundled_by’] ) || ‘bundle’ === $product->get_type() ) {
    return false;
    }

    return $is_active;
    }

    add_filter( ‘woodmart_check_free_gifts_condition’, ‘woodmart_exclude_adding_gifts_for_bundle_products’, 10, 3 );
    }

    In the near future, we’ll be offering various products as free gifts along with bundled items. What should I do when that happens?”

    #652676

    Artem Temos
    Keymaster

    Hello,

    This code doesn’t work because the filter will be added in our 8.1.3 update. Sorry for the confusion. If you need to make it work now, we can create a patch. But we still don’t quite understand how do you want to make it work.
    In your initial message, you said you wanted to exclude bundle products, and that is exactly what it does.

    Kind Regards

    #652857

    spnutratea
    Participant

    Hi Artem,

    Thank you for your reply.

    I will wait for the theme update 8.1.3 update.

    Regarding bundle products please find how Free Gifts are configured in the private content section.

    Kind regards
    SP

    #652868

    spnutratea
    Participant

    Please find the admin access in the private content area.

    #653034

    Artem Temos
    Keymaster

    Here are screenshots of how it currently works. You can exclude certain products, but if there’s even one product in the cart that isn’t excluded, the gift will still be added.
    https://monosnap.com/file/pxQgmdTm6yS4p5QZyME9Efx8KCsJRz
    https://monosnap.com/file/5C6GUJLpFvL1fgHGzACVLOUp2hUfo1

    The custom rule we provided creates a condition that excludes a bundle product along with all its associated products (i.e., both the main product and the ones offered with it in the bundle). However, if the cart contains at least one non-bundle product in addition to these, the gift will still be added.

    Do you want to change this logic somehow?

Viewing 15 posts - 1 through 15 (of 15 total)