/** * Return back title for logged in and guest users * * @return \Magento\Framework\Phrase */ public function getBackTitle() { if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) { return __('Back to My Orders'); } return __('View Another Order'); }
/** * @return string */ protected function _toHtml() { if ($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) { return ''; } return parent::_toHtml(); }
/** * @return string */ protected function _toHtml() { if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) { return ''; } return parent::_toHtml(); }
/** * Get url for reorder action * * @param \Magento\Sales\Model\Order $order * @return string */ public function getReorderUrl($order) { if (!$this->httpContext->getValue(Context::CONTEXT_AUTH)) { return $this->getUrl('sales/guest/reorder', ['order_id' => $order->getId()]); } return $this->getUrl('sales/order/reorder', ['order_id' => $order->getId()]); }
/** * {@inheritdoc} */ protected function _toHtml() { if (!$this->_customerHelper->isRegistrationAllowed() || $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) { return ''; } return parent::_toHtml(); }
/** * {@inheritdoc} */ protected function _toHtml() { if (!$this->_registration->isAllowed() || $this->httpContext->getValue(Context::CONTEXT_AUTH)) { return ''; } return parent::_toHtml(); }
/** * Get customer group id * * @return int */ protected function getCustomerGroupId() { $customerGroupId = (int) $this->getRequest()->getParam('cid'); if ($customerGroupId == null) { $customerGroupId = $this->httpContext->getValue(Context::CONTEXT_GROUP); } return $customerGroupId; }
/** * Retrieve welcome text * * @return string */ public function getWelcome() { if (empty($this->_data['welcome'])) { if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) { $customerName = $this->_customerViewHelper->getCustomerName($this->_customerSession->getCustomerDataObject()); $this->_data['welcome'] = __('Welcome, %1!', $this->escapeHtml($customerName)); } else { $this->_data['welcome'] = $this->_scopeConfig->getValue('design/header/welcome', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); } } return $this->_data['welcome']; }
/** * Get url for reorder action * * @param \Magento\Sales\Model\Order $order * @return string */ public function getReorderUrl($order) { if (!$this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) { return $this->getUrl('sales/guest/reorder', array('order_id' => $order->getId())); } return $this->getUrl('sales/order/reorder', array('order_id' => $order->getId())); }
/** * Return back title for logged in and guest users * * @return string */ public function getBackTitle() { if ($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) { return __('Back to My Orders'); } return __('View Another Order'); }
/** * Get default value for From field * * @return string */ public function getDefaultFrom() { if ($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) { return $this->_customerSession->getCustomer()->getName(); } else { return $this->getEntity()->getBillingAddress()->getName(); } }
/** * @return bool */ public function isWishlistActive() { $isActive = $this->_getData('is_wishlist_active'); if ($isActive === null) { $isActive = $this->_scopeConfig->getValue('wishlist/general/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) && $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH); $this->setIsWishlistActive($isActive); } return $isActive; }
/** * Initialize review form * * @return void */ protected function _construct() { parent::_construct(); $this->setAllowWriteReviewFlag($this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite()); if (!$this->getAllowWriteReviewFlag()) { $queryParam = $this->urlEncoder->encode($this->getUrl('*/*/*', ['_current' => true]) . '#review-form'); $this->setLoginLink($this->getUrl('customer/account/login/', [Url::REFERER_QUERY_PARAM_NAME => $queryParam])); } $this->setTemplate('form.phtml'); }
/** * Get Key pieces for caching block content * * @return array */ public function getCacheKeyInfo() { $shortCacheId = ['CATALOG_NAVIGATION', $this->_storeManager->getStore()->getId(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(Context::CONTEXT_GROUP), 'template' => $this->getTemplate(), 'name' => $this->getNameInLayout(), $this->getCurrentCategoryKey()]; $cacheId = $shortCacheId; $shortCacheId = array_values($shortCacheId); $shortCacheId = implode('|', $shortCacheId); $shortCacheId = md5($shortCacheId); $cacheId['category_path'] = $this->getCurrentCategoryKey(); $cacheId['short_cache_id'] = $shortCacheId; return $cacheId; }
/** * Get last order ID from session, fetch it and check whether it can be viewed, printed etc * * @return void */ protected function _prepareLastOrder() { $orderId = $this->_checkoutSession->getLastOrderId(); if ($orderId) { $order = $this->_orderFactory->create()->load($orderId); if ($order->getId()) { $isVisible = !in_array($order->getStatus(), $this->_orderConfig->getInvisibleOnFrontStatuses()); $canView = $this->httpContext->getValue(Context::CONTEXT_AUTH) && $isVisible; $this->addData(['is_order_visible' => $isVisible, 'view_order_url' => $this->getUrl('sales/order/view/', ['order_id' => $orderId]), 'print_url' => $this->getUrl('sales/order/print', ['order_id' => $orderId]), 'can_print_order' => $isVisible, 'can_view_order' => $canView, 'order_id' => $order->getIncrementId()]); } } }
/** * Retrieve sender email address * * @return string */ public function getEmail() { $email = $this->getFormData()->getData('sender/email'); if (!empty($email)) { return trim($email); } /* @var $session \Magento\Customer\Model\Session */ $session = $this->_customerSession; if ($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)) { return $session->getCustomerDataObject()->getEmail(); } return ''; }
/** * Retrieve Product Compare items collection * * @return \Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection */ public function getItems() { if ($this->_items === null) { $this->_compareProduct->setAllowUsedFlat(false); $this->_items = $this->_itemCollectionFactory->create(); $this->_items->useProductItem(true)->setStoreId($this->_storeManager->getStore()->getId()); if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) { $this->_items->setCustomerId($this->currentCustomer->getCustomerId()); } elseif ($this->_customerId) { $this->_items->setCustomerId($this->_customerId); } else { $this->_items->setVisitorId($this->_customerVisitor->getId()); } $this->_items->addAttributeToSelect($this->_catalogConfig->getProductAttributes())->loadComparableAttributes()->addMinimalPrice()->addTaxPercents()->setVisibility($this->_catalogProductVisibility->getVisibleInSiteIds()); } return $this->_items; }
/** * Initialize review form * * @return void */ protected function _construct() { parent::_construct(); $data = $this->_reviewSession->getFormData(true); $data = new \Magento\Framework\Object((array) $data); // add logged in customer name as nickname if (!$data->getNickname()) { $customer = $this->_customerSession->getCustomerDataObject(); if ($customer && $customer->getId()) { $data->setNickname($customer->getFirstname()); } } $this->setAllowWriteReviewFlag($this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite()); if (!$this->getAllowWriteReviewFlag()) { $queryParam = $this->urlEncoder->encode($this->getUrl('*/*/*', ['_current' => true]) . '#review-form'); $this->setLoginLink($this->getUrl('customer/account/login/', [Url::REFERER_QUERY_PARAM_NAME => $queryParam])); } $this->setTemplate('form.phtml')->assign('data', $data); }
/** * Is logged in * * @return bool */ public function isLoggedIn() { return $this->httpContext->getValue(Context::CONTEXT_AUTH); }
/** * Checking customer login status * * @return bool */ public function customerLoggedIn() { return (bool) $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH); }
/** * Get current store currency code * * @return string */ public function getCurrentCurrencyCode() { // try to get currently set code among allowed $code = $this->_httpContext->getValue(Context::CONTEXT_CURRENCY); $code = $code === null ? $this->_getSession()->getCurrencyCode() : $code; if (empty($code)) { $code = $this->getDefaultCurrencyCode(); } if (in_array($code, $this->getAvailableCurrencyCodes(true))) { return $code; } // take first one of allowed codes $codes = array_values($this->getAvailableCurrencyCodes(true)); if (empty($codes)) { // return default code, if no codes specified at all return $this->getDefaultCurrencyCode(); } return array_shift($codes); }
/** * Get cache key informative items * * @return array */ public function getCacheKeyInfo() { return ['PAGE_FOOTER', $this->_storeManager->getStore()->getId(), (int) $this->_storeManager->getStore()->isCurrentlySecure(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(Context::CONTEXT_AUTH)]; }
public function testSetUnsetGetValue() { $this->object->setValue('key', 'value', 'default'); $this->object->unsValue('key'); $this->assertEquals('default', $this->object->getValue('key')); }
/** * Get key pieces for caching block content * * @return array */ public function getCacheKeyInfo() { $conditions = $this->getData('conditions') ? $this->getData('conditions') : $this->getData('conditions_encoded'); return ['CATALOG_PRODUCTS_LIST_WIDGET', $this->_storeManager->getStore()->getId(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP), intval($this->getRequest()->getParam(self::PAGE_VAR_NAME, 1)), $this->getProductsPerPage(), $conditions]; }
/** * Is logged in * * @return bool */ public function isLoggedIn() { return $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH); }
/** * Can view order * * @param Order $order * @return bool */ protected function canViewOrder(Order $order) { return $this->httpContext->getValue(Context::CONTEXT_AUTH) && $this->isVisible($order); }
/** * Get current customer group id * * @return int */ public function getCurrentCustomerGroupId() { return $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_GROUP); }
/** * Get Key pieces for caching block content * * @return array */ public function getCacheKeyInfo() { return ['CATALOG_PRODUCT_NEW', $this->_storeManager->getStore()->getId(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(CustomerContext::CONTEXT_GROUP), 'template' => $this->getTemplate(), $this->getProductsCount()]; }
/** * Get cache key informative items * * @return array */ public function getCacheKeyInfo() { return array('PAGE_FOOTER', $this->_storeManager->getStore()->getId(), (int) $this->_storeManager->getStore()->isCurrentlySecure(), $this->_design->getDesignTheme()->getId(), $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH)); }
/** * Render "My Orders" sidebar block * * @return string */ protected function _toHtml() { $isValid = $this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH) || $this->getCustomerId(); return $isValid ? parent::_toHtml() : ''; }