1

I am trying to set particular payment method in Magento session programatically in methods.phtml. I know how to retrieve current selected payment method from Magento session using getSingleton. But I am not able to find out how to override the existing selected payment method in the session.
I want to directly update the session variable for payment method. Is there anything like Mage::getSingleton('checkout/session')->setMethod('$method'). I have tried every other solution. If there is any function like this then please help me.

  • I just want to set payment method in magento session programatically .. – Dinesh Belakare Nov 12 '13 at 13:50
4

I'm not sure I understand your question, but here goes. You can try this:

$quote = Mage::getSingleton('checkout/session')->getQuote();
$methodCode = 'payment_code_here';
if ($quote->isVirtual()) {
    $quote->getBillingAddress()->setPaymentMethod($methodCode);
} else {
    $quote->getShippingAddress()->setPaymentMethod($methodCode);
}
$quote->save();
0

Looking at your code I noticed you are putting your variable in quotes. Not sure if you noticed that or not but it should look like.

Mage::getSingleton('checkout/session')->setMethod($method);

not

Mage::getSingleton('checkout/session')->setMethod('$method')

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.