Repository Forums Support WooCommerce Extended Coupon Features PRO One problem and one question BOGO

Topic Resolution: Resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5221
    Melvin Cheah
    Participant

    I have setup the following (match3):
    -Fixed product discount
    -Products OR ticket1 exclude ticket2
    -Minimum quantity 3
    -free products: ticket1
    -allow multiplication of product
    -BOGO

    When 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!

    #5225
    Soft79
    Keymaster

    Hi,

    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)

    #5226
    Melvin Cheah
    Participant

    Hi!

    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!

    #5227
    Soft79
    Keymaster

    Yeah, looks good. Alternatively you could do this:

    
    $amount = 2 * $min_matching_product_qty * floor( $amount / $min_matching_product_qty );
    
    #5228
    Melvin Cheah
    Participant

    That’s a good idea. Thanks! It’s cleaner and allows for more manipulation on the min quantity.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.