我在自定义模块中覆盖了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();
当我在Google Chrome浏览器中打开网络时,我看到错误,但是在网页上却没有看到通知。