Home › Forums › WoodMart support forum › Free Gifts & Woocommerce Product Bundles
Free Gifts & Woocommerce Product Bundles
- This topic has 14 replies, 2 voices, and was last updated 1 week ago by
Artem Temos.
-
AuthorPosts
-
March 25, 2025 at 2:23 pm #648834
spnutrateaParticipantHi 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
SPMarch 25, 2025 at 3:18 pm #648853
Artem TemosKeymasterHello,
It should work without any problems. Please send us your admin access so we can check it.
Kind Regards
April 2, 2025 at 2:52 pm #651148
spnutrateaParticipantHi 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
SPApril 3, 2025 at 2:47 pm #651450
Artem TemosKeymasterIt 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.
April 7, 2025 at 11:34 am #652086
spnutrateaParticipantHi 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
SatyaApril 7, 2025 at 12:25 pm #652108
Artem TemosKeymasterHello,
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
April 7, 2025 at 3:51 pm #652212
spnutrateaParticipantHi 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
SPApril 8, 2025 at 9:39 am #652393
Artem TemosKeymasterHello,
To change the logic, use the following option for Free gifts https://monosnap.com/file/5wlh4YdG13euYC3ezmktlBSkJkqW6g
Kind Regards
April 8, 2025 at 2:13 pm #652516
spnutrateaParticipantHi 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
SPApril 8, 2025 at 3:12 pm #652563
Artem TemosKeymasterHello,
Sorry, we are a bit confused. Could you please explain with some examples how the custom code should work for you?
Kind Regards
April 8, 2025 at 6:36 pm #652613
spnutrateaParticipantThis 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?”
April 9, 2025 at 9:06 am #652676
Artem TemosKeymasterHello,
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
April 9, 2025 at 5:14 pm #652857
spnutrateaParticipantHi 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
SPApril 9, 2025 at 5:27 pm #652868
spnutrateaParticipantPlease find the admin access in the private content area.
April 10, 2025 at 12:08 pm #653034
Artem TemosKeymasterHere 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/5C6GUJLpFvL1fgHGzACVLOUp2hUfo1The 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?
-
AuthorPosts
- You must be logged in to create new topics. Login / Register