Magento - difference between quote and order

I have doubts about how quotes and orders are triggered in the payment method. I know Quote is a set of products or services offered. In magento Quote, data is created immediately before clicking the "Order Order" Onepage Checkout button. After placing an order, order data is created in Magento. An invoice is delivered next to the order if the order is confirmed.

But I was wondering why the Mage_Payment_Model_Method_Abstract class in the method check checks an instance of the Info class, if it is an instance of Mage_Sales_Model_Order_Payment, take getOrder (), take getQuote ()

I do not understand. Does the function Validate () call two times the first time when creating a quote and the second time when creating an order, or does the class of the payment method itself be called twice.

Please clarify my confusion.

/** * Validate payment method information object * * @param Varien_Object $info * @return Mage_Payment_Model_Abstract */ public function validate() { /** * to validate paymene method is allowed for billing country or not */ $paymentInfo = $this->getInfoInstance(); if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) { $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId(); } else { $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId(); } if (!$this->canUseForCountry($billingCountry)) { Mage::throwException($this->_getHelper()->__('Selected payment type is not allowed for billing country.')); } return $this; } 
+6
source share
1 answer

A quote at Magento is basically an order that has not yet been placed. It contains commodity items (shopping basket), addresses and payment / delivery methods. It is created as soon as you add an item to the cart. During the check, billing and delivery data are added to the quote. Finally, when the user clicks on a place, the order is converted to an order.

To answer the question about payment validation: the payment method is included in the quote, as well as the order and confirmed in both places. The payment method may be limited to certain countries, therefore, in the verification method, the payment method for the quote will check the country of quotation marks, and the payment method for the order will check the country of the order.

+11
source

Source: https://habr.com/ru/post/908405/


All Articles