Hide Coupon Code Field

Published by Nayem on

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). 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. Then you will see there is no field to apply the coupon code.

You can also change the word "Apply Coupon". Keep following my blog to get the next tuotorial.

 


Nayem

I really love to discuss and research about the new thing. I love #customer #support #php #wordpress #bug. Cheers!! Personal Website: https://nayemdevs.com Contributor @ WordPress.org Linked in: https://www.linkedin.com/in/nayemdevs Twitter: @nayemdevs

Leave a Reply

%d bloggers like this: