Default Postal Code
add_action(‘woocommerce_checkout_create_order’, function ($order, $data) { $default_postcode = ‘00000’; if (empty($order->get_billing_postcode())) { $order->set_billing_postcode($default_postcode); } }, 10, 2);Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
add_action(‘woocommerce_checkout_create_order’, function ($order, $data) { $default_postcode = ‘00000’; if (empty($order->get_billing_postcode())) { $order->set_billing_postcode($default_postcode); } }, 10, 2);Continue reading
function enqueue_custom_tabs_script() { ?>Continue reading
/***********************************************************/ /* Convert ‘transaction_id’ query string param as a cookie */ /***********************************************************/ function tune_capture_transaction_id_cookie() { if ( isset($_GET[‘tune_transaction_id’]) ) { $transaction_id = sanitize_text_field($_GET[‘tune_transaction_id’]); // Set cookie for 30 days setcookie( ‘tune_transaction_id’, // Cookie name $transaction_id, // Cookie value time() +…Continue reading
add_filter( ‘woocommerce_product_add_to_cart_text’, ‘bll_archive_custom_cart_button_text’ ); function bll_archive_custom_cart_button_text( $text ) { global $product; if ( $product && ! $product->is_in_stock() ) { return ‘Join the Waitlist’; } return $text; }Continue reading
add_action(‘wp_footer’, function () { ?>Continue reading
add_filter( ‘woocommerce_coupon_message’, ‘hide_coupon_success_message’, 10, 3 ); function hide_coupon_success_message( $msg, $msg_code, $coupon ) { if ( $msg_code === 200 ) { // 200 is the code for a successful coupon application return ”; // Return an empty string to hide the…Continue reading
add_filter(‘woocommerce_coupon_is_valid’, ‘block_employee_coupon_usage’, 10, 3); function block_employee_coupon_usage($valid, $coupon, $discount) { if (is_user_logged_in()) { $user = wp_get_current_user(); if (in_array(’employee’, (array) $user->roles) || in_array(‘owner’, (array) $user->roles)) { wc_add_notice(__(‘Employees are not allowed to use coupons.’, ‘woocommerce’), ‘error’); return false; } } return $valid; }Continue reading
/** * Handle Meta (Facebook/Instagram Shops) checkout URLs * Format: /checkout?products=wc_post_id_123:2,wc_post_id_456:1&coupon=CODE */ add_action( ‘template_redirect’, function() { if ( ! isset( $_GET[‘products’] ) ) { return; } // Ensure WooCommerce is loaded and cart is available if ( ! function_exists( ‘WC’…Continue reading
/** * WooCommerce: cookie-driven auto-coupon using the coupon’s own restrictions * – URL: ?bllpromo=COUPONCODE -> sets cookie bllpromo=COUPONCODE for 30 days * – If cookie exists and coupon is valid for the current cart (per ALL restrictions), * the coupon…Continue reading
add_filter( ‘woocommerce_coupon_message’, function( $msg, $msg_code, $coupon ) { if ( $msg_code === ‘coupon_already_applied’ ) { return ”; // hide the message } return $msg; }, 10, 3 );Continue reading