Jump to content

Edit History

ps8modules

ps8modules

There are several possibilities, for example in combination with JavaScript and event listening prestashop.on('updateCart ....

A header hook is added to the module and javascript is connected + messages are defined.

 

E.g.:

Module

/* install setion */
 && $this->registerHook('displayHeader');

/* function */
public function hookDisplayHeader()
{ 
	$this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/views/js/front/front.js');	
	$jsDef = [
		'custom_success_message' => $this->l('Succes'),
	];
	Media::addJsDef($jsDef);
}

 

JS

prestashop.on(
    'updateCart',
    function (event) {
        var myDiv = document.createElement('div');
        myDiv.setAttribute('id', 'myDiv');
		myDiv.setAttribute('style', 'display:block; padding:5px; color:black; background: green; font-size:1.2em; position:sticky; top:10px; right:10px; text-align:center;'); 
		myDiv.textContent = custom_success_message;
		document.getElementById('header').appendChild(myDiv);
		setTimeout(function() {
    			$('#mydiv').remove();
		}, 3000);
    }
}

 

ps8modules

ps8modules

There are several possibilities, for example in combination with JavaScript and event listening prestashop.on('updateCart ....

A header hook is added to the module and javascript is connected + messages are defined.

 

E.g.:

Module

/* install setion */
 && $this->registerHook('displayHeader');

/* function */
public function hookDisplayHeader()
{ 
	$this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/views/js/front/front.js');	
	$jsDef = [
		'custom_success_message' => $this->l('Succes'),
	];
	Media::addJsDef($jsDef);
}

 

JS

prestashop.on(
    'updateCart',
    function (event) {
        var myDiv = document.createElement('div');
        myDiv.setAttribute('id', 'myDiv');
		myDiv.setAttribute('style', 'display:block; padding:5px;, color:black; background: green; font-size:1.2em; position:sticky; top:10px; right:10px; text-align:center;'); 
		myDiv.textContent = custom_success_message;
		document.getElementById('header').appendChild(myDiv);
		setTimeout(function() {
    			$('#mydiv').remove();
		}, 3000);
    }
}

 

ps8modules

ps8modules

There are several possibilities, for example in combination with JavaScript and event listening prestashop.on('updateCart ....

A header hook is added to the module and javascript is connected + messages are defined.

 

E.g.:

Module

/* install setion */
 && $this->registerHook('displayHeader');

/* function */
public function hookDisplayHeader()
{ 
	$this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/views/js/front/front.js');	
	$jsDef = [
		'custom_success_message' => $this->l('Succes'),
	];
	Media::addJsDef($jsDef);
}

 

JS

prestashop.on(
    'updateCart',
    function (event) {
        var myDiv = document.createElement('div');
        div.setAttribute('id', 'myDiv');
		div.setAttribute('style', 'display:block; padding:5px;, color:black; background: green; font-size:1.2em; position:sticky; top:10px; right:10px; text-align:center;'); 
		div.textContent = custom_success_message;
		document.getElementById('header').appendChild(div);
		setTimeout(function() {
    			$('#mydiv').remove();
		}, 3000);
    }
}

 

×
×
  • Create New...