Skip to content

Instantly share code, notes, and snippets.

@amenk
Last active October 16, 2015 15:17
Show Gist options
  • Save amenk/d2728c7d81e9ce0bdeb7 to your computer and use it in GitHub Desktop.
Save amenk/d2728c7d81e9ce0bdeb7 to your computer and use it in GitHub Desktop.
Magento - Initialize an (empty) cart, generate shipping rates
/**
* Initialize an (empty) cart
*/
protected function initCart()
{
if (!$this->cart->getQuote()->getId()) {
$this->cart->getQuote()->getShippingAddress()
->setCountryId('DE')
->setCollectShippingRates(true)
->collectShippingRates();
$this->cart->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment