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


PHP SessionManagerInterface::getCustomerId方法代碼示例

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


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

示例1: getConfig

 /**
  * Retrieve assoc array of checkout configuration
  *
  * @return array
  */
 public function getConfig()
 {
     $vaultPayments = [];
     $customerId = $this->session->getCustomerId();
     if (!$customerId) {
         return $vaultPayments;
     }
     $storeId = $this->storeManager->getStore()->getId();
     if (!$this->vaultPayment->isActive($storeId)) {
         return $vaultPayments;
     }
     $vaultProviderCode = $this->vaultPayment->getProviderCode($storeId);
     $componentProvider = $this->getComponentProvider($vaultProviderCode);
     if (null === $componentProvider) {
         return $vaultPayments;
     }
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::CUSTOMER_ID)->setValue($customerId)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::IS_VISIBLE)->setValue(1)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::PAYMENT_METHOD_CODE)->setValue($vaultProviderCode)->create();
     $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
     foreach ($this->paymentTokenRepository->getList($searchCriteria)->getItems() as $index => $token) {
         $component = $componentProvider->getComponentForToken($token);
         $vaultPayments[VaultPaymentInterface::CODE . '_item_' . $index] = ['config' => $component->getConfig(), 'component' => $component->getName()];
     }
     return ['payment' => [VaultPaymentInterface::CODE => $vaultPayments]];
 }
開發者ID:uibar,項目名稱:lavinia2,代碼行數:31,代碼來源:TokensConfigProvider.php

示例2: getConfig

 /**
  * Retrieve assoc array of checkout configuration
  *
  * @return array
  */
 public function getConfig()
 {
     $availableMethods = [];
     $vaultPayments = $this->getVaultPaymentMethodList();
     $customerId = $this->session->getCustomerId();
     $storeId = $this->storeManager->getStore()->getId();
     foreach ($vaultPayments as $method) {
         $availableMethods[$method->getCode()] = ['is_enabled' => $customerId !== null && $method->isActive($storeId)];
     }
     return [self::$vaultCode => $availableMethods];
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:16,代碼來源:VaultConfigProvider.php

示例3: execute

 /**
  * @inheritdoc
  */
 public function execute()
 {
     $response = $this->resultFactory->create(ResultFactory::TYPE_JSON);
     try {
         $publicHash = $this->getRequest()->getParam('public_hash');
         $customerId = $this->session->getCustomerId();
         $result = $this->command->execute(['public_hash' => $publicHash, 'customer_id' => $customerId])->get();
         $response->setData(['paymentMethodNonce' => $result['paymentMethodNonce']]);
     } catch (\Exception $e) {
         $this->logger->critical($e);
         return $this->processBadRequest($response);
     }
     return $response;
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:17,代碼來源:GetNonce.php

示例4: getTokensComponents

 /**
  * @param string $vaultPaymentCode
  * @return TokenUiComponentInterface[]
  */
 public function getTokensComponents($vaultPaymentCode)
 {
     $result = [];
     $customerId = $this->session->getCustomerId();
     if (!$customerId) {
         return $result;
     }
     $vaultPayment = $this->getVaultPayment($vaultPaymentCode);
     if ($vaultPayment === null) {
         return $result;
     }
     $vaultProviderCode = $vaultPayment->getProviderCode();
     $componentProvider = $this->getComponentProvider($vaultProviderCode);
     if ($componentProvider === null) {
         return $result;
     }
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::CUSTOMER_ID)->setValue($customerId)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::PAYMENT_METHOD_CODE)->setValue($vaultProviderCode)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::IS_ACTIVE)->setValue(1)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::EXPIRES_AT)->setConditionType('gt')->setValue($this->dateTimeFactory->create('now', new \DateTimeZone('UTC'))->format('Y-m-d 00:00:00'))->create();
     $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
     foreach ($this->paymentTokenRepository->getList($searchCriteria)->getItems() as $token) {
         $result[] = $componentProvider->getComponentForToken($token);
     }
     return $result;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:30,代碼來源:TokensConfigProvider.php

示例5: getConfig

 /**
  * Retrieve assoc array of checkout configuration
  *
  * @return array
  */
 public function getConfig()
 {
     $storeId = $this->storeManager->getStore()->getId();
     $customerId = $this->session->getCustomerId();
     return [VaultPaymentInterface::CODE => ['vault_provider_code' => $this->vault->getProviderCode($storeId), 'is_enabled' => $customerId !== null && $this->vault->isActive($storeId)]];
 }
開發者ID:rafaelstz,項目名稱:magento2,代碼行數:11,代碼來源:VaultConfigProvider.php


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