Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Difference between Quote and Order

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;
        }
like image 373
naquiuddin Avatar asked Feb 14 '12 08:02

naquiuddin


People also ask

What is quote in Magento?

The quote table ( sales_flat_quote on M1) contains records on every shopping cart created in your store, whether they were abandoned or converted to a purchase. Each row represents one cart.

What is a quote table?

A quote table is used to display data in a table format on one of the quote tabs. This data could be used by the quote template when creating a printed quote, for example.


1 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.

like image 166
Anders Thirsgaard Rasmussen Avatar answered Nov 09 '22 14:11

Anders Thirsgaard Rasmussen