prestashop - 在前端控制器中显示 js 通知
prestashop - show js notification in front controller
我在自定义模块中覆盖了 CartController。但我对通知有疑问,这是我的代码:
<?php
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;
class CartController extends CartControllerCore
{
public $php_self = 'cart';
public function init()
{
parent::init();
$this->qty = abs(Tools::getValue('qty', 1));
var_dump(1);
if ($this->qty >= 2) {
#How can i show notification?
}
}
}
如果我说问题我的意思是,当 $this->qty >= 2 时我如何显示例如 js 消息或模态对话框?
来自首页的屏幕,我看到网络错误,但我没有在页面上看到通知
您可以查看核心购物车控制器如何显示通知:
使用$this->errors[]
来制作一些错误信息应该就足够了。
$this->errors[] = $this->trans(
'Add your message her with possible variables like this: %product% and %quantity%.',
array('%product%' => $product->name, '%quantity%' => $product->minimal_quantity),
'Shop.Notifications.Error'
);
另请参阅 FrontController
其他类似数组来设置通知:
/** @var array Controller errors */
public $errors = array();
/** @var array Controller warning notifications */
public $warning = array();
/** @var array Controller success notifications */
public $success = array();
/** @var array Controller info notifications */
public $info = array();
我在自定义模块中覆盖了 CartController。但我对通知有疑问,这是我的代码:
<?php
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;
class CartController extends CartControllerCore
{
public $php_self = 'cart';
public function init()
{
parent::init();
$this->qty = abs(Tools::getValue('qty', 1));
var_dump(1);
if ($this->qty >= 2) {
#How can i show notification?
}
}
}
如果我说问题我的意思是,当 $this->qty >= 2 时我如何显示例如 js 消息或模态对话框?
来自首页的屏幕,我看到网络错误,但我没有在页面上看到通知
您可以查看核心购物车控制器如何显示通知:
使用$this->errors[]
来制作一些错误信息应该就足够了。
$this->errors[] = $this->trans(
'Add your message her with possible variables like this: %product% and %quantity%.',
array('%product%' => $product->name, '%quantity%' => $product->minimal_quantity),
'Shop.Notifications.Error'
);
另请参阅 FrontController
其他类似数组来设置通知:
/** @var array Controller errors */
public $errors = array();
/** @var array Controller warning notifications */
public $warning = array();
/** @var array Controller success notifications */
public $success = array();
/** @var array Controller info notifications */
public $info = array();