當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Session::setCustomerData方法代碼示例

本文整理匯總了PHP中Magento\Checkout\Model\Session::setCustomerData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::setCustomerData方法的具體用法?PHP Session::setCustomerData怎麽用?PHP Session::setCustomerData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Checkout\Model\Session的用法示例。


在下文中一共展示了Session::setCustomerData方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetQuoteNotInitializedCustomerSet

 /**
  * Test covers case when quote is not yet initialized and customer data is set to checkout session model.
  *
  * Expected result - quote object should be loaded and customer data should be set to it.
  *
  * @magentoDataFixture Magento/Sales/_files/quote_with_customer.php
  */
 public function testGetQuoteNotInitializedCustomerSet()
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     /** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
     $customerRepository = $objectManager->create('Magento\\Customer\\Api\\CustomerRepositoryInterface');
     $customer = $customerRepository->getById(1);
     $this->_checkoutSession->setCustomerData($customer);
     /** Execute SUT */
     $quote = $this->_checkoutSession->getQuote();
     $this->_validateCustomerDataInQuote($quote);
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:18,代碼來源:SessionTest.php

示例2: testGetQuoteNotInitializedCustomerSet

 /**
  * Test covers case when quote is not yet initialized and customer data is set to checkout session model.
  *
  * Expected result - quote object should be loaded and customer data should be set to it.
  *
  * @magentoDataFixture Magento/Sales/_files/quote_with_customer.php
  */
 public function testGetQuoteNotInitializedCustomerSet()
 {
     /** Preconditions */
     $customerIdFromFixture = 1;
     /** @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerService */
     $customerService = Bootstrap::getObjectManager()->get('Magento\\Customer\\Service\\V1\\CustomerAccountServiceInterface');
     $customer = $customerService->getCustomer($customerIdFromFixture);
     $this->_checkoutSession->setCustomerData($customer);
     /** Execute SUT */
     $quote = $this->_checkoutSession->getQuote();
     $this->_validateCustomerDataInQuote($quote);
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:19,代碼來源:SessionTest.php

示例3: execute

 /**
  * Emulate quote by persistent data
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute($observer)
 {
     $stopActions = ['persistent_index_saveMethod', 'customer_account_createpost'];
     if (!$this->_persistentData->canProcess($observer) || !$this->_persistentSession->isPersistent() || $this->_customerSession->isLoggedIn()) {
         return;
     }
     $actionName = $observer->getEvent()->getRequest()->getFullActionName();
     if (in_array($actionName, $stopActions)) {
         return;
     }
     if ($this->_persistentData->isShoppingCartPersist()) {
         $this->_checkoutSession->setCustomerData($this->customerRepository->getById($this->_persistentSession->getSession()->getCustomerId()));
         if (!$this->_checkoutSession->hasQuote()) {
             $this->_checkoutSession->getQuote();
         }
     }
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:23,代碼來源:EmulateQuote.php

示例4: expire

 /**
  * Expire persistent quote
  *
  * @return void
  */
 public function expire()
 {
     $quote = $this->checkoutSession->setLoadInactive()->getQuote();
     if ($quote->getIsActive() && $quote->getCustomerId()) {
         $this->checkoutSession->setCustomerData(null)->clearQuote()->clearStorage();
     } else {
         $quote->setIsActive(true)->setIsPersistent(false)->setCustomerId(null)->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID);
     }
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:14,代碼來源:QuoteManager.php

示例5: _expirePersistentSession

 /**
  * @return void
  */
 protected function _expirePersistentSession()
 {
     $quote = $this->_checkoutSession->setLoadInactive()->getQuote();
     if ($quote->getIsActive() && $quote->getCustomerId()) {
         $this->_checkoutSession->setCustomerData(null)->clearQuote()->clearStorage();
     } else {
         $quote->setIsActive(true)->setIsPersistent(false)->setCustomerId(null)->setCustomerGroupId(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID);
     }
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:12,代碼來源:Observer.php


注:本文中的Magento\Checkout\Model\Session::setCustomerData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。