Created
October 10, 2018 09:27
-
-
Save rashmimalpande/59ab07cca5622f44219fcb0180169716 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_ids = array(8, 55, 57); | |
$count = 0; | |
$cart = WC()->cart->get_cart(); | |
foreach ( $cart as $id => $cart_item ) { | |
if( in_array( $cart_item[ 'data' ]->get_id(), $product_ids ) ) { | |
$count++; | |
} | |
} | |
if( $count == count($product_ids ) ) { | |
$enabled = false; | |
} | |
return $enabled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment