php - WooCommerce Coucpon - Hide 0 amount value for total order section and only show on recurring

one text

We use WooCommerce Subscription and created a recurring coupon. This means on the initial order, there is no discount. Only on the recurring orders. By default WooCommerce displays on the checkout, after adding this coupon, two times the coupon information. One position is shown with the discount value of $0 for to total order and at one position the coupon code amount is shown for the recurring orders.

Screenshot: https://ibb.co/9yKK92X (Checkout page)

This looks strange because this is a coupon only for recurring orders. So it should be shown only on the recurring order section. I tried to hide the coupon in the total order section with the code below. But it does not work as expected. Also I'm not sure if this is the best way of doing it.

Does someone know how we can do that?

add_filter( 'woocommerce_coupon_get_discount_amount', 'filter_woocommerce_coupon_get_discount_amount', 10, 5 ); // add filter for all coupons
function filter_woocommerce_coupon_get_discount_amount( $discount, $discounting_amount, 
$cart_item, $single, $coupon ) { 
// filter the discount if coupon amount is 0
if($discount == 0 && $cart_item['line_subtotal'] == $cart_item['line_total']){ 
    echo "<script>document.querySelector('.cart-discount').style.display = 'none';</script>";
}
    
return $discount;
}

Source