TransWikia.com

How to use the country set in the shipping estimate in checkout?

Magento Asked on December 24, 2021

I use the shipping estimate in the cart page and select a country, for example Ethiopia. How can I use this country as default in the (billing + shipping) address in the checkout?

One Answer

Hook into Mage_Checkout_CartController::estimatePostAction and set the countryId() in the billing address to the specified country.

/**
 * Use the country from the shipping estimator in the checkout
 *
 * @event controller_action_predispatch_checkout_cart_estimatePost
 * @param Varien_Event_Observer $observer
 */
public function controllerActionPredispatchCheckoutCartEstimatePost(Varien_Event_Observer $observer)
{
    $request = $observer->getControllerAction()->getRequest();
    $country = (string) $request->getParam('country_id');
    $cart = Mage::getSingleton('checkout/cart');
    $cart->getQuote()->getBillingAddress()->setCountryId($country);
}

Answered by Alex on December 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP