Temporarily disable the WooCommerce ‘Completed Order’ email
add_filter( ‘woocommerce_email_enabled_customer_completed_order’, ‘__return_false’ );Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
add_filter( ‘woocommerce_email_enabled_customer_completed_order’, ‘__return_false’ );Continue reading
add_filter(‘woocommerce_shipping_methods’, ‘register_wholesale_shipping_method’); function register_wholesale_shipping_method($methods) { $methods[‘wholesale_shipping’] = ‘WC_Shipping_Wholesale’; return $methods; } if (!class_exists(‘WC_Shipping_Wholesale’)) { class WC_Shipping_Wholesale extends WC_Shipping_Method { public function __construct($instance_id = 0) { $this->id = ‘wholesale_shipping’; $this->instance_id = absint($instance_id); $this->method_title = __(‘Wholesale Shipping’); $this->method_description = __(‘Flat rate shipping…Continue reading
// 💡 Load multiselect field to all shipping methods add_action(‘woocommerce_init’, ‘woocommerce_shipping_instances_form_fields_filters’); function woocommerce_shipping_instances_form_fields_filters() { foreach (WC()->shipping->get_shipping_methods() as $shipping_method) { add_filter(‘woocommerce_shipping_instance_form_fields_’ . $shipping_method->id, ‘add_allowed_roles_field_to_shipping_methods’); } } // 🎯 Add multiselect role option (styled like tag input) function add_allowed_roles_field_to_shipping_methods($settings) { $settings[‘allowed_user_roles’] =…Continue reading
function always_display_products($visible, $prd_id) { // Get current user object $user = get_current_user(); // Get current user’s active subscriptions $active_subs = $user->active_product_subscriptions(‘ids’); // Check if the user has a specific subscription (ID 1234) and the current product ID is 222 if…Continue reading
/** * Snippet Name: Show ‘NEW’ Badges for Recently Added Items in WooCommerce * Snippet Author: wdxtechnologies.com */ // Show the NEW badge on the archive loop item add_action( ‘woocommerce_after_shop_loop_item_title’, ‘ecommercehints_product_archive_new_badge’, 1 ); function ecommercehints_product_archive_new_badge() { global $product; $days_to_show =…Continue reading
add_action(‘woocommerce_subscription_status_active’, ‘send_admin_subscription_reactivated_email’, 10, 1); function send_admin_subscription_reactivated_email($subscription) { // Get the WooCommerce mailer $mailer = WC()->mailer(); // Get the email template content ob_start(); wc_get_template( ’emails/admin-subscription-reactivated.php’, // Your custom template file array( ‘subscription’ => $subscription, ’email_heading’ => ‘Subscription Reactivated’, ‘sent_to_admin’ => true,…Continue reading
add_action(‘woocommerce_before_customer_login_form’, ‘custom_login_message’); function custom_login_message() { echo ‘ Welcome! Please log in to access your account. Note: A valid subscription is required to access your account. ‘; }Continue reading
function add_currency_below_total() { $currency = get_woocommerce_currency(); // Get currency code (e.g., USD, CAD, EUR) echo ‘ ‘ . __(‘Currency’, ‘woocommerce’) . ‘ ‘ . esc_html($currency) . ‘ ‘; } add_action(‘woocommerce_review_order_after_order_total’, ‘add_currency_below_total’);Continue reading
// Product details in separate metadata lines + billing country + taxes + coupons add_filter(‘wc_stripe_intent_metadata’, ‘add_custom_stripe_metadata’, 10, 2); function add_custom_stripe_metadata($metadata, $order) { $count = 1; $billing_country = $order->get_billing_country(); // Get billing country $order_subtotal = $order->get_subtotal(); // Get order subtotal $cart_discount…Continue reading
function g9_woo_selectbox() { $per_page = filter_input(INPUT_GET, ‘perpage’, FILTER_SANITIZE_NUMBER_INT); echo ‘ ‘; echo ‘‘; $orderby_options = array( ’12’ => ’12 Items’, ’24’ => ’24 Items’, ’48’ => ’48 Items’, ’96’ => ’96 Items’ ); $shop_page_url = get_permalink(wc_get_page_id(‘shop’)); foreach ($orderby_options as $value…Continue reading