Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › One problem and one question BOGO
- This topic has 4 replies, 2 voices, and was last updated 7 years, 3 months ago by Melvin Cheah.
- AuthorPosts
- May 24, 2019 at 9:44 am #5221Melvin CheahParticipant
I have setup the following (match3):
-Fixed product discount
-Products OR ticket1 exclude ticket2
-Minimum quantity 3
-free products: ticket1
-allow multiplication of product
-BOGOWhen I go to cart and apply the coupon on 3 ticket1, I get a Free! quantity 4 ticket1
If I add 4 then I get free 5.
How do I fix this? What did I do wrong?I would also like another coupon code whereby it would be triple10 whereby if someone adds 10 x ticket1 to cart and uses that code, they get 20 x ticket1 free. How would I do that?
Thanks!
May 24, 2019 at 8:20 pm #5225Soft79KeymasterHi,
1. Remove the ‘ticket1’ from free products. Just checking the BOGO is enough. You can also remove the excluded ‘ticket2’
2. You need a snippet in your child theme’s functions.php for that. Set minimum quantity of matching products of the coupon to 10 and use this snippet:
add_filter( 'wjecf_bogo_product_amount_for_coupon', function ( $amount, $coupon ) { if ( strcasecmp( $coupon->get_code(), 'COUPON_CODE_HERE' ) == 0 ) { $min_matching_product_qty = intval( $coupon->get_meta( '_wjecf_min_matching_product_qty' ) ); if ( $min_matching_product_qty < 1 ) $min_matching_product_qty = 1; $amount = 2 * floor( $amount / $min_matching_product_qty ); } return $amount; }, 10, 2 );(untested)
May 25, 2019 at 9:07 am #5226Melvin CheahParticipantHi!
Thanks for #1. That was what I needed to make it work.
For #2, I inserted my COUPON CODE that I created with minimum quantity 10 into ‘COUPON_CODE_HERE’. I also changed it to $amount = 20 * floor( $amount / $min_matching_product_qty );
This makes more sense and gives me the result I want since if min quantity is set as 10 and I order place 10 in cart, that will return a 1 multiply by 20 and that amount is added to cart for free. For 15 it returns 1 as well and for 20 it returns 2 which gives me the desired result.
Let me know if my logic is off and if it will create problems. Thanks!
May 25, 2019 at 9:58 am #5227Soft79KeymasterYeah, looks good. Alternatively you could do this:
$amount = 2 * $min_matching_product_qty * floor( $amount / $min_matching_product_qty );May 25, 2019 at 10:36 am #5228Melvin CheahParticipantThat’s a good idea. Thanks! It’s cleaner and allows for more manipulation on the min quantity.
- AuthorPosts
- You must be logged in to reply to this topic.