本文整理汇总了PHP中Magento\Checkout\Model\Session::setContinueShoppingUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::setContinueShoppingUrl方法的具体用法?PHP Session::setContinueShoppingUrl怎么用?PHP Session::setContinueShoppingUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Checkout\Model\Session
的用法示例。
在下文中一共展示了Session::setContinueShoppingUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _goBack
/**
* Set back redirect url to response
*
* @return $this
*/
protected function _goBack()
{
$returnUrl = $this->getRequest()->getParam('return_url');
if ($returnUrl && $this->_isInternalUrl($returnUrl)) {
$this->messageManager->getMessages()->clear();
$this->getResponse()->setRedirect($returnUrl);
} elseif (!$this->_scopeConfig->getValue('checkout/cart/redirect_to_cart', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) && !$this->getRequest()->getParam('in_cart') && ($backUrl = $this->_redirect->getRefererUrl())) {
$this->getResponse()->setRedirect($backUrl);
} else {
if ($this->getRequest()->getActionName() == 'add' && !$this->getRequest()->getParam('in_cart')) {
$this->_checkoutSession->setContinueShoppingUrl($this->_redirect->getRefererUrl());
}
$this->_redirect('checkout/cart');
}
return $this;
}
示例2: getBackUrl
/**
* Get resolved back url
*
* @param null $defaultUrl
*
* @return mixed|null|string
*/
protected function getBackUrl($defaultUrl = null)
{
$returnUrl = $this->getRequest()->getParam('return_url');
if ($returnUrl && $this->_isInternalUrl($returnUrl)) {
$this->messageManager->getMessages()->clear();
return $returnUrl;
}
$shouldRedirectToCart = $this->_scopeConfig->getValue('checkout/cart/redirect_to_cart', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
if ($shouldRedirectToCart || $this->getRequest()->getParam('in_cart')) {
if ($this->getRequest()->getActionName() == 'add' && !$this->getRequest()->getParam('in_cart')) {
$this->_checkoutSession->setContinueShoppingUrl($this->_redirect->getRefererUrl());
}
return $this->_url->getUrl('checkout/cart');
}
return $defaultUrl;
}