Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can I use plugins to manage multiple free shipping thresholds for various product categories
    WooCommerce free shipping multiple thresholds shipping plugins Advanced Flat Rate Shipping Method WooCommerce Advanced Free Shipping YayPricing custom shipping method


Can I use plugins to manage multiple free shipping thresholds for various product categories


Yes, you can use plugins to manage multiple free shipping thresholds for various product categories in WooCommerce. Here are some plugins that can help you achieve this:

1. Advanced Flat Rate Shipping Method for WooCommerce:
- This plugin allows you to set different free shipping thresholds for different product categories. You can create multiple shipping methods and set conditions based on product categories, shipping classes, and more[1].

2. WooCommerce Advanced Free Shipping:
- This plugin provides advanced free shipping rules based on various conditions such as subtotal, quantity, user role, country, and more. You can set multiple free shipping thresholds for different product categories by creating multiple shipping rates and setting conditions accordingly[3].

3. YayPricing:
- This plugin offers advanced shipping settings, including free shipping for specific products or customers. You can set different free shipping thresholds for different product categories by configuring the shipping rules and conditions[4].

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 multiple free shipping thresholds for various product categories in WooCommerce requires the use of plugins like Advanced Flat Rate Shipping Method for WooCommerce, WooCommerce Advanced Free Shipping, and YayPricing. 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://www.businessbloomer.com/assign-free-shipping-single-woocommerce-product/
[2] https://www.thedotstore.com/enable-woocommerce-multiple-shipping/
[3] https://wordpress.org/plugins/woocommerce-advanced-free-shipping/
[4] https://yaycommerce.com/create-woocommerce-free-shipping-over-conditions/
[5] https://nl.wordpress.org/plugins/multiple-shipping-options-for-woocommerce/