This requires a small snippet in your child theme’s functions.php to work:
add_filter( 'wjecf_free_product_amount_for_coupon',
function( $coupon_qty, $coupon ) {
if ( strcmp( $coupon->get_code(), 'COUPON_CODE' ) === 0 ) {
$min_matching_product_qty = intval( $coupon->get_meta( '_wjecf_min_matching_product_qty' ) );
if ( $min_matching_product_qty > 0 ) {
$coupon_qty = WJECF_API()->get_quantity_of_matching_products( $coupon );
if ( $coupon_qty < $min_matching_product_qty ) {
$coupon_qty = 0;
}
}
}
return $coupon_qty;
}, 10, 2
);
Replace ‘COUPON_CODE’ by the actual coupon code. For the coupon set the minimum quantity of matching products to 5, and it will work.