Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can I set different free shipping thresholds for different product categories
    WooCommerce free shipping thresholds Advanced Flat Rate Shipping Method plugin shipping rules WooCommerce shipping setup


Can I set different free shipping thresholds for different product categories


Yes, you can set different free shipping thresholds for different product categories in WooCommerce. Here are the steps to follow:

1. Install the Advanced Flat Rate Shipping Method Plugin:
- Download and install the Advanced Flat Rate Shipping Method plugin from the WordPress repository.

2. Create a Shipping Method Rule:
- Navigate to the Woo Pricing & Discounts menu.
- Open the Shipping Methods tab.
- Click on the Add New button to create a new shipping method rule.

3. Add a Base Shipping Method:
- Set a name for your base shipping method.
- Set the Apply Mode to "Apply with other applicable rules" to apply this rule with other applicable shipping rules.
- Set a cost for your base shipping rule.

4. Create a Free Shipping Method:
- Set a name for your free shipping method.
- Set the Apply Mode to "Apply with other applicable rules" to apply this rule with other applicable shipping rules.
- Set the cost to 0 to make it a free shipping method.
- Add a Subtotal Including Tax condition to the rule.

5. Set Different Free Shipping Thresholds for Product Categories:
- Navigate to the Woo Pricing & Discounts plugin Settings Menu.
- Go to the Shipping tab.
- Click on the Add New button to create a new shipping rule.
- Set the Shipping Method to Free Shipping.
- Set the Subtotal Including Tax condition to the specific product category you want to apply the free shipping threshold to.
- Set the Price Threshold to the desired free shipping threshold for that product category.

Example Code for Custom Shipping Rules

Here is an example of how you can create a custom shipping method using the Advanced Flat Rate Shipping Method plugin:

php
// Define the shipping method
function custom_shipping_method() {
    $shipping_method = new WC_Shipping_Method(
        'custom_shipping_method',
        array(
            'id' => 'custom_shipping_method',
            'method_title' => 'Custom Shipping Method',
            'method_description' => 'This is a custom shipping method',
            'instance_form_fields' => array(
                'custom_shipping_rate' => array(
                    'title' => 'Custom Shipping Rate',
                    'type' => 'text',
                ),
            ),
        )
    );

    // Define the shipping rate
    function custom_shipping_rate($package) {
        $shipping_rate = WC_Shipping_Rate::get_rate_by_name('custom_shipping_method', $package);
        if ($shipping_rate) {
            return $shipping_rate->get_rate();
        }
        return 0;
    }

    // Add the shipping method to WooCommerce
    add_filter('woocommerce_shipping_methods', 'add_custom_shipping_method');
    function add_custom_shipping_method($methods) {
        $methods[] = 'custom_shipping_method';
        return $methods;
    }

    // Add the shipping rate to WooCommerce
    add_filter('woocommerce_calculate_shipping_rates', 'add_custom_shipping_rate');
    function add_custom_shipping_rate($rates) {
        $rates[] = new WC_Shipping_Rate(
            'custom_shipping_method',
            'Custom Shipping Method',
            custom_shipping_rate($rates),
            'custom_shipping_method',
            'custom_shipping_method',
            'custom_shipping_method'
        );
        return $rates;
    }

    return $shipping_method;
}

// Register the shipping method
add_action('woocommerce_shipping_init', 'register_custom_shipping_method');
function register_custom_shipping_method() {
    global $woocommerce;
    $woocommerce->shipping->add_method('custom_shipping_method', 'custom_shipping_method');
}

// Initialize the shipping method
add_action('woocommerce_init', 'init_custom_shipping_method');
function init_custom_shipping_method() {
    global $woocommerce;
    $woocommerce->shipping->init('custom_shipping_method');
}

// Add the shipping method to the shipping zones
add_action('woocommerce_shipping_zones', 'add_custom_shipping_method_to_zones');
function add_custom_shipping_method_to_zones($zones) {
    foreach ($zones as $zone) {
        if ($zone->get_zone_name() == 'Your Zone Name') {
            $zone->add_shipping_method('custom_shipping_method');
        }
    }
}

Conclusion

Implementing custom shipping rules for different product categories in WooCommerce requires the use of plugins like Advanced Flat Rate Shipping Method for WooCommerce. These plugins provide extensive features to manage shipping rules based on various conditions. The example code above demonstrates how to create a custom shipping method using the Advanced Flat Rate Shipping Method plugin. This code defines a shipping method, adds it to WooCommerce, and sets the shipping rate based on a custom condition.

Citations:
[1] https://support.google.com/merchants/answer/14768922?hl=en
[2] https://www.intelligems.io/resources/blog/expert-guide-how-to-determine-if-your-free-shipping-threshold-is-hurting-conversion
[3] https://www.shopify.com/enterprise/blog/ecommerce-fulfillment-free-shipping
[4] https://support.google.com/merchants/answer/14768922?hl=en-IE
[5] https://support.orderchamp.com/hc/en-150/articles/360014944278-What-are-the-free-shipping-thresholds