当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Quote::setCustomer方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Quote::setCustomer方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Quote::setCustomer方法的具体用法?PHP Mage_Sales_Model_Quote::setCustomer怎么用?PHP Mage_Sales_Model_Quote::setCustomer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Quote的用法示例。


在下文中一共展示了Mage_Sales_Model_Quote::setCustomer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _prepareCustomerQuote

 /**
  * Prepare quote customer address information and set the customer on the quote
  *
  * @return self
  */
 protected function _prepareCustomerQuote()
 {
     $shipping = $this->_quote->isVirtual() ? null : $this->_quote->getShippingAddress();
     $customer = $this->_getCustomerSession()->getCustomer();
     $customerBilling = $this->_prepareCustomerBilling($customer);
     if ($shipping) {
         $customerShipping = $this->_prepareCustomerShipping($customer, $shipping);
         if ($customerBilling && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) {
             $customerBilling->setIsDefaultShipping(true);
         } elseif (isset($customerShipping) && !$customer->getDefaultShipping()) {
             $customerShipping->setIsDefaultShipping(true);
         }
     }
     $this->_quote->setCustomer($customer);
     return $this;
 }
开发者ID:adderall,项目名称:magento-retail-order-management,代码行数:21,代码来源:Checkout.php

示例2: _prepareCustomerQuote

 /**
  * Prepare quote for customer order submit
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return Mage_Checkout_Model_Api_Resource_Customer
  */
 protected function _prepareCustomerQuote(Mage_Sales_Model_Quote $quote)
 {
     $billing = $quote->getBillingAddress();
     $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
     $customer = $quote->getCustomer();
     if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
         $customerBilling = $billing->exportCustomerAddress();
         $customer->addAddress($customerBilling);
         $billing->setCustomerAddress($customerBilling);
     }
     if ($shipping && (!$shipping->getCustomerId() && !$shipping->getSameAsBilling() || !$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())) {
         $customerShipping = $shipping->exportCustomerAddress();
         $customer->addAddress($customerShipping);
         $shipping->setCustomerAddress($customerShipping);
     }
     if (isset($customerBilling) && !$customer->getDefaultBilling()) {
         $customerBilling->setIsDefaultBilling(true);
     }
     if ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) {
         $customerShipping->setIsDefaultShipping(true);
     } else {
         if (isset($customerBilling) && !$customer->getDefaultShipping()) {
             $customerBilling->setIsDefaultShipping(true);
         }
     }
     $quote->setCustomer($customer);
     return $this;
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:34,代码来源:Customer.php

示例3: _setQuoteCustomer

 /**
  * @param Mage_Sales_Model_Quote $quote
  * @param ShopgateCartBase       $order
  *
  * @return Mage_Sales_Model_Quote
  * @throws ShopgateLibraryException
  */
 protected function _setQuoteCustomer($quote, $order)
 {
     /* @var $customer Mage_Customer_Model_Customer */
     $customer = Mage::getModel('customer/customer');
     $externalCustomerId = $order->getExternalCustomerId();
     if ($externalCustomerId) {
         $this->log('external customer id: ' . $externalCustomerId, ShopgateLogger::LOGTYPE_DEBUG);
         $customer->load($externalCustomerId);
         if (!$customer->getId()) {
             throw new ShopgateLibraryException(ShopgateLibraryException::UNKNOWN_ERROR_CODE, sprintf('customer with external id \'%s\' does not exist', $externalCustomerId));
         } else {
             $quote->setCustomer($customer);
             // also set customer in session some 3rd party plugins rely on it
             Mage::getSingleton('customer/session')->setCustomer($customer)->setCustomerId($customer->getId())->setCustomerGroupId($customer->getGroupId());
             $this->log('external customer loaded', ShopgateLogger::LOGTYPE_DEBUG);
         }
     }
     $invoiceAddress = $order->getInvoiceAddress();
     if ($invoiceAddress) {
         $this->log('invoice address start', ShopgateLogger::LOGTYPE_DEBUG);
         $quote->getBillingAddress()->setShouldIgnoreValidation(true);
         $billingAddressData = $this->_getSalesHelper()->createAddressData($order, $order->getInvoiceAddress(), true);
         $billingAddress = $quote->getBillingAddress()->addData($billingAddressData);
         $this->log('invoice address end', ShopgateLogger::LOGTYPE_DEBUG);
     }
     $deliveryAddress = $order->getDeliveryAddress();
     if ($deliveryAddress) {
         $this->log('delivery address start', ShopgateLogger::LOGTYPE_DEBUG);
         $quote->getShippingAddress()->setShouldIgnoreValidation(true);
         $shippingAddressData = $this->_getSalesHelper()->createAddressData($order, $order->getDeliveryAddress(), false);
         $shippingAddress = $quote->getShippingAddress()->addData($shippingAddressData);
         $this->_getHelper()->setShippingMethod($shippingAddress, $order);
         $this->log('delivery address end', ShopgateLogger::LOGTYPE_DEBUG);
     }
     $quote->setCustomerEmail($order->getMail());
     $this->log('customer email: ' . $order->getMail(), ShopgateLogger::LOGTYPE_DEBUG);
     if ($invoiceAddress) {
         $this->log('invoice address start (names)', ShopgateLogger::LOGTYPE_DEBUG);
         $quote->setCustomerPrefix($quote->getShippingAddress()->getPrefix());
         $quote->setCustomerFirstname($invoiceAddress->getFirstName());
         $quote->setCustomerLastname($invoiceAddress->getLastName());
         $this->log('invoice address end (names)', ShopgateLogger::LOGTYPE_DEBUG);
     }
     $externalCustomerId = $order->getExternalCustomerId();
     if (empty($externalCustomerId)) {
         $this->log('external customer number unavailable', ShopgateLogger::LOGTYPE_DEBUG);
         $quote->setCustomerIsGuest(1);
         $quote->getShippingAddress();
         $quote->getBillingAddress();
     } else {
         $this->log('external customer number available', ShopgateLogger::LOGTYPE_DEBUG);
         $quote->setCustomerIsGuest(0);
         if ($invoiceAddress) {
             $billingAddress->setCustomerAddressId($invoiceAddress->getId());
         }
         if ($deliveryAddress) {
             $shippingAddress->setCustomerAddressId($deliveryAddress->getId());
         }
     }
     Mage::register('rule_data', new Varien_Object(array('store_id' => Mage::app()->getStore()->getId(), 'website_id' => Mage::app()->getStore()->getWebsiteId(), 'customer_group_id' => $quote->getCustomerGroupId())));
     $quote->setIsActive('0');
     $quote->setRemoteIp('shopgate.com');
     $quote->save();
     if (empty($externalCustomerId)) {
         $quote->getBillingAddress()->isObjectNew(false);
         $quote->getShippingAddress()->isObjectNew(false);
     }
     return $quote;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:76,代码来源:Plugin.php


注:本文中的Mage_Sales_Model_Quote::setCustomer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。