Repository Forums Support WooCommerce Extended Coupon Features PRO Min order quantity and free product

Topic Resolution: Resolved
Viewing 15 posts - 1 through 15 (of 34 total)
  • Author
    Posts
  • #391
    Natasha Solley
    Participant

    Hi there

    I want to do an auto coupon that requires the customer to have to purchase a minimum of 10 items of product x to qualify for the free gift offer. But once they reach that min number of product x I want them to get product y free – but match the number of product x they have in their cart. is this possible?

    #392
    Soft79
    Keymaster

    Yes, this is possible.

    On the usage restriction tab select the product (x) that must be in the cart.
    On the product tab set ‘Minimum quantity of marching products’ to 1.
    On the product tab check the box ‘Allow multiplication’.
    On the product tab enter the ‘Free product’ to give away (y)
    On the misc tab check ‘Auto coupon’

    #395
    Natasha Solley
    Participant

    Hi there thanks for this. I need them to have purchased a minimum number of item x though – being 10 to be able to qualify for the free products. When I do this they only receive 1 free product when it should match how many they have purchased of item x.

    #396
    Soft79
    Keymaster

    I see… I didn’t read your question well, sorry about that.

    I’ll think about a solution and will come back to you this week…

    #398
    Natasha Solley
    Participant

    OK thank you so much 🙂

    #401
    Natasha Solley
    Participant

    Hi there sorry another question while you are looking. I want to be able to do a promotion where the customer buys 3 of an item and gets 1 free of the same item. But I also want them to be able to buy more if they want – so if they purchased 6 of that item that they would then get 2 items free.

    #404
    Soft79
    Keymaster

    This weekend I will add some filters to my plugin, so you can alter the quantity of free products that is applied using a small custom php script in your theme’s functions.php. More or less like this:

    
    add_filter( 'wjecf_free_product_amount_for_coupon', 'wjecf_free_product_amount_for_coupon', 10, 2 );
    function wjecf_free_product_amount_for_coupon ( $amount, $coupon ) {
      if ( $coupon->code == 'your-plugin-code' ) {
        $amount = WJECF_API()->get_quantity_of_matching_products( $coupon );
      }
      return $amount;
    }
    

    What do you think?

    #405
    Natasha Solley
    Participant

    That would amazing thank you 🙂
    So will that be an update on the plugin or do I just need to add this code to my themes functions.php ?

    #406
    Soft79
    Keymaster

    Please wait for the update!

    #407
    Natasha Solley
    Participant

    Ok brilliant thank you so much 🙂

    #409
    Soft79
    Keymaster

    Please download 2.3.3-b2 (you can find it on your orders page) and try this:

    1. Create a coupon with minimum amount of matching products of 10 and free product y
    2. Don’t check the ‘Allow multiplication’ checkbox
    3. In your theme’s functions.php paste the snippet I posted this morning, and replace your-plugin-code with the actual coupon code. (Please notice that I edited the snippet)

    Let me know if that works fine.

    #412
    Natasha Solley
    Participant

    Hi there

    That worked perfectly that you 🙂 Will that only work with that specific promotion though – not for any others?

    Also another one I would like to do is:
    I want to be able to do a promotion where the customer buys 3 of an item and gets 1 free of the same item. But I also want them to be able to buy more if they want – so if they purchased 6 of that item that they would then get 2 items free.

    #413
    Soft79
    Keymaster

    Just extend your hook script, like this:

    
    add_filter( 'wjecf_free_product_amount_for_coupon', 'wjecf_free_product_amount_for_coupon', 10, 2 );
    function wjecf_free_product_amount_for_coupon ( $amount, $coupon ) {
      switch ( $coupon->code ) {
        case 'free-x-for-every-y':
          $amount = WJECF_API()->get_quantity_of_matching_products( $coupon );
          break;
        case 'free-y-for-every-three-x':
          $amount = intval( WJECF_API()->get_quantity_of_matching_products( $coupon ) / 3 );
          break;
      }
      return $amount;
    }
    

    (Untested. Please the replace coupon codes with yours)

    #417
    Natasha Solley
    Participant

    Hi there thank for this – however its not quite doing what I had wanted. I need it to add more items of the free product when they do more than multiples of 3. Eg buy 6 and then they would get 2 free products. Like the first one you did.

    #418
    Soft79
    Keymaster

    That’s what it should do… did you replace free-y-for-every-three-x with your coupon-code?

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