"Product added to cart" notification bar in PrestaShop

Today i want to show you how to create notification bar which will appear right after successfully "add to cart" action in your store based on PrestaShop engine. I use the same effect here, ony MyPresta.eu website, you can test it now - just add product to cart, you will see it at the bottom of website.


Product sucessfully added to cart notification bar

prestashop notification bar



How to create notification bar

Read this guide carefully, you have to follow all steps described below. What we will do? We will modify 3 files: header.tpl (your theme file), ajax-cart.js file (a part of blockcart module) and your store global stylesheet file (global.css).  So, we can start, let's go ;)


1. header.tpl file modification

In this step we have to define "Product successfully added to cart" message. We must give possibility to translate this message due to the fact, that today many of stores uses many languages. In this case in header.tpl file located in your theme directory add this simple code:

var addtocartconfirmation = '{l s='Product successfully added to cart'}';

to the script with javascript variables definition, like i show below:

		<script type="text/javascript">
			var baseDir = '{$content_dir|addslashes}';
			var baseUri = '{$base_uri|addslashes}';
			var static_token = '{$static_token|addslashes}';
			var token = '{$token|addslashes}';
			var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals};
			var priceDisplayMethod = {$priceDisplay};
			var roundMode = {$roundMode};
                        var addtocartconfirmation = '{l s='Product successfully added to cart'}';

We defined javascript variable which contains string "Product sucessfully added to cart". If you want to translate it to other languages, just go to localization > translations > front office translations section in your back office, and just translate it.


2. ajax-cart.js file modification

Now it's time to add javascript action to display this message right after someone add product to cart. In this case, we must edit the ajax-cart.js file located in your blockcart module directory. The path to file looks like: /modules/blockcart/ajax-cart.js but in some cases this file is overrided by theme, in this case you must open /themes/your_theme/modules/blockcart/ajax-cart.js instead of original one.


by default, near the 208 line, there is a code with "add to cart" action, right after 

success: function(jsonData,textStatus,jqXHR){

add this code:

$("body").append("<div class='addtocartconfirmation'><span>"+addtocartconfirmation+"</span></div>"); $(".addtocartconfirmation").fadeOut(8000);

so full code of add function should looks like (i highlighted line with new code)

	// add a product in the cart via ajax
	add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, wishlist){
		if (addedFromProductPage && !checkCustomizations())
			return ;
		//disabled the button when adding to not double add if user double click
		if (addedFromProductPage)
			$('#add_to_cart input').attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
			$(callerElement).attr('disabled', true);

		if ($('#cart_block_list').hasClass('collapsed'))
		//send the ajax request to the server
			type: 'POST',
			headers: { "cache-control": "no-cache" },
			url: baseUri + '?rand=' + new Date().getTime(),
			async: true,
			cache: false,
			dataType : "json",
			data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
			success: function(jsonData,textStatus,jqXHR)
			     $("body").append("<div class='addtocartconfirmation'><span>"+addtocartconfirmation+"</span></div>"); $(".addtocartconfirmation").fadeOut(8000); 
				// add appliance to wishlist module
				if (wishlist && !jsonData.errors)
					WishlistAddProductCart(wishlist[0], idProduct, idCombination, wishlist[1]);

				// add the picture to the cart
				var $element = $(callerElement).parent().parent().find('a.product_image img,a.product_img_link img');
				if (!$element.length)
					$element = $('#bigpic');
				var $picture = $element.clone();
				var pictureOffsetOriginal = $element.offset();
				pictureOffsetOriginal.right = $(window).innerWidth() - pictureOffsetOriginal.left - $element.width();

				if ($picture.length)
						position: 'absolute',
						top: pictureOffsetOriginal.top,
						right: pictureOffsetOriginal.right

				var pictureOffset = $picture.offset();
				var cartBlock = $('#cart_block');
				if (!$('#cart_block')[0] || !$('#cart_block').offset().top || !$('#cart_block').offset().left)
					cartBlock = $('#shopping_cart');
				var cartBlockOffset = cartBlock.offset();
				cartBlockOffset.right = $(window).innerWidth() - cartBlockOffset.left - cartBlock.width();

				// Check if the block cart is activated for the animation
				if (cartBlockOffset != undefined && $picture.length)
							position: 'absolute',
							top: pictureOffsetOriginal.top,
							right: pictureOffsetOriginal.right,
							zIndex: 4242
							width: $element.attr('width')*0.66,
							height: $element.attr('height')*0.66,
							opacity: 0.2,
							top: cartBlockOffset.top + 30,
							right: cartBlockOffset.right + 15
						}, 1000)
						.fadeOut(100, function() {
							ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
					ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
			error: function(XMLHttpRequest, textStatus, errorThrown)
				alert("Impossible to add the product to the cart.\n\ntextStatus: '" + textStatus + "'\nerrorThrown: '" + errorThrown + "'\nresponseText:\n" + XMLHttpRequest.responseText);
				//reactive the button when adding has finished
				if (addedFromProductPage)
					$('#add_to_cart input').removeAttr('disabled').addClass('exclusive').removeClass('exclusive_disabled');


3. global.css styles

Now it's time to define CSS styles for our new block addtocartconfirmation (block with our confirmation message). We must add styles to global stylesheet file. By default it's a global.css file located in your theme directory /themes/your_theme/css/global.css. Add there these styles:

.addtocartconfirmation {
    background: #D34F2B; 
    padding:10px 0px; 

.addtocartconfirmation span {
    text-shadow:1px 1px 0px #000;


Of course you can use own colors for this notification bar. You can customize it exactly as you want to fit your theme colors. Just change params above. Final effect:


author milos myszczuk
Article by Milosz Myszczuk PrestaShop expert, official PrestaShop community moderator. PHP developer, specialist in relative and spatial databases management, GIS Analyst, CEO & founder of VEKIA interactive agency. Read more about VEKIA company
If you like my articles and want much more valuable tips, feel free to send me donation
1.4 version 1.4.11 1.6 404 addon admin advertise ahref ajax alpha animation api app application authentication back office backup badge banner basics block bootstrap button cache carrier cart catalog category certificate changelog chat class clear client clip cms code colors columns comments configuration contact container content controller cookie counter country coupon css csv currency customer dashboard database debug default delete delivery desktop developer device disable discount displayNav displayTop download dynamic editor effect empty encrypt engine error exchange exclude export facebook faceshop fade fancoupon fancybox fanpage fatal feature feed field file fix fixed font footer free friendly url front ftp full gallery generate gift global godaddy google google+ gray grid groupon header help hide highlight homefeatured homepage hook hosting hover howto htaccess html html5 ID image import include input instagram installation integration iPhone issue javascript jquery kgb knowhow languages law left likebox link list livingsocial loading log login logo loyality mail mailing maintenance manufacturer marketing marquee mcrypt menu meta mobile modification module movie moving multilanguage multiupload must have mysql news newsletter notification number open graph order override page password performance PHP phpmyadmin picture pinterest plugin popup post prestashop prestashop 1.0 prestashop 1.1 prestashop 1.2 prestashop 1.3 prestashop 1.4 prestashop 1.5 price rules problem product profile promotion proslider purifier quantity query quick tip random rates register reinsurance release reporting reset responsive restore results ribbon rich text right sales search security seo service shadow share shipping shop shopmania slider smarty social networks SQL SSL statistics stock store style subcategory superuser support switcher tab tablet tag tax template text theme tinyMCE tips and tricks tpl tracking translations tree trends trigger tumblr tutorial twitter update upgrade upload variables video visits voucher vulnerability web2print wide widget width window wishlist wysiwyg youtube zip zopim