1

I want to change the currency to USD for a quote depending on shipping method in Onepage checkout. The new currency should be reflected in the order review before going to the payment provider. A bonus would be if both currencies can be shown in the review, but only USD is also fine.

Nothing I do seem to have any effect, even though I recompile and empty the cache between . This is my current attempt:

app/code/local/Mage/Checkout/controllers/OnepageController.php

/**
 * Save payment ajax action
 *
 * Sets either redirect or a JSON response
 */
public function savePaymentAction()
{
    if ($this->_expireAjax()) {
        return;
    }
    try {
        if (!$this->getRequest()->isPost()) {
            $this->_ajaxRedirectResponse();
            return;
        }

        $data = $this->getRequest()->getPost('payment', array());
        $result = $this->getOnepage()->savePayment($data);
        if ($data['method'] == 'ourpaymentmethodofchoice') {
            Mage::app()->getStore()->setCurrentCurrencyCode('USD');
        }
    // etc

I have also tried this:

            $currency = Mage::getModel('directory/currency')->load('USD')
            $quote = $this->getOnepage()->getQuote();
            $quote->setForcedCurrency($currency);
            $quote->save();
            $this->getOnepage()->saveOrder();

We are running Magento 1.9.

What is the best way to change the currency programatically?

  • Did you try $quote->setBaseCurrencyCode($currencyCode); $quote->setQuoteCurrencyCode($currencyCode);? – Renon Stewart Sep 22 '15 at 14:59
  • The problem might be that I assumed controllers to be overridable in the same way as everything else in Magento: by copying the file to local/. That does not seem to be the case so it is still using the original core controller. I guess this question might be considered on hold in the meantime. – Emil Vikström Sep 22 '15 at 15:30
  • $quote->setBaseCurrencyCode($currencyCode); $quote->setQuoteCurrencyCode($currencyCode); did not make any difference. – Emil Vikström Sep 22 '15 at 15:41
1

donot use

$this->getOnepage()->saveOrder(); fire order place.

Add below code after Mage::app()->getStore()->setCurrentCurrencyCode('USD');

$this->getOnepage()->getQuote()->collectTotals()->save(); for calculate quote price

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.