If the WooCommerce “Apply coupon” field isn’t showing on the cart or checkout page, it might be due to a few different reasons.
Here’s a checklist to help you troubleshoot the issue (maybe do this on a staging site):
- WooCommerce Settings: Ensure that the use of coupons is enabled. Go to
WooCommerce
->Settings
->General
and check the box for “Enable the use of coupon codes”. - Theme Compatibility: Some themes might override WooCommerce templates and accidentally remove the coupon field. Try temporarily switching to another theme like Storefront to see if the issue persists. Alternatively, check your themes settings and see if it has an option to show the apply coupon option on your cart/checkout page.
- Conflicting Plugins: Deactivate other plugins one by one to find if there is a conflict causing the coupon field to disappear.
- Custom Code: If you have custom code snippets added to your theme’s
functions.php
file or a site-specific plugin, ensure there’s nothing that would hide the coupon field. - Template Overrides: Check if your theme has overridden the
cart.php
template. Go toWooCommerce
->System Status
->Templates
and look for overridden templates. Update or remove overrides if necessary. - JavaScript Issues: Browser Console might show JavaScript errors that could be hiding the coupon field. Check for errors and resolve them.
- CSS Styling: Sometimes, CSS might be hiding the coupon field (
display: none;
). Check your CSS files and inline styles.
If you’re comfortable doing so, you can also try to manually add the coupon form to your cart or checkout page using a hook in your theme’s functions.php
file or using a code snippets plugin.
Here’s an example:
Cart:
This code will hook the coupon form right before the cart table on the cart page. Ensure that the woocommerce_before_cart_table
action is present in your cart template for this to work.
function custom_add_coupon_field_to_cart() {
if ( wc_coupons_enabled() ) {
woocommerce_form_field( 'coupon_code', array(
'id' => 'coupon_code',
'label' => __( 'Coupon', 'woocommerce' ) . ':',
'placeholder' => __( 'Coupon code', 'woocommerce' ),
'class' => 'input-text',
), '' );
}
}
add_action( 'woocommerce_before_cart_table', 'custom_add_coupon_field_to_cart' );
Checkout:
This code will hook the coupon form right before the checkout. Ensure that the woocommerce_before_checkout_form
action is present in your checkout template for this to work.
function custom_add_coupon_field_to_checkout() {
if ( ! is_checkout() || WC()->cart->is_empty() ) {
return;
}
echo '<div class="woocommerce-form-coupon-toggle">';
echo '<p>' . __( 'Have a coupon? Click here to enter your code.', 'woocommerce' ) . '</p>';
echo '</div>';
woocommerce_checkout_coupon_form();
}
add_action( 'woocommerce_before_checkout_form', 'custom_add_coupon_field_to_checkout', 10 );
Always make a backup of your site before making changes.