Magento - Difference between Quote and Order

青春壹個敷衍的年華 提交于 2020-01-01 09:47:14

问题


I have a doubt about how quotes and orders are being called in payment method. What I know is that a Quote is a set of products or services offered. In magento Quote data is created just before clicking Place Order button of Onepage Checkout. After the Order is placed Order data is created in Magento. Invoice comes next to Order if Order is confirmed.

But I was wondering why the Class Mage_Payment_Model_Method_Abstract in validate Method checks Info class Instance if it is an instance of Mage_Sales_Model_Order_Payment take getOrder() else take getQuote()

I am not clear with this. Does the Validate() function is called two time i.e first time when Quote is created and second time when Order is Created OR does the Payment Method Class itself is called two times.

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;
        }

回答1:


A quote in Magento is basically an order that hasn't been placed yet. It contains product items (shopping cart), addresses and payment/shipping methods. It is created as soon as you add an item to cart. During checkout, billing and shipping data is added to the quote. Finally, when the user clicks place order, the quote is converted to an order.

To answer your question about the payment validation: The payment method is included in the quote as well as the order and validated in both places. A payment method may be restricted to certain countries, so in the validate method, a payment method for a quote will validate the quote country, and a payment method for an order will validate the order country.



来源:https://stackoverflow.com/questions/9273537/magento-difference-between-quote-and-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!