Repository Forums Support WooCommerce Extended Coupon Features PRO 2 Free with any purchase

Topic Resolution: Resolved
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #3688
    Rick
    Participant

    I’m trying to set up a promotion where a customer will receive TWO product A with any purchase.
    I can set it up to add ONE to the cart, but how do I increase the free products to TWO?

    I have MINIMUM SPEND set to 1 and have added the FREE PRODUCT to the FREE PRODUCTS tab. I just need to increase the free item to TWO.

    Thank you.

    #3689
    Soft79
    Keymaster

    You can achieve that with this filter:

    add_filter( 'wjecf_free_product_amount_for_coupon', function ( $amount, $coupon ) {
      if ( $coupon->get_code() == 'COUPON_CODE_HERE' ) {
        $amount = 2;
      }
      return $amount;
    }, 10, 2 );
    

    Please replace COUPON_CODE_HERE by the actual coupon code (lower case).

    #3690
    Rick
    Participant

    Thank you for the quick reply.
    But, I get a syntax error when I add that code to my functions.php file.
    Could there be an error in the code?

    #3692
    Rick
    Participant

    Got it to work. I just added the IF statement to another filter you had sent me a while back with the same name. Works perfect.
    Thank you.

    #3698
    Soft79
    Keymaster

    Are you using a very old PHP version, maybe? Pre 5.3?

    If possible upgrade to 7.x; huge performance profit!

    #3699
    Rick
    Participant

    I had been using 5.6, but after reading your response, went ahead and upgraded to 7.2. Never really paid much attention to the version before. Kind of out of site, out of mind…

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