Hiding coupon field in cart for a product category
<p>I'm trying to hide out the coupon code field in the cart for a few excluded products. I've added a product category and exclude this category from the coupon use. </p>

<p>A snippet restricts the cart so only one product at a time is allowed. It's unnecessary to show the coupon code for excluded products in this case. The validation would not let the user apply the coupon but it would be even better if they didn't even see the coupon fields.  </p>

<p>This is a snippet I found that finds a product category and displays a message:</p>

<pre><code>// Find product category
add_action( 'woocommerce_check_cart_items', 'checking_cart_items', 12 );
function checking_cart_items() {
// set your special category name, slug or ID here:
$special_cat = 'myproductcategory';
$bool = false;
foreach ( WC()-&gt;cart-&gt;get_cart() as $cart_item_key =&gt; $cart_item ) {
    $item = $cart_item['data'];
    if ( has_term( $special_cat, 'product_cat', $item-&gt;id ) )
        $bool = true;
}
// Displays a message if category is found
if ($bool)
    echo '&lt;div class="checkoutdisc"&gt;A custom message displayed.&lt;/div&gt;';

}
</code></pre>

<p>This is the general snippet that hides the coupon code in the cart:</p>

<pre><code>// hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {

if ( is_cart() ) {
    $enabled = false;
}

return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' );
</code></pre>

<p>How can I make these functions work together?</p>

<p>Thanks</p>