The PHP code in this premium download enables you to remove the coupon field on the cart and checkout pages if the total is zero. You can use the following PHP code to remove the coupon field on cart and checkout pages using WooCommerce.
// remove coupon field on the cart and checkout pages add_filter( 'woocommerce_coupons_enabled', 'remove_coupon_field_on_cart_checkout' ); function remove_coupon_field_on_cart_checkout( $enabled ) { if ( is_cart() || is_checkout() ) { $enabled = false; } return $enabled; }
The above code disables the coupon field regardless of the total or subtotal in the cart or checkout.
If you want to remove the coupon field when the cart or checkout total is zero, you’ll need to make several checks and use more advanced coding which is available in this premium download.
Installation
Add the PHP code to the end of your child themes functions file or custom functionality/code snippets plugin.
Remove Coupon Field When Cart Equals a Value
Simply change the 0 in the code on line 31 to any other number.
You must be logged in to post a comment.