How to Apply shipping method programmatically in Magento | Magento Source24

How to Apply shipping method programmatically in Magento | Magento Source24

👉 Hello Magento friends today's i'm share with you to  How to Apply shipping method programmatically in Magento

use this bellow code in your php logic file to  Apply shipping method programmatically in Magento 



public function saveShippingAction()
{
    if ($this->_expireAjax()) {
        return;
    }
    if ($this->getRequest()->isPost()) {
        $data = $this->getRequest()->getPost('shipping', array());
        $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
        $result = $this->getOnepage()->saveShipping($data, $customerAddressId);

        if (!isset($result['error'])) {
            //$method = 'flatrate_flatrate';
            $method = 'tablerate_bestway';        
            $result = $this->getOnepage()->saveShippingMethod($method);
            Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->setShippingMethod($method)->save();

            if (!isset($result['error'])) {

                $result['goto_section'] = 'payment';
                $result['update_section'] = array(
                    'name' => 'payment-method',
                    'html' => $this->_getPaymentMethodsHtml()
                );
            }
        }
        $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
    }
}



Deepak Kumar Bind

Success is peace of mind, which is a direct result of self-satisfaction in knowing you made the effort to become the best of which you are capable.

Post a Comment

If you liked this post please do not forget to leave a comment. Thanks

Previous Post Next Post