This article shows a shortcut to hide the coupon code field from your cart and checkout pages.
- 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 the 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
You can see the list of files in your active theme folder on the Theme Editor screen. Please scroll down 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, copy either of the two PHP code snippets below.
PHP code to disable the coupon code field on the cart page
PHP code to disable the coupon code field on 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.
hello
February 4, 2024
Hi
can any one help me how i can make this code work in specific category
Arjun
February 7, 2024
Hi,
Thank you for reaching out. You can use this code snippet to hide the coupon field while adding products from selected categories. Make sure to replace the numbers in line 17 with respective category ID’s.
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.