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


PHP CurrentCustomer::getCustomerId方法代码示例

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


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

示例1: getSectionData

 /**
  * {@inheritdoc}
  */
 public function getSectionData()
 {
     $customerId = $this->currentCustomer->getCustomerId();
     if ($this->paypalData->shouldAskToCreateBillingAgreement($this->config, $customerId)) {
         return ['askToCreate' => true, 'confirmUrl' => $this->escaper->escapeUrl($this->urlBuilder->getUrl($this->startAction, [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1])), 'confirmMessage' => $this->escaper->escapeJsQuote(__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'))];
     }
     return [];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:BillingAgreement.php

示例2: getSectionData

 /**
  * {@inheritdoc}
  */
 public function getSectionData()
 {
     if (!$this->currentCustomer->getCustomerId()) {
         return [];
     }
     $customer = $this->currentCustomer->getCustomer();
     return ['fullname' => $this->customerViewHelper->getCustomerName($customer), 'firstname' => $customer->getFirstname()];
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:Customer.php

示例3: getCustomerName

 /**
  * Return the full name of the customer currently logged in
  *
  * @return string|null
  */
 public function getCustomerName()
 {
     try {
         $customer = $this->customerRepository->getById($this->currentCustomer->getCustomerId());
         return $this->escapeHtml($this->_viewHelper->getCustomerName($customer));
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         return null;
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Customer.php

示例4: getReviews

 /**
  * Return collection of reviews
  *
  * @return array|\Magento\Review\Model\Resource\Review\Product\Collection
  */
 public function getReviews()
 {
     if (!($customerId = $this->currentCustomer->getCustomerId())) {
         return [];
     }
     if (!$this->_collection) {
         $this->_collection = $this->_collectionFactory->create();
         $this->_collection->addStoreFilter($this->_storeManager->getStore()->getId())->addCustomerFilter($customerId)->setDateOrder()->setPageSize(5)->load()->addReviewSummary();
     }
     return $this->_collection;
 }
开发者ID:nja78,项目名称:magento2,代码行数:16,代码来源:Recent.php

示例5: getBillingAgreements

 /**
  * Retrieve available customer billing agreements
  *
  * @return array
  */
 protected function getBillingAgreements()
 {
     $customerId = $this->currentCustomer->getCustomerId();
     $data = [];
     if (!$customerId) {
         return $data;
     }
     $collection = $this->agreementFactory->create()->getAvailableCustomerBillingAgreements($customerId);
     foreach ($collection as $item) {
         $data[] = ['id' => $item->getId(), 'referenceId' => $item->getReferenceId()];
     }
     return $data;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:BillingAgreementConfigProvider.php

示例6: getOrderHasDownloadable

 /**
  * Return true if order(s) has one or more downloadable products
  *
  * @return bool
  */
 public function getOrderHasDownloadable()
 {
     $hasDownloadableFlag = $this->_checkoutSession->getHasDownloadableProducts(true);
     if (!$this->isOrderVisible()) {
         return false;
     }
     /**
      * if use guest checkout
      */
     if (!$this->currentCustomer->getCustomerId()) {
         return false;
     }
     return $hasDownloadableFlag;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:Success.php

示例7: _construct

 /**
  * Class constructor
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $purchased = $this->_linksFactory->create()->addFieldToFilter('customer_id', $this->currentCustomer->getCustomerId())->addOrder('created_at', 'desc');
     $this->setPurchased($purchased);
     $purchasedIds = [];
     foreach ($purchased as $_item) {
         $purchasedIds[] = $_item->getId();
     }
     if (empty($purchasedIds)) {
         $purchasedIds = [null];
     }
     $purchasedItems = $this->_itemsFactory->create()->addFieldToFilter('purchased_id', ['in' => $purchasedIds])->addFieldToFilter('status', ['nin' => [Item::LINK_STATUS_PENDING_PAYMENT, Item::LINK_STATUS_PAYMENT_REVIEW]])->setOrder('item_id', 'desc');
     $this->setItems($purchasedItems);
 }
开发者ID:nja78,项目名称:magento2,代码行数:20,代码来源:ListProducts.php

示例8: _beforeToHtml

 /**
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 protected function _beforeToHtml()
 {
     $result = parent::_beforeToHtml();
     /** @var \Magento\Paypal\Model\Config $config */
     $config = $this->_paypalConfigFactory->create();
     $config->setMethod($this->_paymentMethodCode);
     $isInCatalog = $this->getIsInCatalogProduct();
     if (!$this->_shortcutValidator->validate($this->_paymentMethodCode, $isInCatalog)) {
         $this->_shouldRender = false;
         return $result;
     }
     $quote = $isInCatalog || !$this->_checkoutSession ? null : $this->_checkoutSession->getQuote();
     // set misc data
     $this->setShortcutHtmlId($this->_mathRandom->getUniqueHash('ec_shortcut_'))->setCheckoutUrl($this->getUrl($this->_startAction));
     // use static image if in catalog
     if ($isInCatalog || null === $quote) {
         $this->setImageUrl($config->getExpressCheckoutShortcutImageUrl($this->_localeResolver->getLocale()));
     } else {
         /**@todo refactor checkout model. Move getCheckoutShortcutImageUrl to helper or separate model */
         $parameters = ['params' => ['quote' => $quote, 'config' => $config]];
         $checkoutModel = $this->_checkoutFactory->create($this->_checkoutType, $parameters);
         $this->setImageUrl($checkoutModel->getCheckoutShortcutImageUrl());
     }
     // ask whether to create a billing agreement
     $customerId = $this->currentCustomer->getCustomerId();
     // potential issue for caching
     if ($this->_paypalData->shouldAskToCreateBillingAgreement($config, $customerId)) {
         $this->setConfirmationUrl($this->getUrl($this->_startAction, [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1]));
         $this->setConfirmationMessage(__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'));
     }
     return $result;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:Shortcut.php

示例9: _toHtml

 /**
  * @return string
  */
 protected function _toHtml()
 {
     if ($this->currentCustomer->getCustomerId()) {
         return parent::_toHtml();
     } else {
         return '';
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:Wishlist.php

示例10: getCompareItems

 /**
  * @return int
  */
 public function getCompareItems()
 {
     if (!$this->_compareItems) {
         $this->_compareItems = $this->_createProductCompareCollection()->setStoreId($this->_storeManager->getStore()->getId());
         $this->_compareItems->setCustomerId($this->currentCustomer->getCustomerId());
         $this->_compareItems->setCustomerId($this->_customerSession->getCustomerId());
         $this->_compareItems->addAttributeToSelect('name')->useProductItem()->load();
     }
     return $this->_compareItems;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Sidebar.php

示例11: getAllRatesByProductClassJson

 /**
  * Get all tax rates JSON for all product tax classes.
  *
  * @return string
  */
 public function getAllRatesByProductClassJson()
 {
     $result = [];
     foreach ($this->productTaxClassSource->getAllOptions() as $productTaxClass) {
         $taxClassId = $productTaxClass['value'];
         $taxRate = $this->calculationService->getDefaultCalculatedRate($taxClassId, $this->currentCustomer->getCustomerId(), $this->getStore()->getId());
         $result["value_{$taxClassId}"] = $taxRate;
     }
     return $this->jsonHelper->jsonEncode($result);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Js.php

示例12: getBillingAgreementCode

 /**
  * Return billing agreement code for method
  *
  * @param string $code
  * @return null|string
  */
 protected function getBillingAgreementCode($code)
 {
     $pre = __METHOD__ . ' : ';
     $this->_logger->debug($pre . 'bof');
     $customerId = $this->currentCustomer->getCustomerId();
     $this->config->setMethod($code);
     $this->_logger->debug($pre . 'eof');
     // always return null
     return $this->payfastHelper->shouldAskToCreateBillingAgreement($this->config, $customerId);
 }
开发者ID:PayFast,项目名称:mod-magento_2,代码行数:16,代码来源:PayfastConfigProvider.php

示例13: getCustomer

 /**
  * @return \Magento\Customer\Api\Data\CustomerInterface|null
  */
 public function getCustomer()
 {
     $customer = $this->getData('customer');
     if ($customer === null) {
         try {
             $customer = $this->customerRepository->getById($this->currentCustomer->getCustomerId());
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
             return null;
         }
         $this->setData('customer', $customer);
     }
     return $customer;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Book.php

示例14: getCustomer

 /**
  * @return \Magento\Customer\Service\V1\Data\Customer|null
  */
 public function getCustomer()
 {
     $customer = $this->getData('customer');
     if (is_null($customer)) {
         try {
             $customer = $this->_customerAccountService->getCustomer($this->currentCustomer->getCustomerId());
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
             return null;
         }
         $this->setData('customer', $customer);
     }
     return $customer;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Book.php

示例15: getJsonConfig

 /**
  * Composes configuration for js
  *
  * @return string
  */
 public function getJsonConfig()
 {
     $store = $this->getCurrentStore();
     $currentProduct = $this->getProduct();
     /**
      * @var \Magento\ConfigurableProduct\Pricing\Price\AttributePrice $attributePrice
      */
     $attributePrice = $currentProduct->getPriceInfo()->getPrice('attribute_price');
     $options = $this->helper->getOptions($currentProduct, $this->getAllowProducts());
     $attributes = $attributePrice->prepareAttributes($options);
     $config = array('attributes' => $attributes['priceOptions'], 'template' => str_replace('%s', '#{price}', $store->getCurrentCurrency()->getOutputFormat()), 'basePrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getFinalPrice())), 'oldPrice' => $this->_registerJsPrice($this->_convertPrice($currentProduct->getPrice())), 'productId' => $currentProduct->getId(), 'chooseText' => __('Choose an Option...'), 'taxConfig' => $attributePrice->getTaxConfig($this->currentCustomer->getCustomerId()), 'images' => $options['images'], 'baseImage' => $options['baseImage']);
     if ($currentProduct->hasPreconfiguredValues() && !empty($attributes['defaultValues'])) {
         $config['defaultValues'] = $attributes['defaultValues'];
     }
     $config = array_merge($config, $this->_getAdditionalConfig());
     return $this->jsonEncoder->encode($config);
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:22,代码来源:Configurable.php


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