I override CartController in my custom module. But i have problem with notification, this is my code:
<?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?
}
}
}
if i say problem i mean, how can i show for example js message or modal dialog when $this->qty >= 2 ?
Screen from front page, i see error i network, but i don't see notification on page
You can look into how the core cart controller shows notifications:
It should be enough to use $this->errors[]
to make some error message.
$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'
);
Also look at FrontController
other similar arrays to set notifications:
/** @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();
When i open Network in Google Chrome i see error, but on webpage i don't see notification.