Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Free product in › Reply To: Free product in
September 13, 2018 at 7:15 pm
#3776
Soft79
Keymaster
Hi Jan,
paste this in your child theme’s functions.php:
add_filter( 'woocommerce_coupon_discount_amount_html', function( $discount_html, $coupon ) {
$amount = WC()->cart->get_coupon_discount_amount( $coupon->get_code(), true );
if ( ! $amount ) {
$plugin = is_callable( 'WJECF' ) ? WJECF()->get_plugin( 'pro-free-products') : false;
if ( $plugin ) {
if ( count( $plugin->get_coupon_free_product_ids( $coupon ) ) > 0 || $coupon->get_meta( '_wjecf_bogo_matching_products' ) === 'yes' ) {
$discount_html = 'Free product!';
}
}
}
return $discount_html;
}, 10, 2);