cancel
Showing results for 
Search instead for 
Did you mean: 

How to add shipping amount from cart controller?

How to add shipping amount from cart controller?

Ow 

$formatPrice = Mage::helper('core')->currency($shippingrate, false, false);


$quote = $this->_getQuote();

if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customerData = Mage::getSingleton('customer/session')->getCustomer();
$customerData->getId();
}

$customer = Mage::getModel('customer/customer')->load($customerData->getId());

$customerShippingAddress = $customer->getDefaultShippingAddress();

$country = $customerShippingAddress->getData('country_id');
$postcode = $customerShippingAddress->getData('postcode');
$city = $customerShippingAddress->getData('city');
$regionId = $customerShippingAddress->getData('region_id');
$region = $customerShippingAddress->getData('region');

$this->_getQuote()->getShippingAddress()
->setCountryId($country)
->setCity($city)
->setPostcode($postcode)
->setRegionId($regionId)
->setRegion($region)
->setCollectShippingRates(true);
$this->_getQuote()->save();


$this->_getSession()->setEstimatedShippingAddressData(array(
'country_id' => $country,
'postcode' => $postcode,
'city' => $city,
'region_id' => $regionId,
'region' => $region
));

$this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
$this->_getQuote()->setShippingAmount($formatPrice)->setBaseShippingAmount($formatPrice)->collectTotals()->save();

Grand total not updated , any idea ?

3 REPLIES

Re: How to add shipping amount from cart controller?

Try this link.
https://magento.stackexchange.com/questions/30686/add-shipping-in-cart
 
I have tried, it is working..
 
remember to replace your default shipping method needs to replace in 

BTS_Checkout_Model_Observer

Currently, they have selected 'royalmail'.

private $_shippingCode = 'royalmail';

Hope this link will help you.

Re: How to add shipping amount from cart controller?

I already tried above but not properly work, i want to add shipping amount into cart total from controller file

Re: How to add shipping amount from cart controller?

We need to $50 shipping rate add in cart subtotal when checkbox not checked within 2 seconds from cart controller.