Home » Php » php – Magento – Difference between Quote and Order

php – Magento – Difference between Quote and Order

Posted by: admin July 12, 2020 Leave a comment

Questions:

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;
        }
How to&Answers:

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.