Repository Forums Support WooCommerce Extended Coupon Features PRO set parent product of the variation as free gift when variation is in the cart

Topic Resolution: Resolved
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1251
    info17
    Participant

    How to achieve?
    i.e.

    product A has variation 1,2,3.
    product B has variation 4,5,6.

    I’d like to set A as free gift if customer has 1/2/3 in the cart.
    And set B as free gift if customer has 4/5/6 in the cart

    #1252
    Soft79
    Keymaster

    Do you mean:
    If user has 3x a variation of A in the cart, he can choose a free 4th variation of A?
    If user has 3x a variation of B in the cart, he can choose a free 4th variation of B?

    #1254
    info17
    Participant

    No, not variation. parent product of variation in the cart.
    (means Product A or B itself)
    buy Product A variation 1 get free gift Product A(not variation)

    I can do this if I specify parent product as free gift if free gift choice is only one.
    And I modified cart to be able to choose variation by customer them self there.

    But finding the way how to choose from multiple free gift choices automatically.

    #1255
    Soft79
    Keymaster

    I don’t think you can add parent products to the cart in WooCommerce.

    #1260
    info17
    Participant

    Actually I can when I set parent product as free gift in Extended Coupon Feature settings.

    i.e. Buy 4 Get 1 Free sale
    http://imgur.com/a/QIfOZ

    #1261
    Soft79
    Keymaster

    Great, so create 2 coupons. One for product A and one for product B.

    #1262
    info17
    Participant

    I know
    but my client want to use same coupon code for couple of products since it’s same product line.
    So I’d like to set free goods programmatically depend on parent product of variation.

    #1270
    Soft79
    Keymaster

    I don’t think that’s possible.

    #1271
    info17
    Participant

    What about using this method you mentioned before to set free gift?
    WJECF()->get_plugin(‘WJECF_Pro_Free_Products’)->set_session_selected_product( $coupon_code, $product_id )
    https://www.soft79.nl/forums/topic/obtain-coupon-info/

    Is there way to utilize this method to set free gift programmatically?

    #1274
    Soft79
    Keymaster

    Try this:

    Set both product A as product B as a free product in the coupon. Then use filter wjecf_set_free_product_amount_in_cart to change the amount of free products (set to zero if the product should not be applied).

    
    add_filter( 'wjecf_set_free_product_amount_in_cart', function ( $quantity, $product_data ) {
    // Logic here
    }, 10, 2 );
    
    #1284
    info17
    Participant

    Thank you.
    Will try.

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