<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NemoPS &#187; javascript</title>
	<atom:link href="http://nemops.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>How to create a &#8220;Go back to the category&#8221; button in PrestaShop and thirty bees</title>
		<link>http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/</link>
		<comments>http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/#comments</comments>
		<pubDate>Mon, 09 Apr 2018 10:56:55 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[prestashop 1.6]]></category>
		<category><![CDATA[thirtybees]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=3125</guid>
		<description><![CDATA[<p>In this video we will make a handy button to let our customers navigate back to the previously visited category from the product page, in PrestaShop 1.6 and thirty bees Watch the screencast Text Version To start with, open up global.js, located in your theme folder /js. At the very end, add the following: Then, [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/">How to create a &#8220;Go back to the category&#8221; button in PrestaShop and thirty bees</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this video we will make a handy button to let our customers navigate back to the previously visited category from the product page, in PrestaShop 1.6 and thirty bees<br />
<span id="more-3125"></span></p>
<h2>Watch the screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/nOR7f_76LHE" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<h2>Text Version</h2>
<p>To start with, open up <strong>global.js</strong>, located in your theme folder <em>/js</em>. At the very end, add the following:</p>
<pre class="brush: jscript; title: ; notranslate">

$(document).ready(function() {
	if($('body').hasClass('category'))
	{
		$('.product_img_link').click(function(e) {
			$.totalStorage('last_visited_category', window.location.href);
		});
	}
});
</pre>
<p>Then, in <strong>product.tpl</strong>, again in the theme folder, find a proper spot for the button, then add the following inside a &lt;script&gt; tag:</p>
<pre class="brush: jscript; title: ; notranslate">
	$(document).ready(function() {
		if(previous_category = $.totalStorage('last_visited_category'))
		{
			$('#goback').attr('href', previous_category);
			$.totalStorage('last_visited_category', '');
		} else $('#goback').hide();
	});
</pre>
<p>Right after id, add our button:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;a href=&quot;javascript:void(0)&quot; class=&quot;btn btn-default&quot; id=&quot;goback&quot;&gt;
	&lt;i class=&quot;icon-chevron-left left&quot;&gt;&lt;/i&gt; {l s='Go Back to the last category'}
&lt;/a&gt;
</pre>
<p>Here is the final code for product.tpl</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script&gt;

	$(document).ready(function() {
		if(previous_category = $.totalStorage('last_visited_category'))
		{
			$('#goback').attr('href', previous_category);
			$.totalStorage('last_visited_category', '');
		} else $('#goback').hide();
	});
&lt;/script&gt;

&lt;a href=&quot;javascript:void(0)&quot; class=&quot;btn btn-default&quot; id=&quot;goback&quot;&gt;
	&lt;i class=&quot;icon-chevron-left left&quot;&gt;{l s='Go Back to the last category'}&lt;/i&gt;
&lt;/a&gt;

</pre>
<p><strong>Notice:</strong> If you want to keep a record of the visited category across pages, you can remove <strong>$.totalStorage(&#8216;last_visited_category&#8217;, &#8221;);</strong> from the code in product.tpl.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/">How to create a &#8220;Go back to the category&#8221; button in PrestaShop and thirty bees</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Update price on quantity change in PrestaShop 1.6</title>
		<link>http://nemops.com/update-price-on-quantity-change-in-prestashop-1-6/</link>
		<comments>http://nemops.com/update-price-on-quantity-change-in-prestashop-1-6/#comments</comments>
		<pubDate>Wed, 07 Dec 2016 11:51:50 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prestashop 1.6]]></category>
		<category><![CDATA[price]]></category>
		<category><![CDATA[products]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2924</guid>
		<description><![CDATA[<p>Let&#8217;s give our customers some more feedback when they change quantity! In this video, we will see how to change the price on the product page based on the user&#8217;s chosen quantity in PrestaShop 1.6 Watch the Screencast</p>
<p>The post <a rel="nofollow" href="http://nemops.com/update-price-on-quantity-change-in-prestashop-1-6/">Update price on quantity change in PrestaShop 1.6</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Let&#8217;s give our customers some more feedback when they change quantity! In this video, we will see how to change the price on the product page based on the user&#8217;s chosen quantity in PrestaShop 1.6<br />
<span id="more-2924"></span></p>
<h2>Watch the Screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/6znHv0zUao0" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<p>The post <a rel="nofollow" href="http://nemops.com/update-price-on-quantity-change-in-prestashop-1-6/">Update price on quantity change in PrestaShop 1.6</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/update-price-on-quantity-change-in-prestashop-1-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating a &#8220;Clear cart&#8221; button in PrestaShop</title>
		<link>http://nemops.com/clear-cart-button-prestashop/</link>
		<comments>http://nemops.com/clear-cart-button-prestashop/#comments</comments>
		<pubDate>Wed, 13 Jul 2016 13:08:49 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2824</guid>
		<description><![CDATA[<p>In this tutorial, we will see how to add a button to empty the PrestaShop Cart in one click. Adding the button to the cart page The first thing we need is, of course, a button to play with. The ideal place where to add it is shopping-cart.tpl, specifically right after the order summary table. [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/clear-cart-button-prestashop/">Creating a &#8220;Clear cart&#8221; button in PrestaShop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this tutorial, we will see how to add a button to empty the PrestaShop Cart in one click.<br />
<span id="more-2824"></span></p>
<h2>Adding the button to the cart page</h2>
<p>The first thing we need is, of course, a button to play with. The ideal place where to add it is <strong>shopping-cart.tpl</strong>, specifically right after the order summary table. Therefore, open up the file, located in the theme folder, and read the end of the table, around line 454 of the default template:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
					{/foreach}
				&lt;/tbody&gt;
			{/if}
		&lt;/table&gt;
</pre>
<p>Right after the table, let&#8217;s add a simple button:</p>
<pre class="brush: xml; title: ; notranslate">
		&lt;a class=&quot;btn btn-default pull-right&quot; id=&quot;removeAll&quot; href=&quot;javascript:void(0)&quot;&gt;
			Empty Cart
		&lt;/a&gt;
</pre>
<p>Then, we need it to do something. We could use a submit, inside a form, but modern standards require speed, and nothing beats ajax in this.<br />
Right after the button, let&#8217;s add a script tag:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script&gt;
			$(document).ready(function() {
				$('#removeAll').click(function(e) {
				});
			});
				
&lt;/script&gt;
</pre>
<p>We want to target the click event of our new button, and fire an ajax request to the cart controller:</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function() {
	$('#removeAll').click(function(e) {
		e.preventDefault()
		$.ajax({
			type: 'POST',
			headers: { &quot;cache-control&quot;: &quot;no-cache&quot; },
			url: baseUri + '?rand=' + new Date().getTime(),
			async: true,
			cache: false,
			dataType : &quot;json&quot;,
			data: 'controller=cart&amp;deleteAll=1&amp;token=' + static_token + '&amp;ajax=true',
			success: function(data){
				$('.opc-main-block, .step-num, #HOOK_SHOPPING_CART_EXTRA').fadeOut('fast');
				$('#order-detail-content').fadeOut('fast', function() {
					$('#emptyCartWarning').fadeIn('slow');	
				});
				ajaxCart.refresh();
			}
		})
	});
});
</pre>
<p><strong>Explanation:</strong> The url we call is simply the base one, plus a random value with the date, to avoid the request being cached. In terms of data, we need to pass in the controller (cart), and action (deleteAll, which doesn&#8217;t exist yet, but we will create in a second), the security token, and then ajax=true.<br />
On success, we fade out the page content, making sure any stuff from the One Page Checkout is hidden as well, and we also refresh the cart block.</p>
<p>The next step is to create something to handle the new deleteAll command.</p>
<div class="separator"></div>
<h2>Editing the CartController</h2>
<p>As always, instead of modifying the core file, make sure you use an override for this method. The function we are interested in is <strong>postProcess</strong>:</p>
<pre class="brush: php; title: ; notranslate">
    public function postProcess()
    {
        // Update the cart ONLY if $this-&gt;cookies are available, in order to avoid ghost carts created by bots
        if ($this-&gt;context-&gt;cookie-&gt;exists() &amp;&amp; !$this-&gt;errors &amp;&amp; !($this-&gt;context-&gt;customer-&gt;isLogged() &amp;&amp; !$this-&gt;isTokenValid())) {
            if (Tools::getIsset('add') || Tools::getIsset('update')) {
                $this-&gt;processChangeProductInCart();
            } elseif (Tools::getIsset('delete')) {
                $this-&gt;processDeleteProductInCart();
            } elseif (Tools::getIsset('changeAddressDelivery')) {
                $this-&gt;processChangeProductAddressDelivery();
            } elseif (Tools::getIsset('allowSeperatedPackage')) {
                $this-&gt;processAllowSeperatedPackage();
            } elseif (Tools::getIsset('duplicate')) {
                $this-&gt;processDuplicateProduct();
            }
            // Make redirection
            if (!$this-&gt;errors &amp;&amp; !$this-&gt;ajax) {
                $queryString = Tools::safeOutput(Tools::getValue('query', null));
                if ($queryString &amp;&amp; !Configuration::get('PS_CART_REDIRECT')) {
                    Tools::redirect('index.php?controller=search&amp;search='.$queryString);
                }

                // Redirect to previous page
                if (isset($_SERVER['HTTP_REFERER'])) {
                    preg_match('!http(s?)://(.*)/(.*)!', $_SERVER['HTTP_REFERER'], $regs);
                    if (isset($regs[3]) &amp;&amp; !Configuration::get('PS_CART_REDIRECT')) {
                        $url = preg_replace('/(\?)+content_only=1/', '', $_SERVER['HTTP_REFERER']);
                        Tools::redirect($url);
                    }
                }

                Tools::redirect('index.php?controller=order&amp;'.(isset($this-&gt;id_product) ? 'ipa='.$this-&gt;id_product : ''));
            }
        } elseif (!$this-&gt;isTokenValid()) {
            Tools::redirect('index.php');
        }
    }
</pre>
<p>See all those <strong>elseif</strong>s? We need another condition to target our deleteAll command. Therefore, at the end of the stack, add another:</p>
<pre class="brush: php; title: ; notranslate">
...
} elseif (Tools::getIsset('duplicate')) {
    $this-&gt;processDuplicateProduct();
} elseif (Tools::getIsset('deleteAll')) {

}
// Make redirection
if (!$this-&gt;errors &amp;&amp; !$this-&gt;ajax) {
...
</pre>
<p>Inside it, we do not need fancy stuff, only:</p>
<pre class="brush: php; title: ; notranslate">
elseif (Tools::getIsset('deleteAll')) {
                
    $this-&gt;context-&gt;cart-&gt;delete();
    $this-&gt;context-&gt;cookie-&gt;id_cart = 0;
    die(1);


}
</pre>
<p>This will clear the cart for good, and reset the id for the current user. You can also avoid resetting it, if you prefer.<br />
Save and test the button now. Make sure you clear the class_index.php file inside <em>cache/</em>, if you used an override.<br />
We are done!</p>
<p>The post <a rel="nofollow" href="http://nemops.com/clear-cart-button-prestashop/">Creating a &#8220;Clear cart&#8221; button in PrestaShop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/clear-cart-button-prestashop/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding page-specific CSS and Javascript in PrestaShop</title>
		<link>http://nemops.com/page-specific-css-javascript-prestashop/</link>
		<comments>http://nemops.com/page-specific-css-javascript-prestashop/#comments</comments>
		<pubDate>Mon, 09 Nov 2015 11:38:46 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prestashop]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2599</guid>
		<description><![CDATA[<p>PrestaShop has introduced a few useful classes with the new 1.6 template. In this quick tip, we will see what&#8217;s their pattern, and how we can use them to create specific styles for each page of our web store Watch the screencast</p>
<p>The post <a rel="nofollow" href="http://nemops.com/page-specific-css-javascript-prestashop/">Adding page-specific CSS and Javascript in PrestaShop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>PrestaShop has introduced a few useful classes with the new 1.6 template. In this quick tip, we will see what&#8217;s their pattern, and how we can use them to create specific styles for each page of our web store</p>
<p><span id="more-2599"></span></p>
<h2>Watch the screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/Sjexcn_Mh1I" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<p>The post <a rel="nofollow" href="http://nemops.com/page-specific-css-javascript-prestashop/">Adding page-specific CSS and Javascript in PrestaShop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/page-specific-css-javascript-prestashop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Essential Prestashop Functions &#8211; Day 1</title>
		<link>http://nemops.com/prestashop-functions-1/</link>
		<comments>http://nemops.com/prestashop-functions-1/#comments</comments>
		<pubDate>Tue, 21 Jul 2015 10:03:01 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prestashop]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2486</guid>
		<description><![CDATA[<p>Prestashop has lots of time-saving functions that we can use when developing modules or extensions. Let&#8217;s have a look at the first batch of Prestashop Functions, and in which context they might come in use. If you want to dive into Prestashop development, these are likely the first methods you&#8217;ll be needing. NOTICE: Values with [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-functions-1/">Essential Prestashop Functions &#8211; Day 1</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Prestashop has lots of time-saving functions that we can use when developing modules or extensions. Let&#8217;s have a look at the first batch of Prestashop Functions, and in which context they might come in use.</p>
<p><span id="more-2486"></span></p>
<p>If you want to dive into Prestashop development, these are likely the first methods you&#8217;ll be needing.</p>
<p><strong>NOTICE: Values with &#8220;=&#8221; in the declaration are optionals.</strong></p>
<h2>Managing Configuration values in Prestashop</h2>
<pre class="brush: php; title: ; notranslate">

// Updating a single/multiple value/s
Configuration::updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null);

// Getting a single value
Configuration::get($key, $id_lang = null, $id_shop_group = null, $id_shop = null)

// Getting Multiple Values
Configuration::getMultiple($keys, $id_lang = null, $id_shop_group = null, $id_shop = null)

// Getting the same key in all languages
Configuration::getInt($key, $id_shop_group = null, $id_shop = null)

// Erase the given entry
Configuration::deleteByName($key)

</pre>
<p>These methods are used to interact with the *prefix_*configuration table. It&#8217;s the quickest way to store simple data in Prestashop.</p>
<h3>Example Usage</h3>
<pre class="brush: php; title: ; notranslate">
// Saving a normal string
$my_text = 'This is some text';
Configuration::updateValue('MY_CONFIG_PARAMETER', $my_text);

// Saving an html string
$my_text = '&lt;p&gt;This is some text&lt;/p&gt;';
Configuration::updateValue('MY_CONFIG_PARAMETER', $my_text, true);

// Saving multiple values, KEYS represend ID_LANG
$my_texts = array(
	1 =&gt; 'This is some text',
	2 =&gt; 'This is some text in another language'
	);
Configuration::updateValue('MY_CONFIG_PARAMETER_MULTILANG', $my_text);


// Getting a single value
$my_text = Configuration::get('MY_CONFIG_PARAMETER');

// Getting a single value for the current language only
$my_text = Configuration::get('MY_CONFIG_PARAMETER', $this-&gt;context-&gt;language-&gt;id);

// Getting Multiple Values
$keys_to_get = array('MY_CONFIG_PARAMETER', 'OTHER_CONFIG_PARAMETER');
Configuration::getMultiple($keys_to_get);

// Delete the given key
Configuration::deleteByName('MY_CONFIG_PARAMETER');
</pre>
<div class="separator"></div>
<h2>Getting POST and GET in Prestashop</h2>
<pre class="brush: php; title: ; notranslate">
Tools::getValue($key, $default_value = false)

</pre>
<p>Retrieves the current POST or GET variable with the given key</p>
<h3>Example Usage</h3>
<pre class="brush: php; title: ; notranslate">
// Getting either POST or GET with the key 'myvalue', the second parameter is what to assign then nothing is found.
$value = Tools::getValue('myvalue', 4);
// If no 'myvalue' POST or GET variable is set, $value will be 4.
</pre>
<div class="separator"></div>
<h2>Checking for submitted data in Prestashop</h2>
<pre class="brush: php; title: ; notranslate">
Tools::isSubmit($key);
</pre>
<p>Check whether or not the given key has been submitted to the current page.</p>
<h3>Example Usage</h3>
<pre class="brush: php; title: ; notranslate">
if(Tools::isSubmit('myvalue'))
{
	// do something
}
</pre>
<div class="separator"></div>
<h2>Displaying Errors in Prestashop</h2>
<pre class="brush: php; title: ; notranslate">
Tools::displayError($string = 'Fatal error', $htmlentities = true, Context $context = null)
</pre>
<p>Displays an error with proper formatting.</p>
<h3>Example Usage</h3>
<pre class="brush: php; title: ; notranslate">
if($myvalue != 1)
{
	// will need to be displayed later on
	$error_string = Tools::displayError('It is different from 1');
}
</pre>
<div class="separator"></div>
<h2>Displaying Confirmations in Prestashop Modules</h2>
<pre class="brush: php; title: ; notranslate">
$this-&gt;displayConfirmation($string);
</pre>
<p>Displays a properly formatted confirmation message. $this refers to a module, it is therefore only available in module contexts only. Refer to the proper variable elsewhere.</p>
<pre class="brush: php; title: ; notranslate">

// this is inside a module's method
if($myvalue == 1)
{
	// will need to be displayed later on
	$conf_string = $this-&gt;displayConfirmation('Updated!');
}

</pre>
<div class="separator"></div>
<h2>Adding CSS in Prestashop</h2>
<pre class="brush: php; title: ; notranslate">
ControllerCore::addCSS($css_uri, $css_media_type = 'all', $offset = null, $check_path = true)
</pre>
<p>Appends the given CSS file/s to the page</p>
<h3>Example Usage</h3>
<pre class="brush: php; title: ; notranslate">

// this is inside a module's method
$this-&gt;context-&gt;controller-&gt;addCSS($this-&gt;_path.'css/myfile.css', 'all');

// this is inside a controller's method
$this-&gt;addCSS(_THEME_CSS_DIR_.'product.css');

// adding multiple files
$files = array(
	_THEME_CSS_DIR_.'product.css' =&gt; 'all',
	_THEME_CSS_DIR_.'other_css.css' =&gt; 'all'
);
$this-&gt;addCSS($files);

</pre>
<div class="separator"></div>
<h2>Adding Javascript in Prestashop</h2>
<pre class="brush: php; title: ; notranslate">
ControllerCore::addJS($js_uri, $check_path = true);
</pre>
<p>Appends the given JS file/s to the page</p>
<h3>Example Usage</h3>
<pre class="brush: php; title: ; notranslate">

// this is inside a module's method
$this-&gt;context-&gt;controller-&gt;addCSS($this-&gt;_path.'css/myfile.css', 'all');

// this is inside a controller's method
$this-&gt;addCSS(_THEME_CSS_DIR_.'product.css');

</pre>
<div class="separator"></div>
<h2>Adding jQuery Plugins in Prestashop</h2>
<pre class="brush: php; title: ; notranslate">
ControllerCore::addJqueryPlugin($name, $folder = null, $css = true)
</pre>
<p>Appends the given jQuery Plugin/s to the page</p>
<h3>Example Usage</h3>
<pre class="brush: php; title: ; notranslate">

// this is inside a module's method, multiple files
$this-&gt;context-&gt;controller-&gt;addjqueryPlugin('fancybox');

// this is inside a controller's method
$this-&gt;addjqueryPlugin('fancybox');

// this is inside a controller's method, multiple values
$this-&gt;addjQueryPlugin(array('scrollTo', 'alerts', 'chosen', 'autosize', 'fancybox' ));

// this is inside a controller's method, without loading the plugin's CSS
$this-&gt;addjQueryPlugin('growl', null, false);

</pre>
<div class="separator"></div>
<h2>Adding jQuery UI Components in Prestashop</h2>
<pre class="brush: php; title: ; notranslate">
ControllerCore::addJqueryUI($component, $theme = 'base', $check_dependencies = true);
</pre>
<p>Appends the given jQuery UI component/s to the page</p>
<h3>Example Usage</h3>
<pre class="brush: php; title: ; notranslate">

// this is inside a module's method, single file
$this-&gt;context-&gt;controller-&gt;addjQueryUI(ui.datepicker');

// this is inside a controller's method, multiple files
$this-&gt;addJqueryUI(array('ui.slider', 'ui.datepicker'));

</pre>
<div class="separator"></div>
<h2>Wrapping it up</h2>
<p>We saw quite a number of useful PrestaShop Functions today, which are enough to start coding your own, simple module. Apart from trying to remember them all, I suggest creating code snippets with some text expander, so you can quickly drop them in, without having to remember the exact syntax.</p>
<div class="separator"></div>
<h3>Additional Resources</h3>
<ul>
<li><a href="http://nemops.com/prestashop-functions-2/#.Vb9Bxvnzrmg" title="Essential Prestashop Functions – Day 2">Essential Prestashop Functions – Day 2</a></li>
<li><a href="http://nemops.com/prestashop-functions-3/#.Vb9EAPnzrmg" title="Essential Prestashop Functions – Day 3">Essential Prestashop Functions – Day 3</a></li>
<li><a href="http://nemops.com/prestashop-functions-4/#.Vc2cffnzrmg" title="Essential Prestashop Functions – Day 4">Essential Prestashop Functions – Day 4</a></li>
<li><a href="http://nemops.com/prestashop-functions-5/#.Ve6fNxHzrmg" title="Essential Prestashop Functions – Day 5">Essential Prestashop Functions – Day 5</a></li>
</ul>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-functions-1/">Essential Prestashop Functions &#8211; Day 1</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-functions-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A better &#8220;Add to Cart&#8221; animation for Prestashop (Updated)</title>
		<link>http://nemops.com/better-prestashop-add-to-cart/</link>
		<comments>http://nemops.com/better-prestashop-add-to-cart/#comments</comments>
		<pubDate>Wed, 07 Aug 2013 08:00:04 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[add to cart]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prestashop]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1093</guid>
		<description><![CDATA[<p>Let&#8217;s face it: Prestashop&#8217;s default &#8220;Add to cart&#8221; animation sucks a bit. In this tutorial, I&#8217;ll show you how to change it to something more appealing and useful. Introduction In this short tutorial we will add a fancy popup box that notifies the customer when a product is adedd to the cart. Something similar to [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/better-prestashop-add-to-cart/">A better &#8220;Add to Cart&#8221; animation for Prestashop (Updated)</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Let&#8217;s face it: Prestashop&#8217;s default &#8220;Add to cart&#8221; animation sucks a bit. In this tutorial, I&#8217;ll show you how to change it to something more appealing and useful.</p>
<p><span id="more-1093"></span></p>
<h2>Introduction</h2>
<p>In this short tutorial we will add a fancy popup box that notifies the customer when a product is adedd to the cart. Something similar to the one I have in my  <a href="http://store.nemops.com">Prestashop Addons store</a>.<br/><br />
First of all,  the shop must be configured to use ajax animation. This option is activated by default, but in case you disabled it, be sure it&#8217;s turned on by going to the back office, <strong>Modules -> Cart Block </strong> in Front office features, and set Ajax Cart to on.</p>
<div class="separator"></div>
<h2>Step 1 &#8211; Introduction to the Add to cart animation</h2>
<p>Now that we&#8217;re sure ajax is on, let&#8217;s go to our root Prestashop folder, then <em>modules/blockcart</em>. The file where the evil code is stored is <strong>ajax-cart.js</strong>. As always, it&#8217;s not good practice to edit core files directly, as any update can destroy our changes, therefore copy  <strong>ajax-cart.js</strong> in your theme&#8217;s folder, then <em>js/modules/blockcart/</em>. Create any necessary folder, of course. The structure is pretty much redundant, but needed by the system. We can now start editing our file.</p>
<p>What we&#8217;re interested in is the <strong>add</strong> function of th cart object. It&#8217;s located at about line 176. What we really want to mess with, anyway, is the actual animation, not the whole Add to Cart process. Therefore, we will be editing this piece of code only, from line 208 to 232:</p>
<pre class="brush: jscript; title: ; notranslate">

	// 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();

	if ($picture.size())
		$picture.css({'position': 'absolute', 'top': pictureOffsetOriginal.top, 'left': pictureOffsetOriginal.left});

	var pictureOffset = $picture.offset();
	if ($('#cart_block').offset().top &amp;&amp; $('#cart_block').offset().left)
		var cartBlockOffset = $('#cart_block').offset();
	else
		var cartBlockOffset = $('#shopping_cart').offset();

	// Check if the block cart is activated for the animation
	if (cartBlockOffset != undefined &amp;&amp; $picture.size())
	{
		$picture.appendTo('body');
		$picture.css({ 'position': 'absolute', 'top': $picture.css('top'), 'left': $picture.css('left'), 'z-index': 4242 })
		.animate({ 'width': $element.attr('width')*0.66, 'height': $element.attr('height')*0.66, 'opacity': 0.2, 'top': cartBlockOffset.top + 30, 'left': cartBlockOffset.left + 15 }, 1000)
		.fadeOut(100, function() {
			ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
		});
	}
	else

</pre>
<p>We don&#8217;t want all this junk: get rid of everything, so that the ajax call&#8217;s success function looks like this:</p>
<pre class="brush: jscript; title: ; notranslate">

success: function(jsonData,textStatus,jqXHR)
	{
		// add appliance to whishlist module
		if (whishlist &amp;&amp; !jsonData.errors)
			WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]);
		ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
	},

</pre>
<p>If you now refresh the page, you&#8217;ll notice the product is being added to the cart without animation. Already feels better!</p>
<div class="separator"></div>
<h2>Step 2 &#8211; Adding the floating box</h2>
<p>Let&#8217;s add some valuable information to let our customers know they just added a product to the cart. We will first create the box with javascript, and in a second stage move some styling to the css file. Add the following just before <strong>ajaxCart.updateCartInformation(jsonData, addedFromProductPage);</strong>:</p>
<p><strong>EDIT:</strong> There was a small mistake here, <strong>Marius</strong> pointed out in the comments: all of the following code MUST be enclosed within</p>
<pre class="brush: jscript; title: ; notranslate">
if(!jsonData.errors)
{
}
</pre>
<p>Otherwise, the box will trigger even if customers add quantities exceeding products&#8217; stocks! Thanks Marius!</p>
<pre class="brush: jscript; title: ; notranslate">

				/* Creating the dark overlay */

				var overlay = $('&lt;div&gt;&lt;/div&gt;')
								.addClass('dark-overlay')
								.css({
									position: 'fixed',
									backgroundColor: 'black',
									'z-index': 99,
									display: 'none',
									opacity: .5,
									width: '100%',
									height: '100%',
									left: 0,
									top: 0
								});

				overlay.appendTo($('body')).fadeIn();

</pre>
<p><strong>Explanation: </strong> basically, every time we now click on add to cart, a dark overlay will fade in the screen, preparing the field to give our popup more prominence. We also need to take it away once we are done though! Let&#8217;s add the following code after the previous one:</p>
<pre class="brush: jscript; title: ; notranslate">
				$('.dark-overlay').click(function(){
					$(this).fadeOut(function(){
						$(this).remove()
					});
				})



</pre>
<p>And we can now toggle the dark overlay by clicking on it. Finally, let&#8217;s create our floating box:</p>
<pre class="brush: jscript; title: ; notranslate">


				/* Creating the floating box */

				var floating_box = $('&lt;div&gt;&lt;/div&gt;')
									.addClass('add-to-cart-popup')
									.css({
										position: 'fixed',
										left: '50%',
										top: '30%',
										display: 'none',
										width: '450px',
										height: '160px',
										'margin-left': '-225px',
										backgroundColor : 'white',
										'z-index' : 100
									})

				floating_box.appendTo($('body')).fadeIn();

</pre>
<p><strong>Explanation:</strong> We basically do what we did for the overlay, but with one difference: we want this box to have specific dimensions, and to be centered. To achieve this, we&#8217;ve got to add <strong>half on the width</strong> of the box as a negative left margin, while keeping the left positioning at 50%. This way, the box will be perfectly centered.</p>
<div class="separator"></div>
<h2>Step 3 &#8211; Populating the box</h2>
<p>We have our not-so-informative box; it&#8217;s now time to make it useful. We&#8217;ve got a problem though! If we write our informative text inside the javascript file itself, it won&#8217;t be multilanguage by any mean. This is okay for single-language stores, but for all the others it will cause big troubles. How to deal with it? We will use a trick: we will add the translatable variables inside our template.</p>
<p>In your theme folder, navigate to <em>modules/blockcart/blockcart.tpl</em> and open it. If you can&#8217;t find that, because it&#8217;s not present, copy in this very same location the original one that you find in the module&#8217;s folder. At about line 35, there should be a javascript block with the following content:</p>
<pre class="brush: jscript; title: ; notranslate">

&lt;script type=&quot;text/javascript&quot;&gt;
var customizationIdMessage = '{l s='Customization #' mod='blockcart' js=1}';
var removingLinkText = '{l s='remove this product from my cart' mod='blockcart' js=1}';
var freeShippingTranslation = '{l s='Free shipping!' mod='blockcart' js=1}';
var freeProductTranslation = '{l s='Free!' mod='blockcart' js=1}';
var delete_txt = '{l s='Delete' mod='blockcart' js=1}';
&lt;/script&gt;

</pre>
<p>At the end of this, so right after delete_txt, add the following variables:</p>
<pre class="brush: jscript; title: ; notranslate">

var added_txt = '{l s='Product added to the cart' mod='blockcart' js=1}';
var checkout_txt = '{l s='Proceed to checkout' mod='blockcart' js=1}';
var continue_txt = '{l s='Continue shopping' mod='blockcart' js=1}';

</pre>
<p>Now we can reference these in the javascript file. Basically, we assigned to those variables texts that change when the language changes, thus offering us a nice way to implement multiple languages in our box. Let&#8217;s deal with the actual box content. Go back to <strong>ajax.cart.js</strong> and add the following at the end of our last modifications, but <strong>before appending the floating box to the body</strong>:</p>
<pre class="brush: jscript; title: ; notranslate">
				/* getting the checkout link */

				var checkout_link = $('#button_order_cart').attr('href');

				/* Populating the box */

				floating_box.append('&lt;p&gt;'+ added_txt+'&lt;/p&gt;');
				floating_box.append('&lt;a href=&quot;'+checkout_link+'&quot; class=&quot;exclusive&quot;&gt;'+ checkout_txt+'&lt;/a&gt;');
				floating_box.append('&lt;a class=&quot;close-popup button&quot;&gt;'+ continue_txt+'&lt;/a&gt;');



</pre>
<p>Then, after appending it</p>
<pre class="brush: jscript; title: ; notranslate">

				$('.close-popup').click(function(){
					$(this).parent().fadeOut(function(){
						$(this).remove()
					});
					$('.dark-overlay').fadeOut(function(){
						$(this).remove()
					});
				})	
</pre>
<p><strong>Explanation:</strong> First of all, we need to know where to direct users once they want to procees to the checkout. Instead of creating a new link, we can make use of the existing one in the cart. Therefore, we first assign that link to a variable (<strong>checkout_link</strong>).<br />
Then, in this order, we append the text that informs an item has been added to the cart, the checkout link, and the link to continue shopping. This last one needs to close the current dialog, therefore, in the end we register its clicks: we remove both the dialog and the overlay.
</p>
<p>As a last step in the javascript file, we need to amend the previous overlay click to be sure we also remove the new dialog:</p>
<pre class="brush: jscript; title: ; notranslate">
				$('.dark-overlay').click(function(){
					$(this).fadeOut(function(){
						$(this).remove()
					});
					$('.add-to-cart-popup').fadeOut(function(){
						$(this).remove()
					});					
				})

</pre>
<p>And we are basically done with javascript. Test it out, you&#8217;ll notice it behaves as it should&#8230;but it looks ugly. In the next step, we will style it nicely to make it a bit more appealing.</p>
<div class="separator"></div>
<h2>Step 4 &#8211; Styling our new Add to cart dialog</h2>
<p>First of all, since we added classes to our overlay and floating box, we can get rid of those javascript styling. We will override blockcart.css, therefore go to your module&#8217;s folder, <em>blockcart/</em> and copy <strong>blockcart.css</strong>. reach your theme&#8217;s folder, then create this folder structure, if not present: <em>css/modules/blockcart/</em>. If that blockcart folder is already there, the stylesheet is likely to be found inside, and you can add to that directly. If not, paste in the one we just copied, and open it up in a code editor.</p>
<p>At the very end of the file, add the following:</p>
<pre class="brush: css; title: ; notranslate">
/* Floating box modification */

.dark-overlay {
	position: fixed;
	background-color: black;
	z-index: 99;
	display: none;
	opacity: .5;
	width: 100%;
	height: 100%;
	left: 0;
	top: 0;
}

.add-to-cart-popup {
	position: fixed;
	left: 50%;
	top: 30%;
	display: none;
	width: 450px;
	height: 160px;
	margin-left: -225px;
	background-color : white;
	z-index : 100;
}
</pre>
<p>It&#8217;s just a copy/paste of those rules we previously applied. We can now remove them from the javascript, so that our previous objects now look like this:</p>
<pre class="brush: jscript; title: ; notranslate">
/* this the overlay*/
	var overlay = $('&lt;div&gt;').addClass('dark-overlay');
/* And the box */
	var floating_box = $('&lt;div&gt;').addClass('add-to-cart-popup')
</pre>
<p>Refresh and check that it behaves as before.</p>
<p>Let&#8217;s now add a bit of spice to the box, by adding some other lines of css inside the popup&#8217;s class:</p>
<pre class="brush: css; title: ; notranslate">
.add-to-cart-popup {
	position: fixed;
	left: 50%;
	top: 30%;
	display: none;
	width: 450px;
	height: 160px;
	margin-left: -225px;
	background-color : white;
	z-index : 100;
	border: 1px solid #f0f0f0;
	box-shadow:         0px 0px 10px rgba(50, 50, 50, 0.75);
	border-radius: 5px;
}

</pre>
<p>So, we&#8217;ve got some nice shadow and rounded corners, let&#8217;s space out those buttons, and give them some difference (we don&#8217;t want them to be the same, but rather the checkout one to be more prominent):</p>
<pre class="brush: css; title: ; notranslate">

.add-to-cart-popup p {
	font-weight: bold;
	font-size: 18px;
	width: 100%;
	padding-top: 30px;
	text-align: center;
}

.add-to-cart-popup .exclusive {
	margin-left: 80px;
	margin-top: 20px;
}

.add-to-cart-popup .button {
	margin-left: 40px;
	color: #ccc;
	border: 1px solid black;
	background-image: -ms-linear-gradient(top, #404040 0%, #272727 100%);
	background-image: -moz-linear-gradient(top, #404040 0%, #272727 100%);
	background-image: -o-linear-gradient(top, #404040 0%, #272727 100%);
	background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #404040), color-stop(1, #272727));
	background-image: -webkit-linear-gradient(top, #404040 0%, #272727 100%);
	background-image: linear-gradient(to bottom, #404040 0%, #272727 100%);	

}

.add-to-cart-popup .button:hover {
	background:#272727;
}
</pre>
<p>And there it is! Of course, it can be even prettier, but this gives it a nice neutral style that can be further enhanced, and adapted to your needs. here is the final result:</p>
<div id="attachment_1101" style="width: 690px" class="wp-caption aligncenter"><a href="http://nemops.com/wp-content/uploads/2013/03/final_result.png"><img src="http://nemops.com/wp-content/uploads/2013/03/final_result-680x414.png" alt="Our new &quot;add to cart&quot; animation for Prestashop" width="680" height="414" class="size-large wp-image-1101" /></a><p class="wp-caption-text">Our new &#8220;add to cart&#8221; animation for Prestashop</p></div>
<p>The post <a rel="nofollow" href="http://nemops.com/better-prestashop-add-to-cart/">A better &#8220;Add to Cart&#8221; animation for Prestashop (Updated)</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/better-prestashop-add-to-cart/feed/</wfw:commentRss>
		<slash:comments>73</slash:comments>
		</item>
		<item>
		<title>Quick Tip: display product images in the Prestashop Ajax Cart</title>
		<link>http://nemops.com/quick-tip-product-images-prestashop-ajax-cart/</link>
		<comments>http://nemops.com/quick-tip-product-images-prestashop-ajax-cart/#comments</comments>
		<pubDate>Mon, 06 May 2013 09:36:24 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[products]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1255</guid>
		<description><![CDATA[<p>Adding product images in the default Prestashop Ajax cart can be tricker than expected, especially if you want to display them on the fly, without a page refresh. Let&#8217;s see how to do it properly in this quick tip! Introduction: the 3 files we need to edit You might think that it can be simple [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/quick-tip-product-images-prestashop-ajax-cart/">Quick Tip: display product images in the Prestashop Ajax Cart</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Adding product images in the default Prestashop Ajax cart can be tricker than expected, especially if you want to display them on the fly, without a page refresh. Let&#8217;s see how to do it properly in this quick tip!</p>
<p><span id="more-1255"></span></p>
<h2>Introduction: the 3 files we need to edit</h2>
<p>You might think that it can be simple enough to add a small thumb for each product in the ajax cart. Opening the tpl file, adding the same code you find in the product list. Done.<br />
Not exactly. As with many other things, Prestashop badly mixes up javascript and html in the cart too, and creates a hybrid to be served on the fly, right after the product is added to the cart, but before a page refresh. The mentioned process might work if you reload the page after adding the product, but otherwise no picture will be shown. We need to edit more than the cart template file. Specifically, 3 files: <strong>blockcart.tpl</strong>, <strong>blockcart-json.tpl</strong> and <strong>ajax-cart.js</strong>.</p>
<p>Before starting, it is vital to avoid any direct modification, so create a folder named <em>blockcart</em> in your theme&#8217;s folder, <em>/modules</em>. Copy blockcart.tpl, and the json counterpart inside it. Lastly, inside the theme folder <em>/js</em>, create another <strong>blockcart</strong> folder, but this time paste <strong>ajax-cart.tpl</strong> inside.</p>
<p><strong>NOTE:</strong> If those files are already in place, use those, instead of overwriting.</p>
<div class="separator"></div>
<h2>The basic markup</h2>
<p>Open up <strong>blockcart.tpl</strong>. It has a really sad structure to deal with, as each product is not entirely separated from the next, if it has attributes. Therefore, I won&#8217;t focus on specific styling, but rather on the overall process. Look for the following block of code: </p>
<pre class="brush: php; html-script: true; title: ; notranslate">

&lt;span class=&quot;quantity-formated&quot;&gt;&lt;span class=&quot;quantity&quot;&gt;{$product.cart_quantity}&lt;/span&gt;x&lt;/span&gt;

</pre>
<p>We want to insert our image <strong>right before</strong> this tag. So, before it, add the following:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">

&lt;span style=&quot;display: inline-block; float:left&quot;&gt;&lt;img src=&quot;{$link-&gt;getImageLink($product.legend, $product.id_image, 'small_default')}&quot; alt=&quot;&quot;&gt;&lt;/span&gt;

</pre>
<p>Note that I&#8217;m using inline css to float the image block. I am also assigning an inline-block property to it, so that you can further style it with dimensions at your discretion.</p>
<p>At this point, if you have products in the cart, and refresh the page, the picture will display. However, the float will make it&#8230; float &#8211; outside of the container. It&#8217;s contained inside a <strong>dt</strong>, and the line right above the one we just added should look like:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">

&lt;dt id=&quot;cart_block_product_{$product.id_product}_{if $product.id_product_attribute}{$product.id_product_attribute}{else}0{/if}_{if $product.id_address_delivery}{$product.id_address_delivery}{else}0{/if}&quot; class=&quot;{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}&quot;&gt;

</pre>
<p>Messy. We need this to clear every float, therefore let&#8217;s add a clearfix class to it: </p>
<pre class="brush: php; html-script: true; title: ; notranslate">

&lt;dt id=&quot;cart_block_product_{$product.id_product}_{if $product.id_product_attribute}{$product.id_product_attribute}{else}0{/if}_{if $product.id_address_delivery}{$product.id_address_delivery}{else}0{/if}&quot; class=&quot;clearfix {if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}&quot;&gt;

</pre>
<div class="separator"></div>
<h2>The tricky part</h2>
<p>You might be happy with this, but most people would like to display pictures as soon as the user adds products to the cart. To do this in the javascript file, we first need the link variable assigned to the json retrieved in the ajax call, as there is no <strong>getImageLink</strong> function in Prestashop&#8217;s Javascript. Open up <strong>blockcart-json.tpl</strong> and locate the following:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">

		&quot;price_float&quot;:   &quot;{$product.total}&quot;,
</pre>
<p>Right after it, add:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
	&quot;imageLink&quot;:   &quot;{$link-&gt;getImageLink($product.link_rewrite, $product.id_image, 'small_default')}&quot;,
</pre>
<p>This way, we can access the image link from inside the ajax call in the ajax-cart.js file. Open it up, and locate the following (there might be multiple instances of it, this should be about line 445 in Prestashop 1.5.4.1).</p>
<pre class="brush: jscript; title: ; notranslate">
	content += '&lt;span class=&quot;quantity-formated&quot;&gt;&lt;span class=&quot;quantity&quot;&gt;' + this.quantity + '&lt;/span&gt;x&lt;/span&gt;';
</pre>
<p>Right before it, add:</p>
<pre class="brush: jscript; title: ; notranslate">
	content += '&lt;span style=&quot;display: inline-block; float:left&quot;&gt;&lt;img src=&quot;'+this.imageLink+'&quot; alt=&quot;&quot;&gt;&lt;/span&gt;';
</pre>
<p>Again, we need to clear the floats in the previous line, turning this</p>
<pre class="brush: jscript; title: ; notranslate">
	var content =  '&lt;dt class=&quot;hidden&quot; id=&quot;cart_block_product_' + domIdProduct + '&quot;&gt;';
</pre>
<p>Into this</p>
<pre class="brush: jscript; title: ; notranslate">
	var content =  '&lt;dt class=&quot;clearfix hidden&quot; id=&quot;cart_block_product_' + domIdProduct + '&quot;&gt;';
</pre>
<p>Save, remove all products from the cart and refresh the page. Now add a product, it should immediatly display its cover!</p>
<p>The post <a rel="nofollow" href="http://nemops.com/quick-tip-product-images-prestashop-ajax-cart/">Quick Tip: display product images in the Prestashop Ajax Cart</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/quick-tip-product-images-prestashop-ajax-cart/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>
