Disabling coupon codes will remove the coupon code field completely from the WooCommerce store. Therefore, customers won’t be able to see the coupon code field on the checkout page and the cart page.
However, you can hide the coupon code field from the cart or checkout page and make it visible on other pages of the store. To achieve this:
- Navigate to the Theme file editor.
- Access the function.php file.
- Copy the code snippet given below.
- Paste the code into the function.php file.
- Save changes.
Step 1: Access WordPress theme file editor
From the WordPress Dashboard, navigate to Appearance > Theme Editor to open the WordPress Theme Editor screen.
Step 2: Open functions.php file
In the Theme Editor screen, you can see the list of files in your active theme’s folder. Scroll down through the list and click on the Theme Functions (functions.php) file to open it in the text editor screen.
Step 3: Copy the PHP code
Depending on which page you want to disable the coupon code field, you can copy either of the two PHP code snippets given below.
PHP code to disable coupon code field in the cart page
PHP code to disable coupon code field in the checkout page
Step 4: Add the PHP code to functions.php
In the WordPress Theme Editor screen, scroll down to the bottom of the functions.php file and paste the code at the end.
Step 5: Update code
Click on the Update file button to save the code.
- Was this article helpful?
- Yes, thanks!Not really
Comments (2)
Casey Shimata
July 5, 2022
Do you expose any hooks, public functions, or register REST end points so that developers can create/update/get coupons? I need to be able to create bogo coupons and wp_query coupons based on their properties, or get coupons in cart and read their properties.
Mike
July 21, 2022
Hi Casey,
Currently, we are not providing any hook/public functions/REST endpoints for creating BOGO coupons.