0

When I issue a reorder from Admin Panel, Magento copies Order Payment data on the new Quote object.

This is confirmed by the code here.

As a result, if I reorder an Order paid with PayPal into one associated to Cash On Delivery payment method, PayPal's IPN data, stored into the additional_information of the Oerder Payment, will be copied into the additional_information of the new Quote Payment and thus into the new Order Payent.

Isn't it strange, given that this doesn't happen if a user reorder from Frontend?

Is there an explanation?

Thank you!

5
  • Looks like you found a bug. Go tell Piotr.
    – benmarks
    Feb 5, 2014 at 17:52
  • I think this is because everyone complained about the fact, that if you edit an order, the payment data isn't copied. Now they changed it (did they?) and we complain again, because they oversaw a case :-) Feb 5, 2014 at 17:55
  • Agree with Ben, think it's a bug. One orders IPN data should not be copied to a reorder.
    – Vinai
    Feb 5, 2014 at 21:02
  • Hi. What is the effect?is it security issue or is it causing some problems? Feb 6, 2014 at 15:42
  • AFAIK it doesn't cause any problem or side effect; it only seems to be a logical mistake, thus I asked about it. Feb 7, 2014 at 8:48

1 Answer 1

2

I think this an interesting topic. At the end of the day, no matter how initFromOrder is being called, it is still necessary to add a new payment method to a reorder or editorder. It is really important to distinguish the difference between the payment data on the quote and on the order objects. It is the order object that ultimately executes place() which fires the $payment->place() function, which on an Order is type:

Mage_Sales_Model_Order_Payment

while on a quote it is type:

Mage_Sales_Model_Quote_Payment

So basically this funky looking function is just preping the Mage_Sales_Model_Quote_Payment payment object so the order can ultimately meet the data requirements to place() on the actual order object.

Keep in mind what is happening here:

$this->getQuote()->getPayment()->addData($order->getPayment()->getData());

The call to get payment data from the order is adding data to the quote payment. take a look at the difference between sales_flat_order_payment and sales_flat_quote_payment tables in the database. also note that the important table is sales_payment_transaction.

This method initFromOrder is used in two places,

1) the EditController,  
2) the CreateController. 

Magento has been migrating to Service Classes for most of the final high level functions, such as place order. this is where the real magic happens.

Mage_Sales_Model_Service_Quote::submitOrder $order->setPayment($this->_convertor->paymentToOrderPayment($quote->getPayment()));

In the Edit Controller context, it is important to remember that Magento isn't actually allowing you to edit an order, it is canceling the order and making a new one leveraging data from the existing order. I've heard a lot of complaints about how this works on the back-end, but remember that Magento is a platform, and often the more specific they make the process, the more work each company using Magento has to fit their particular needs. So while I personally don't find this implementation 'great', it does offer a lot of room for custom business process on the back-end (with custom implementation required).

In the reorder context, you're basically just duplicating the required data so Magento will be able to place the order. some of that has to be simulated since the OnePage process isn't being followed that same as on the front-end.

There is certainly a lot of 'assumption' in the way a re-order operates. I think many of the larger ecommerce stores running Magento tend to have integrated Payment Profile IDs or other mechanisms for being able to re-bill a customer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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