Update Product Preview Image after First Variant Attribute Selection

/** * Partial variation image preview (Avada‑friendly, ES5) * Loads after wc-add-to-cart-variation and only on single product pages. */ add_action(‘wp_enqueue_scripts’, function () { if (!is_product()) { return; } // Ensure Woo’s variation script is present. wp_enqueue_script(‘wc-add-to-cart-variation’); // Use NOWDOC so…Continue reading

Move Email after Name in Checkout

add_filter( ‘woocommerce_checkout_fields’, ‘rd_email_first_for_checkout’ ); function rd_email_first_for_checkout( $checkout_fields ) { $checkout_fields[‘billing’][‘billing_email’][‘priority’] = 25; return $checkout_fields; }Continue reading

Keep All Checkout Data in WooCommerce Session

add_action( ‘woocommerce_checkout_update_order_review’, ‘bbloomer_save_checkout_values’, 9999 ); function bbloomer_save_checkout_values( $posted_data ) { parse_str( $posted_data, $output ); WC()->session->set( ‘checkout_data’, $output ); } add_filter( ‘woocommerce_checkout_get_value’, ‘bbloomer_get_saved_checkout’, 9999, 2 ); function bbloomer_get_saved_checkout( $value, $index ) { $data = WC()->session->get( ‘checkout_data’ ); if ( ! $data…Continue reading

HPOS Order Table – Internal Name (Nickname) Column

// 1. Add “Internal Name” column after the Order Number column in HPOS Orders Table add_filter(‘woocommerce_shop_order_list_table_columns’, function($columns) { $new_columns = []; foreach ($columns as $key => $label) { $new_columns[$key] = $label; if ($key === ‘order_number’) { // Insert custom column…Continue reading

HPOS Order Table – Internal Name (Nickname) Column

// 1. Add “Internal Name” column after the Order Number column in HPOS Orders Table add_filter(‘woocommerce_shop_order_list_table_columns’, function($columns) { $new_columns = []; foreach ($columns as $key => $label) { $new_columns[$key] = $label; if ($key === ‘order_number’) { // Insert custom column…Continue reading

Legacy Order Table – Internal Name (Nickname) Column

if ( function_exists(‘wc_get_container’) && ! wc_get_container()->get(\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class)->custom_orders_table_usage_is_enabled() ) { // LEGACY ORDER TABLE SNIPPET HERE add_filter(‘manage_edit-shop_order_columns’, function($columns) { $new_columns = []; foreach ($columns as $key => $label) { $new_columns[$key] = $label; if ($key === ‘order_number’) { $new_columns[‘internal_name’] = ‘Internal Name’; }…Continue reading

Show ‘NEW’ Badges for Recently Added Items in WooCommerce (copy)

/** * 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

Create a Custom Shipping Method in WooCommerce

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

WooCommerce: Restrict Shipping Methods by User Role (Logged In, Logged Out, Custom Roles)

// 💡 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