Create Woo Store Total Stock Count Shortcodes & Action Hooks
if (!function_exists(‘rd_wc_round_down_step’)) { function rd_wc_round_down_step(int $value, int $step): int { if ($stepContinue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
if (!function_exists(‘rd_wc_round_down_step’)) { function rd_wc_round_down_step(int $value, int $step): int { if ($stepContinue reading
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
if ( ! function_exists( ‘rd_swap_products_on_subscription’ ) ) { function rd_swap_products_on_subscription( $workflow ) { // Map old SKU => new SKU (simple products only; untested with variable/bundled) $sku_mapping = array( ‘9359769001492’ => ‘9359769002352’, // AF Nando’s Chicken & Rice > Spicy…Continue reading
if (!defined(‘ABSPATH’)) exit; add_action(‘wp’, function () { if (is_admin()) { return; } $set = function ($key, $value) { $_GET[$key] = $value; }; $unset = function ($key) { unset($_GET[$key]); }; /* * rd_url_after_sitebase = everything after the site base (path only)…Continue reading
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
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
if ( class_exists( ‘WooCommerce’ ) ) { // Run after RD renaming snippet (in case enabled) add_filter( ‘gettext’, ‘rd_wc_coupon_text_overrides’, 30, 3 ); function rd_wc_coupon_text_overrides( $translated, $original, $domain ) { if ( is_admin() ) { return $translated; } if ( !…Continue reading
function rosso_woocommerce_checkout_terms_and_conditions() { if ( ! class_exists( ‘WooCommerce’ ) ) { return; } remove_action( ‘woocommerce_checkout_terms_and_conditions’, ‘wc_terms_and_conditions_page_content’, 30 ); } add_action( ‘wp’, ‘rosso_woocommerce_checkout_terms_and_conditions’ );Continue reading
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
if ( ! class_exists( ‘WooCommerce’ ) ) { return; } add_filter( ‘woocommerce_shipping_fields’, ‘rd_add_shipping_phone_field’ ); function rd_add_shipping_phone_field( $fields ) { $fields[‘shipping_phone’] = array( ‘label’ => __( ‘Phone (For Delivery Tracking SMS)’, ‘woocommerce’ ), ‘required’ => false, ‘class’ => array( ‘form-row-wide’ ),…Continue reading