我对付款方法中如何调用报价和订单有疑问。我所知道的是,报价是提供的一组产品或服务。在magento中,报价数据是在单击Onepage Checkout的Place Order按钮之前创建的。下订单后,在Magento中创建订单数据。如果订单已确认,发票将出现在订单旁边。
但我想知道为什么validate Method中的Class Mage_Payment_Model_Method_Abstract会检查Info Class Instance(如果它是Mage_Sales_Model_Order_Payment的实例)take getOrder()else take getQuote()
我对此不清楚。Validate()函数是否被调用两次,即第一次在创建报价时调用,第二次在创建订单时调用,或者支付方法类本身是否被调用了两次。
请澄清我的困惑。
/**
* 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;
}
Magento中的报价基本上是尚未下订单的报价。它包含产品项目(购物车)、地址和付款/运输方式。一旦您将商品添加到购物车中,它就会立即创建。在结账期间,计费和运输数据会添加到报价中。最后,当用户单击下订单时,报价将转换为订单。
回答您关于付款验证的问题:付款方式包含在报价和订单中,并在两个地方进行验证。付款方式可能仅限于某些国家/地区,因此在验证方式中,报价的付款方式将验证报价国家/地区;订单的付款方式则将验证订单国家/地区。