Last active
March 2, 2020 18:44
-
-
Save rashmimalpande/ecb5fcba474c5b6edcd1ac2972452cba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_coupons_enabled','ts_hide_coupon_field_on_cart' ); | |
function ts_hide_coupon_field_on_cart( $enabled ) { | |
$product_id = 55; | |
$cart = WC()->cart->get_cart(); | |
foreach ( $cart as $id => $cart_item ) { | |
if( $cart_item[ 'data' ]->get_id() == $product_id ) { | |
return false; | |
} | |
} | |
return $enabled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I wonder if you can help? I'm trying to get this to work.
I want to only show the coupon box when the price is more than 19.99 AND its not product id 455821
I can't get this to work. Would you be able to give me any ideas why?
Thanks
Kevin