WooCommerce Checkout Redirect After Adding Product To Cart On Archive...
Read NowWooCommerce Change Coupon Code To Discount Code
Pre-Requisites
There are no pre-requisites for this code snippet to work. Keep in mind this solution consists of two code snippets, one to display the content and one to style it.
How To Implement This Solution?
Add these two code snippets as separate entries in either your active child theme’s functions.php file or the Code Snippets plugin.
About The Snippet
In some contexts, “coupon” might not be the most appropriate term. To address this, we’ve created several guides on renaming “coupon” to various popular synonyms. This particular guide focuses on replacing the word “coupon” with “discount.” Although changing “coupon code” to “discount code” isn’t as straightforward as it might seem, we’ve provided a handy code snippet that will update the term wherever it appears on the front end, including in the cart and checkout.
/** * Snippet Name: Rename Coupon Code to Discount Code everywhere in WooCommerce. * Snippet Author: Nevercrox Solutions */ add_filter( 'gettext', 'nevercrox_rename_coupon_field_on_cart', 10, 3 ); add_filter( 'woocommerce_coupon_error', 'nevercrox_rename_coupon_label', 10, 3 ); add_filter( 'woocommerce_coupon_message', 'nevercrox_rename_coupon_label', 10, 3 ); add_filter( 'woocommerce_cart_totals_coupon_label', 'nevercrox_rename_coupon_label', 10, 1 ); add_filter( 'woocommerce_checkout_coupon_message', 'nevercrox_rename_coupon_message_on_checkout' ); add_filter( 'gettext', 'nevercrox_change_coupon_field_instruction_text' ); function nevercrox_rename_coupon_field_on_cart( $translated_text, $text, $text_domain ) { if ( is_admin() || 'woocommerce' !== $text_domain ) { return $translated_text; } if ( 'Coupon:' === $text ) { $translated_text = 'Discount Code:'; } if ( 'Coupon has been removed.' === $text ) { $translated_text = 'Discount code has been removed.'; } if ( 'Apply coupon' === $text ) { $translated_text = 'Apply Code'; } if ( 'Coupon code' === $text ) { $translated_text = 'Discount Code'; } return $translated_text; } function nevercrox_rename_coupon_message_on_checkout() { return 'Have a discount code? <a href="#" class="showcoupon">Enter it here</a>'; } function nevercrox_change_coupon_field_instruction_text($translated) { $translated = str_ireplace('If you have a coupon code, please apply it below.', '', $translated); return $translated; } function nevercrox_rename_coupon_label( $err, $err_code = null, $something = null ) { $err = str_ireplace("Coupon", "Discount", $err); return $err; }
Just Added Blogs
WooCommerce Change Checkout Field Placeholders
WooCommerce Change Checkout Field Placeholders Pre-Requisites There are no pre-requisites...
Read Now