[vc_cta h2=”The Below Code Works for the Following Plugins:”]
- WooCommerce UPS Shipping plugin
- ELEX WooCommerce DHL Express / Paket Shipping plugin
- WooCommerce FedEx Shipping plugin
- ELEX WooCommerce USPS Shipping plugin
- WooCommerce Canada Post Shipping plugin
- ELEX WooCommerce Stamps.com USPS Shipping plugin
- ELEX WooCommerce Australia Post Shipping plugin
- WooCommerce Multi-Carrier Shipping plugin
- WooCommerce Table Rate Shipping Pro plugin
- ELEX EasyPost (UPS, USPS & FedEx) Shipping plugin
[/vc_cta]
WooCommerce doesn’t sort the shipping methods / services by default while showing it on cart and checkout page.
Code Snippet for sorting the shipping options by cost.
Below code snippet will help to sort the shipping options by shipping cost.
Screenshot – Shipping Options – Default view.
Screenshot – Shipping Options – Sorted view.
Code still works! Thank you!
This used to work up until we upgraded woocommerce to 3.2.5 and wordpress to 4.9.1 now when something is added to the cart, it returns this error:
Warning: array_keys() expects parameter 1 to be array, null given in /home4/ffxbmeus/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 478
Warning: array_keys() expects parameter 1 to be array, null given in /home4/ffxbmeus/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 449
Warning: current() expects parameter 1 to be array, null given in /home4/ffxbmeus/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 450
Warning: array_keys() expects parameter 1 to be array, null given in /home4/ffxbmeus/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 478
Warning: array_keys() expects parameter 1 to be array, null given in /home4/ffxbmeus/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 449
Warning: current() expects parameter 1 to be array, null given in /home4/ffxbmeus/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 450
Hi Marc,
We tested this on our side but could not replicate the issue. Would it be possible for you to approach our support team on this so that they can resolve the problem? Here is the URL of support.
Works Perfectly, Thanks a lot!
You are welcome. 🙂
Thanks!
thats for the code, it works great!
You are welcome. 🙂
Thanks!
Where is the code snippet?
You will find it under the title “Code Snippet for sorting the shipping options by cost.”.
One should be careful with this code snippet. It sorts the shipping correctly, however, it causes an error to appear that says “no shipping method has been selected” when clicking the payment button. I’m using the latest version of wordpress (4.6.1) and woocommerce (2.6.6).
Strange. I can’t see the code snippet. I tried 3 different browsers. I see the title and the screenshots, but no code snippet.
Worked! Thank you for this snippet