Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Min order quantity and free product › Reply To: Min order quantity and free product
April 11, 2016 at 7:39 am
#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)