Topic Resolution: Resolved
  • This topic has 2 replies, 2 voices, and was last updated 2 years ago by jan.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3770
    jan
    Participant

    I’ve added a coupon for a free product. Works perfect.

    But in the shoppingcart totals there is still a value. It states ‘-€0.00’. I would expect to see something like ‘free product’, since it is no discount.

    Is there a way to change that behavior?

    Thanks,
    Jan

    #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);
    
    #3781
    jan
    Participant

    Thanks, works like a charm.

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