Modify Free Shipping Threshold in WooCommerce Easily
Explanation
Want to tweak the free shipping settings in WooCommerce? Here's a simple way to do it!
Change the Free Shipping Threshold:
- This code lets you set a new minimum purchase amount for free shipping. Just change the $new_threshold value to whatever amount you prefer. For example, if you want free shipping for orders over $100, set $new_threshold = 100;.
- The code checks your cart total and removes the free shipping option if the total is below your set threshold.
Exclude Certain Products from Free Shipping:
- If you have specific products that shouldn't qualify for free shipping, you can exclude them by adding their product IDs to the $excluded_product_ids array.
- Make sure to replace 123, 456 with the actual IDs of the products you want to exclude.
- The code assigns these products to a different shipping class, ensuring they don't get free shipping.
With these tweaks, you can easily control which orders qualify for free shipping and exclude specific products as needed. Just copy the code into your theme's functions.php file, and you're good to go!
Code
Instructions
File Location: Add the code to your theme's functions.php file or a custom plugin file.
Prerequisites:
- Ensure WooCommerce is installed and activated on your WordPress site.
- Have access to your WordPress theme files or the ability to create a custom plugin.
Implementation Steps:
- Access Your WordPress Dashboard: Log in to your WordPress admin panel.
- Navigate to Theme Editor: Go to Appearance > Theme Editor. If you prefer using a custom plugin, navigate to Plugins > Add New and create a new plugin.
- Open functions.php: In the Theme Editor, locate and open the
functions.phpfile of your active theme. If using a plugin, open your plugin file. - Copy and Paste the Code: Insert the provided code snippet into the
functions.phpfile or your plugin file. - Modify the Free Shipping Threshold: Change the
$new_thresholdvalue to your desired amount for free shipping eligibility. - Exclude Specific Products: Update the
$excluded_product_idsarray with the product IDs you wish to exclude from free shipping. - Save Changes: Click the Update File button to save your changes.
- Test Your Changes: Add products to your cart and verify that the free shipping threshold and exclusions work as expected.
By following these steps, you can easily adjust the free shipping threshold and exclude specific products from free shipping in WooCommerce. If you need further assistance or want to explore more advanced functionalities, consider reaching out to wp-dude.com for expert help.