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?
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.
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.
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?
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 );