本文整理汇总了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]];
}
示例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];
}
示例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;
}
示例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;
}
示例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)]];
}