0

We're using a custom extension that allows users to create quotes, in the more traditional sense of a quote. They put together an order, go through checkout, and save the order to their account without paying, and allowing them to order it at a later date with a set pricing. Why? I don't know exactly, but that's what it does. Now, when a user created a quote, it would decrement the stock, on the frontend that was easily resolved by having it check the

$quote->getPayment()->getMethodInstance()->getCode()

attribute. This is throwing errors in the backend though:

Order saving error: Can not retrieve payment method instance

I cannot access the getMethodInstance attribute at all from the backend checkout, so I cannot test to see if the "payment method" is a quote. I'm not too sure what I should even be troubuleshooting on this.

1

This is typically a result of the quote not having a quote_payment associated.

Usually this is due to an exception raised by the payment module or the gateway returned an error.

Try the following, as a test:

$quote = Mage::getModel('sales/quote')->load(/* Your quote's id here */);

if(!Mage::getStoreConfig('payment/checkmo/active')){
  Mage::app()->getStore()->setConfig('payment/checkmo/active', true);
}
$quote->getPayment()->setMethod('checkmo');
$quote->setTotalsCollectedFlag(false)->collectTotals();
$quote->save();

After this, the following should work:

$quote->getPayment()->getMethodInstance()->getCode()

The reasoning is that we've created a payment of type checkmo against the quote, and now the method instance should be available.

  • While this does in fact give me access to the method, regardless of what the selected payment method is set as during the orders creation getCode() and getMethod()/getMethodInstance() all return String: 'checkmo', rather than the set payment method. As far as creating the object so that I can check it sure, but only in a very non-functional way. – Sturm May 13 '13 at 14:00
  • Okay, so the test as recommended did prove that a payment method was not attached. At this point you may not have a full payment method attached to your quote so you will need to attach a proper payment method with the gateway of your choice. If you recommend a gateway I can provide some sample code to help you debug it. – philwinkle May 13 '13 at 16:10
  • 1
    The problem was almost entirely my lack of experience with Magento, after inspecting the 'adminhtml/session_quote' object for a payment method, I found that it was indeed there. – Sturm May 14 '13 at 16:48

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.