When you apply a coupon code programmatically, for example, you may want to hide the coupon code on the cart and checkout page so that the code stays private and cannot be shared with others.
This solution will basically remove the coupon code (e.g. “VWXYZ”) from the “Coupon: VWXYZ” string that appears in the Cart and Checkout totals. Enjoy!
PHP Snippet: Hide Coupon Code from WooCommerce Cart and Checkout Totals
/**
* @snippet Hide Coupon Code - WooCommerce Cart & Checkout
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 7
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
add_filter( 'woocommerce_cart_totals_coupon_label', 'bbloomer_hide_coupon_code', 9999, 2 );
function bbloomer_hide_coupon_code( $label, $coupon ) {
return __( 'Coupon', 'woocommerce' ); // Basically "Coupon: VWXYZ" becomes "Coupon"
}