Reputation: 77059
A client has asked me to reduce the complexity of Magento's …/template/checkout/cart/shipping.phtml
so that it only asks for (US) Zip Code, bypassing Country and Region, and then furthermore assumes the first shipping option. (Order to be determined by client in the admin). In order to do that, I need to override the estimatePostAction
method from …/Mage/Checkout/controllers/CartController.php
so that it assumes the result from estimateUpdatePostAction
(from the same class).
I'm stuck trying to choose the first shipping option.
The problem I'm having is that the valid shipping values are calculated in the shipping.phtml template via a loop over $this->getEstimateRates()
. How can I get the object that is represented by $this
from within my overriding CartController
class in order to calculate the shipping options?
Note: This is Magento EE ver. 1.11.2.0
If you find the above tl;dr, here's a summary what I'm trying to do:
Upvotes: 1
Views: 796
Reputation: 5277
In /Mage/Checkout/controllers/CartController.php
you can access shipping values which you have in /template/checkout/cart/shipping.phtml
($this->getEstimateRates()
) in next way:
Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getGroupedAllShippingRates();
Upvotes: 2
Reputation: 9090
$this->getQuote()->getShippingAddress()->getGroupedAllShippingRates()
shall return you the collection of shipping rates. Haven't tried it by myself though.
Upvotes: 1