Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 13122310958/cf356dccdda7f573ff0f155a8498c583 to your computer and use it in GitHub Desktop.
Save 13122310958/cf356dccdda7f573ff0f155a8498c583 to your computer and use it in GitHub Desktop.
WooCommerce - hide the coupon form on the cart or checkout page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons
<?php
// hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' );
// hide coupon field on checkout page
function hide_coupon_field_on_checkout( $enabled ) {
if ( is_checkout() ) {
$enabled = false;
}
return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_checkout' );
@braddalton
Copy link

add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_checkout' );
function hide_coupon_field_on_checkout( $enabled ) {

    if ( is_cart() || is_checkout() ) {
		$enabled = false;
	}
	return $enabled;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment