Hide Selected Coupon Code (Name) in Notices + Classic Cart/Checkout Totals

if ( ! defined( ‘ABSPATH’ ) ) { exit; } if ( class_exists( ‘WooCommerce’ ) ) { add_action( ‘woocommerce_coupon_options’, ‘rd_wc_add_hide_coupon_code_field’, 10, 2 ); function rd_wc_add_hide_coupon_code_field( $coupon_id, $coupon ) { $current = get_post_meta( $coupon_id, ‘_rd_hide_coupon_code_public’, true ); woocommerce_wp_checkbox( array( ‘id’ =>…Continue reading

Create Woo Customer Count Shortcodes & Action Hooks

if (!function_exists(‘rd_wc_customer_count_get’)) { function rd_wc_customer_count_get(array $args = array()): int { if (!function_exists(‘WC’)) { return 0; } global $wpdb; $defaults = array( ‘scope’ => ‘all’, ‘registered_only’ => false, ‘roles’ => array(‘customer’), ‘require_role’ => false, ); $args = array_merge($defaults, $args); $scope =…Continue reading

WooPayments Currency Switcher Shortcode

if ( ! function_exists( ‘rd_currency_switcher_shortcode’ ) ) { function rd_currency_switcher_shortcode( $atts ) { if ( ! function_exists( ‘wc_get_currency_switcher_markup’ ) ) { return ”; } // Attributes (defaults) $atts = shortcode_atts( array( ‘flag’ => ‘true’, ‘symbol’ => ‘true’, ‘select_border’ => ‘true’,…Continue reading

Rename WooCommerce “Coupon” terminology to “Discount”

if ( class_exists( ‘WooCommerce’ ) ) { add_filter( ‘gettext’, ‘rd_wc_generic_coupon_replacement’, 20, 3 ); add_filter( ‘ngettext’, ‘rd_wc_generic_coupon_replacement_plural’, 20, 5 ); // Also replace wording directly in notices (covers cases where text bypasses gettext later) add_filter( ‘woocommerce_add_notice’, ‘rd_wc_generic_coupon_replacement_in_notice’, 20, 1 ); add_filter(…Continue reading

Change WooCommerce Coupon Code Entry and Apply Button Text

if ( class_exists( ‘WooCommerce’ ) ) { add_filter( ‘gettext’, ‘rd_wc_coupon_text_overrides’, 20, 3 ); function rd_wc_coupon_text_overrides( $translated, $original, $domain ) { // Only affect front-end Cart & Checkout if ( ! ( function_exists( ‘is_cart’ ) && function_exists( ‘is_checkout’ ) ) )…Continue reading

Open WooCommerce Store Checkout Terms & Conditions in New Window

if ( class_exists( ‘WooCommerce’ ) ) { function rd_woocommerce_checkout_terms_and_conditions() { // Remove WooCommerce’s default T&C content output at priority 30 remove_action( ‘woocommerce_checkout_terms_and_conditions’, ‘wc_terms_and_conditions_page_content’, 30 ); } // Replace with New Window T&Cs – priority set at 31 in Snippet Settings…Continue reading

Create ‘Clear Cart’ URL Parameter

if ( class_exists( ‘WooCommerce’ ) ) { add_action( ‘init’, function() { if ( isset( $_GET[‘clear-cart’] ) && $_GET[‘clear-cart’] === ‘true’ ) { if ( WC()->cart ) { WC()->cart->empty_cart(); } // Remove ?clear-cart=true from URL $clean_url = remove_query_arg( ‘clear-cart’ ); wp_safe_redirect(…Continue reading