Magento 1.8 – Change Default Shipping Method on Button Click (AJAX)

ajaxcheckoutmagento-1.8php-5.4shipping-methods

How to change default shipping method on button click (ajax call) on checkout page?

Best Answer

You can do this from both PHP or JavaScript

If you go the PHP way, you need to edit the app/design/frontend/[package]/[theme]/template/checkout/onepage/shipping_method/available.phtml file, and around line 47 you have an if statement

if($_rate->getCode()===$this->getAddressShippingMethod())

when this condition returns true, it will set the corresponding method as selected. So you can update the if statement, and check other condition as well

If you want to go the JavaScript way, you need to edit the skin/frontend/base/default/js/onepagecheckout.js file

Related Topic