46
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 tutoraspire.com FREE
* @author Tutor Aspire
* @compatible WooCommerce 6
* @donate $9 https://tutoraspire.com
*/
add_filter( 'woocommerce_cart_totals_coupon_label', 'tutoraspire_hide_coupon_code', 9999, 2 );
function tutoraspire_hide_coupon_code( $label, $coupon ) {
return 'Coupon'; // Basically "Coupon: VWXYZ" becomes "Coupon"
}