woocommerce free shipping exclude for some classes, Hide other shipping methods when “Free Shipping” is available, Hide free shipping for specific shipping classes exclusively in Woocommerce.
To exclude a specific shipping class, such as one for bulky items, from qualifying for free shipping in WooCommerce, you can modify the settings for the free shipping method. Here’s how to adjust your WooCommerce settings to ensure that orders containing bulky items do not qualify for free shipping:
- Log in to your WordPress dashboard. Navigate to your website’s admin area.
- Go to WooCommerce settings. On the left sidebar, hover over “WooCommerce” and click on “Settings.”
- Access the Shipping tab. This is where you manage all your shipping settings.
- Select the appropriate shipping zone. Click on the shipping zone where you’ve set up free shipping.
- Edit the free shipping method. Click on the “Free Shipping” method you previously created to edit its settings.
- Adjust the free shipping requirements. In the settings for free shipping:
- In the “Free Shipping Requires…” dropdown, choose “A valid free shipping coupon / A minimum order amount / A minimum order amount OR a coupon.”
- Ensure you have set the minimum order amount as needed (e.g., £30).
- Use shipping classes to exclude bulky items:
- First, ensure you have a shipping class created for bulky items. Go to WooCommerce > Settings > Shipping > Shipping classes and make sure there’s a class labeled appropriately (e.g., “Bulky”).
- Then, go back to the shipping zone settings and click on “Edit” under the Free Shipping method.
- Look for an option to exclude shipping classes from free shipping. WooCommerce by default does not offer an explicit option to exclude classes directly from the free shipping method settings. If such an option is not visible, you will need to add custom code to your site.
- Add custom code to function.php: If WooCommerce’s default options don’t support excluding shipping classes directly, you can add the following custom code to your theme’s
functions.php
file:
function disable_free_shipping_for_bulky($is_available, $package) { // Define the shipping class you want to exclude $excluded_class = 'bulky'; // Use the slug of your bulky shipping class // Check each item in the cart foreach ($package['contents'] as $item) { if ($item['data']->get_shipping_class() == $excluded_class) { return false; // Free shipping is not available } } return $is_available; } add_filter('woocommerce_shipping_free_shipping_is_available', 'disable_free_shipping_for_bulky', 10, 2);
Replace 'bulky'
with the actual slug of the shipping class for bulky items in your WooCommerce setup.
- Save changes and test. After adding the custom code, make sure to test the checkout process to ensure that the free shipping option does not appear when a cart contains items from the bulky shipping class.
By using these steps, you can effectively exclude orders containing bulky items from qualifying for free shipping in your WooCommerce store.
Thanks
Jassa
Recent Comments