Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Adding right amount of free product
- This topic has 7 replies, 2 voices, and was last updated 3 years, 2 months ago by Soft79.
-
AuthorPosts
-
April 9, 2020 at 11:30 am #15363Katja MosbachParticipant
Hi!
Reposting:
I’ve tried several different options. What I’m trying to set up this:
Buy 12 matching products and get 1 for free.So it should be:
12 same products in the cart -> adds 1 free product of the same product.
No matter if you also have 1 or more of other products in the cart:12 Product A + 1 free Product A
3 Product B – no free Product BOR
12 Product A + 1 free Product A
12 Product B + 1 free Product B
3 Product C – no free Product CI cant make it work cause either it adds same amount och free products or it add free products on all or it removes the discount when you add another product to your cart of 12 products. Is there a code snippet that I must add or something because with the settings it constantly ends up being wrong solution.
PLEASE HELP <3
April 9, 2020 at 11:50 am #15364Soft79Keymaster– Tick BOGO matching products
– Tick Allow multiplication of the free products
– Use this snippet:add_filter( 'wjecf_bogo_product_amount_for_coupon', function( $amount, $coupon ) { if ( strcasecmp( $coupon->get_code(), 'COUPON_CODE_HERE' ) === 0 ) { $amount = floor($amount / 12); } return $amount; }, 10, 2 );
April 9, 2020 at 12:08 pm #15367Katja MosbachParticipantThank you, thank you!!
Just to be super sure:
I’m adding the code snippet to functions of the theme that I use?
Cause i tried some of the code snippets I found on the forums, but not sure if maybe then posted them in the wrong file? So just want to know the best file to post your code snippet!!Thank you again!
April 9, 2020 at 12:18 pm #15368Soft79KeymasterIn your child theme‘s functions.php
April 9, 2020 at 1:16 pm #15371Katja MosbachParticipantHi! Thank you once again!
I’ve done as said – but it still adds 12 free products rather than just on 1 free/12.
Also as soon you have 12 in the cart or more, for example 14 it adds 14 free products.
And then also if you add another totally different product, just like 1, to the cart of the 14 then it counts the same in the cart – adding a 1 free product/1 product. So you end up with 14product + 14free + 1another product +1 free another product = 30 products in the cart in total.My settings are:
General: Fixed product discount
Usage Restrictions: Ticked: Cant combine with other discunts / Cant be applied on sale / Minimum quantity of matching products: 12
Usage Limits: Limit discount to every nth item
Free Products: Ticked: BOGO matching products / Allow multiplication of the free products
Otherwise only ticked Auto coupon.Is that what effs it up? Or does the code snippet need adjustment?
Please let me know <3
April 9, 2020 at 1:24 pm #15372Soft79KeymasterIn the code snippet you need to replace COUPON_CODE_HERE with the actual coupon code.
April 9, 2020 at 1:57 pm #15373Katja MosbachParticipantOh shit!
I’m sorry. I did that and its almost perfect now!!
Everything works as it should except that if I add more than 12, may it be 13, 14 or 20. It still adds 1 free product. Is it possible to constraint it only 12 products?
I triedUsage Restrictions: Ticked: Cant combine with other discunts / Cant be applied on sale / Minimum quantity of matching products: 12 / Maximum quantity of matching products: 12
and also the combination
Usage Restrictions: Ticked: Cant combine with other discunts / Cant be applied on sale / Minimum quantity of matching products: 12
Usage Limits: Limit usage to X items: 12 / Limit discount to every nth itemDid not work. As said its almost perfect but needs to be restricted to 12 products only
April 9, 2020 at 2:09 pm #15374Soft79KeymasterRemove the Max quantity of matching products.
Don’t use limit discount to every nth item.
Tick ‘allow multiplication’BTW; it should add zero products if you have it setup as you say and there are more than 12 items in the cart…
-
AuthorPosts
- You must be logged in to reply to this topic.