In this tutorial, I will explain how to remove other shipping methods if free shipping method is available in your Magento store.
If you want the Free shipping option on the basis of cart total amount like If customer cart total amount is greater than 100 USD, then Free shipping will available, then use the below code in the same file as mention above.
1 2 3 4 5 6 7 | if($subtotal >=100) { // Remove any other shipping methods if free shipping is available. if (array_key_exists('freeshipping', $_shippingRateGroups )) { $_shippingRateGroups = array('freeshipping' => $_shippingRateGroups['freeshipping']); } } |
Copy the below code and paste it inside the app/design/frontend/default/your-theme/template/checkout/onepage/shipping_method/available.phtml file. It will remove the other shipping methods if free shipping method is available.
1 2 3 4 5 6 7 8 9 10 | <?php $subtotal = Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(); // Remove any other shipping methods if free shipping is available. if (array_key_exists('freeshipping', $_shippingRateGroups )) { $_shippingRateGroups = array('freeshipping' => $_shippingRateGroups['freeshipping']); } ?> |
Liked this tutorial? Do Like & share with your friends 🙂
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: magento 2 tutorial, magento advanced tutorials, magento free shipping, magento free shipping method, magento shipping, magento shipping method