Hide Coupon Code Field

Hide Coupon Field!

If your marketplace does not require a coupon functionality or you do not want your user to apply any coupon code then hide the field from everywhere (Cart/Checkout) of WooCommerce. Now, you can say that “I am not a developer/programmer, how can I do this?”. 
Please follow my below instruction to do this customization easily and in the proper way.

naprlie

How Can You Hide The Field : 

Always try to customize the plugin functionality through a child theme and try to use action/filter to override/extend a functionality. Because overriding through child theme is safe. Otherwise, you can loose your customization during the plugin update.

For this simple customization, I am gonna use the filter- “woocommerce_coupons_enabled”. I will create a new function (my own function) and I will write my condition as well. I know you are not an expert so, Here is the code for you-


function remove_coupon( $enabled ) {
if ( is_cart() || is_checkout() ) {
$enabled = false;
}
return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'remove_coupon' );

Now, Just paste those lines into your child theme’s function.php file and reload your website.

 

Leave a Reply

%d bloggers like this: