<?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; price</title>
	<atom:link href="http://nemops.com/tag/price/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>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>Adding RRP Price to better showcase &#8220;Our Price&#8221; in Prestashop</title>
		<link>http://nemops.com/prestashop-rrp-price/</link>
		<comments>http://nemops.com/prestashop-rrp-price/#comments</comments>
		<pubDate>Tue, 21 Jan 2014 10:09:34 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[price]]></category>
		<category><![CDATA[rrp]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1813</guid>
		<description><![CDATA[<p>If you are selling products at a competitive price, you might want to showcase how much your customer can save in comparison to the normal online (or retail price). Let&#8217;s add a new price field for your products then! Version Used: Prestashop 1.5 (works on all 1.5 versions) You might be selling products at an [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-rrp-price/">Adding RRP Price to better showcase &#8220;Our Price&#8221; in Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>If you are selling products at a competitive price, you might want to showcase how much your customer can save in comparison to the normal online (or retail price). Let&#8217;s add a new price field for your products then!</p>
<p><span id="more-1813"></span></p>
<a class="download-files button style1" href="http://nemops.com/wp-content/uploads/2014/01/rrp_price.zip" title="Download Project Files">Download Project Files</a>
<ul>
<li>Version Used: <strong>Prestashop 1.5</strong> (works on all 1.5 versions)</li>
</ul>
<p>You might be selling products at an extremely competitive price. So, your customers have the right to know (and you have all the interest in showing) how much they are saving, compared to other online shops or in any case compared to the recommended retail price (rrp). </p>
<p>Once more, although Prestashop doesn&#8217;t come with such a functionality as out-of-the-box, there is a simple way to add it by using our beloved overrides. In this case:</p>
<ul>
<li>Product.php</li>
<li>prices.tpl (back office template file)</li>
<li>product.tpl (front office, to showcase the price)</li>
<li>optional: product-list.tpl (to show the price in the products list as well)</li>
<li>optional(for multiple currencies support): Product Controller</li>
<li>optional(for multiple currencies support): Category Controller</li>
</ul>
<p>If you didn&#8217;t do it already, it might be worth reading my tutorial on <a href="http://nemops.com/extending-prestashop-objects/" target="_blank" title="How to extend Prestashop Objects">How to extend Prestashop Objects</a>, before tackling this one, as we will use the same base method to extend Products.</p>
<div class="separator"></div>
<h2>Step 1 &#8211; Overriding and extending the Product Class</h2>
<h3>Database Operations</h3>
<p>As a first step, we must extend the Product Class so it accepts another field. We will call it <strong>rrp</strong> so it&#8217;s easy to understand what it is. <br />
The very first thing to do is to add the field to the database. Therefore, login to your database manager, look for the <strong>ps_product</strong> table in your web shop&#8217;s database, and add a new field as follows:</p>
<p><a href="http://nemops.com/wp-content/uploads/2014/01/phpmyadmin.png"><img src="http://nemops.com/wp-content/uploads/2014/01/phpmyadmin-680x198.png" alt="Adding the RRP price field in Pretashop&#039;s Database" width="680" height="198" class="aligncenter size-large wp-image-1817" /></a></p>
<p>Please note that this way <strong>won&#8217;t allow you to have a different RRP price if you use multistore</strong>.</p>
<h3>Adding the Override</h3>
<p>Now that the product table contains another column, we can proceed and tell the Product Object about its new property. To do it, create a new php file inside <em>override/classes</em> and call it <strong>Product.php</strong>. Open it and add the following inside php tags:</p>
<pre class="brush: php; title: ; notranslate">
class Product extends ProductCore
{
}
</pre>
<p>Then, add the $rpp property, and using the method described (once more!) in my other tutorial on <a href="http://nemops.com/extending-prestashop-objects/" title="How to extend Prestashop Objects">How to extend Prestashop Objects</a>, add the field to the Object&#8217;s definition:</p>
<pre class="brush: php; title: ; notranslate">

class Product extends ProductCore
{

    public $rrp;
 
    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
    {
        self::$definition['fields']['rrp'] = array('type' =&gt; self::TYPE_FLOAT, 'validate' =&gt; 'isCleanHtml');
        parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
    }

}

</pre>
<p>This part is finished already, so head over to <em>/cache/</em> and delete <strong>class_index.php</strong> so our new override can be seen by Prestashop.</p>
<div class="separator"></div>
<h2>Step 2 &#8211; The back office input</h2>
<p>We need, of course, a way to add the retail price to our products. No better place than the default <strong>price</strong> tab, in the product&#8217;s back office, right? Therefore, we must override the tpl which is used to generate the page. Head over to your admin folder, then <em>themes\default\template\controllers\products</em> and copy <strong>prices.tpl</strong></p>
<p>Paste it in <em>override/controllers/admin/templates/products</em>. Where to put the RRP field is entirely up to you; I chose to insert the field right above the normal price (Pre-tax retail price). In addition, as this one already reads &#8220;retail price&#8221; I will change it to &#8220;Our Price&#8221;, and let the new one as &#8220;RRP&#8221;.</p>
<p>Therefore, look for the next snippet:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
	&lt;tr&gt;
		&lt;td class=&quot;col-left&quot;&gt;
			{include file=&quot;controllers/products/multishop/checkbox.tpl&quot; field=&quot;price&quot; type=&quot;price&quot;}
			&lt;label&gt;{l s='Pre-tax retail price:'}&lt;/label&gt;
		&lt;/td&gt;
		&lt;td style=&quot;padding-bottom:5px;&quot;&gt;
			&lt;input type=&quot;hidden&quot;  id=&quot;priceTEReal&quot; name=&quot;price&quot; value=&quot;{toolsConvertPrice price=$product-&gt;price}&quot; /&gt;
			{$currency-&gt;prefix}&lt;input size=&quot;11&quot; maxlength=&quot;14&quot; id=&quot;priceTE&quot; name=&quot;price_displayed&quot; type=&quot;text&quot; value=&quot;{{toolsConvertPrice price=$product-&gt;price}|string_format:'%.2f'}&quot; onchange=&quot;noComma('priceTE'); $('#priceTEReal').val(this.value);&quot; onkeyup=&quot;$('#priceType').val('TE'); $('#priceTEReal').val(this.value.replace(/,/g, '.')); if (isArrowKey(event)) return; calcPriceTI();&quot; /&gt;{$currency-&gt;suffix}
			&lt;p class=&quot;preference_description&quot;&gt;{l s='The pre-tax retail price to sell this product'}&lt;/p&gt;
		&lt;/td&gt;
	&lt;/tr&gt;
</pre>
<p>Right before it, add</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
	&lt;tr&gt;
		&lt;td class=&quot;col-left&quot;&gt;
			{include file=&quot;controllers/products/multishop/checkbox.tpl&quot; field=&quot;price&quot; type=&quot;price&quot;}
			&lt;label&gt;{l s='Retail Price:'}&lt;/label&gt;
		&lt;/td&gt;
		&lt;td style=&quot;padding-bottom:5px;&quot;&gt;
			&lt;input type=&quot;hidden&quot;  id=&quot;priceTEReal2&quot; name=&quot;rrp&quot; value=&quot;{toolsConvertPrice price=$product-&gt;rrp}&quot; /&gt;
			{$currency-&gt;prefix}&lt;input size=&quot;11&quot; maxlength=&quot;14&quot; id=&quot;priceTE2&quot; name=&quot;price_displayed&quot; type=&quot;text&quot; value=&quot;{{toolsConvertPrice price=$product-&gt;rrp}|string_format:'%.2f'}&quot; onchange=&quot;noComma('priceTE2'); $('#priceTEReal2').val(this.value);&quot; onkeyup=&quot;$('#priceType').val('TE2'); $('#priceTEReal2').val(this.value.replace(/,/g, '.')); if (isArrowKey(event)) return; calcPriceTI();&quot; /&gt;{$currency-&gt;suffix}
			&lt;p class=&quot;preference_description&quot;&gt;{l s='Normal retail price'}&lt;/p&gt;
		&lt;/td&gt;
	&lt;/tr&gt;

</pre>
<p>And the new price field will be added as input to the back office. Just to make sure to avoid useless confusion, I personally suggest you to change the previous &#8220;Pre-tax retail price&#8221; label to &#8220;Our price&#8221; or something equally meaningful.</p>
<p><a href="http://nemops.com/wp-content/uploads/2014/01/rrp_backoffice.png"><img src="http://nemops.com/wp-content/uploads/2014/01/rrp_backoffice-680x313.png" alt="RRP price added to the Prestashop Back Office" width="680" height="313" class="aligncenter size-large wp-image-1818" /></a></p>
<p>Add your rrp and save, it should be preserverd once you are back to the page.</p>
<div class="separator"></div>
<h2>Step 3 &#8211; Showcasing the RRP Price</h2>
<p>Everything is settled, we only need to show the normal RRP price in the front office. Let&#8217;s start by amending the <strong>product.tpl</strong> file, which can be found in your current theme&#8217;s folder. Make sure you back up the file before editing it, of course! <br />
Once more, I arbitrary chose the display position, so feel free to place it wherever you like.</p>
<p>Locate:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;price&quot;&gt;
				&lt;p class=&quot;our_price_display&quot;&gt;
</pre>
<p>And right before it, add:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
{if $product-&gt;rrp|floatval}
	&lt;div class=&quot;rrp-price&quot;&gt;
	{l s='RRP:'}
	&lt;span class=&quot;rrp&quot; style=&quot;text-decoration:line-through&quot;&gt;
		{displayPrice price=$product-&gt;rrp}
	&lt;/span&gt;
	&lt;/div&gt;
{/if}
</pre>
<p><strong>Explanation:</strong> First, we make sure that the float value of the RRP price is not 0 (otherwise it means we didn&#8217;t set an RRP). Then, we simply display the value and format it as the current price settings.</p>
<p><strong>HOLD ON!</strong> How to deal with multiple currencies? If you notice, at the moment the RRP will stay the same, even if you change currency. This is a huge issue for web stores featuring multiple currencies! Let&#8217;s see how to deal with it.</p>
<h3>Dealing with multiple currencies</h3>
<p>This step is entirely optional, as you won&#8217;t need it if you run your sop in one currency only.</p>
<p>To achieve the multi-currency result, we have to add some logic at the time the RRP is retrieved. For the product page, we must override the <strong>ProductController</strong>. Therefore, create a new file named <strong>ProductController.php</strong> and add the following inside:</p>
<pre class="brush: php; title: ; notranslate">

Class ProductController extends ProductControllerCore
{

}


</pre>
<p>Then, let&#8217;s extend <strong>initContent as follows</strong></p>
<pre class="brush: php; title: ; notranslate">
	public function initContent()
	{
		
		$default_currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
		
		$this-&gt;product-&gt;rrp = Tools::convertPriceFull($this-&gt;product-&gt;rrp, $default_currency, $this-&gt;context-&gt;currency);

		parent::initContent();
		
	}
</pre>
<p><strong>Explanation</strong>: We must get the rrp in the default currency. So, assuming the price we input from the back office is in the default one, we get an instance of the shop&#8217;s default currency, then we use the <strong>Tools::convertPriceFull($amount, $from_currency, $to_currency)</strong> method to convert it to the current customer&#8217;s one. Lastly, we need, of course, to call the original initContent().</p>
<p>Delete the <strong>class_index</strong> fdile again, and refresh the page. You should see the correct RRP appear!</p>
<p><a href="http://nemops.com/wp-content/uploads/2014/01/product_page_rrp.png"><img src="http://nemops.com/wp-content/uploads/2014/01/product_page_rrp.png" alt="RRP Price in the Prestashop Product Detail Page" width="559" height="561" class="aligncenter size-full wp-image-1819" /></a></p>
<div class="separator"></div>
<h2>Adding the RRP in category pages</h2>
<p>Similarly to what we did before, let&#8217;s add the rrp to the product-list.tpl file too (once more, theme folder) and locate the following snippet:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
{if (!$PS_CATALOG_MODE AND ((isset($product.show_price) &amp;&amp; $product.show_price) || (isset($product.available_for_order) &amp;&amp; $product.available_for_order)))}
				&lt;div class=&quot;content_price&quot;&gt;
</pre>
<p>Note that I am using the default template again. Inside the content_price element, add:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
	{if $product.rrp|floatval}
		&lt;div class=&quot;rrp-price-listing&quot;&gt;
		{l s='RRP:'}
		&lt;span class=&quot;rrp&quot; style=&quot;text-decoration:line-through&quot;&gt;
			{displayPrice price=$product.rrp}
		&lt;/span&gt;
		&lt;/div&gt;
	{/if}
</pre>
<p>It&#8217;s almost identical to the one we used in the product template file, with the only difference that we are accessing the product as an array, instead of an object.</p>
<p>
	<strong>What about supporting multiple currencies here?</strong> It&#8217;s a little trickier, we need to edit the CategoryController!
</p>
<h3>Multiple currencies in the product list (Category page)</h3>
<p>So, we need another override! This time it will we a little tricker. Create a new file named <strong>CategoryController</strong> in <em>override/controllers/front</em>, and paste the usual override snippet:</p>
<pre class="brush: php; title: ; notranslate">
	public function initContent()
	{
    	parent::initContent();

	}

</pre>
<p>We are overriding the initContent() method once again.</p>
<p>Inside it, add</p>
<pre class="brush: php; title: ; notranslate">

 	$default_currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));

	if($this-&gt;cat_products)
	{
		foreach ($this-&gt;cat_products as $pk =&gt; $product) {

			$this-&gt;cat_products[$pk]['rrp'] = Tools::convertPriceFull($product['rrp'], $default_currency, $this-&gt;context-&gt;currency);
		}
	}

	$this-&gt;context-&gt;smarty-&gt;assign('products', $this-&gt;cat_products);

	

</pre>
<p><strong>Explanation:</strong> We first grab the default currency again. Then, we loop through all the category&#8217;s products (if they have been assigned!), converting the RRP price for each of them. In the end, we simply re-assign the products variable so that changes are reflected in the front office.</p>
<p>For the last time, delete the <strong>class_index</strong> file.</p>
<p><a href="http://nemops.com/wp-content/uploads/2014/01/products_list.png"><img src="http://nemops.com/wp-content/uploads/2014/01/products_list.png" alt="RRP Price in the Prestashop Products List Page" width="545" height="444" class="aligncenter size-full wp-image-1820" /></a></p>
<div class="separator"></div>
<h2>Conclusion</h2>
<p>Although we added the RRP column in the database and Product Class, further steps need to be taken in order to show the correct price in multiple currencies. Please note that the above methods <strong>do not</strong> apply to other pages and modules (best sales page, search page, home featured module); you&#8217;ll have to use other overrides, or edit core files the same way to achieve the expected results. Bummer! Hopefully, we will get a uniform method, in the future.</p>
<p>As I already stressed, this tutorial will not set a different price for each store, if you are on a multistore environment, so keep an eye on that!</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-rrp-price/">Adding RRP Price to better showcase &#8220;Our Price&#8221; in Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-rrp-price/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Display the lowest price in Prestashop product list</title>
		<link>http://nemops.com/lowest-price-prestashop-product-list/</link>
		<comments>http://nemops.com/lowest-price-prestashop-product-list/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 10:11:41 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[price]]></category>
		<category><![CDATA[products list]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1121</guid>
		<description><![CDATA[<p>If you sell products which have a lower price when bought in stocks, you might want to display the lowest possible price in your product list. Let&#8217;s see how Prestashop can be bent to this. Prestashop version: 1.5.3.1 Introduction Before trying to do anything, it&#8217;s worth knowing that you can&#8217;t achieve the rulst without an [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/lowest-price-prestashop-product-list/">Display the lowest price in Prestashop product list</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>If you sell products which have a lower price when bought in stocks, you might want to display the lowest possible price in your product list. Let&#8217;s see how Prestashop can be bent to this.</p>
<p><span id="more-1121"></span></p>
<ul>
<li>Prestashop version: 1.5.3.1</li>
</ul>
<h2>Introduction</h2>
<p>Before trying to do anything, it&#8217;s worth knowing that you can&#8217;t achieve the rulst without an ovverride. Therefore, you might want to have a look at the <a href="http://doc.prestashop.com/display/PS15/Overriding+default+behaviors" title="Prestashop Official Documentation on Overrides" target="_blank">Official Prestashop documentation on how to override default behaviors</a> before starting, if you don&#8217;t know anything about the subject. Specifically, we will override the category controller.</p>
<div class="separator"></div>
<h2>Step 1 &#8211; Retrieving quantity discounts in the CategoryController override</h2>
<p>In <em>override/controllers/front</em> open up <strong>CategoryController.php</strong>, and add the following method inside the class:</p>
<pre class="brush: php; title: ; notranslate">

	public function initContent()
	{
		parent::initContent();
		
		if($this-&gt;cat_products) {

			$id_customer = (isset($this-&gt;context-&gt;customer) ? (int)$this-&gt;context-&gt;customer-&gt;id : 0);
			$id_group = (isset($this-&gt;context-&gt;customer) ? $this-&gt;context-&gt;customer-&gt;id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_);
			$id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT');
			$id_currency = (int)$this-&gt;context-&gt;cookie-&gt;id_currency;
			$id_shop = $this-&gt;context-&gt;shop-&gt;id;



			foreach ($this-&gt;cat_products as $key =&gt; $product) {

				$prices_array = array();

				/* For each product, grab quantity discounts */
				$quantity_discounts = SpecificPrice::getQuantityDiscounts($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null, true);
				
			}
		}
	}

</pre>
<p><strong>Explanation:</strong> Lots of stuff going on here. First, we call the parent&#8217;s initContent method, so that we are sure products have already been picked from this category. Then, if there are some products (if $this->cat_products), we assign some variables we need to get an accurate specific price. Lastly, for each of our products, we call the built-in method <strong>SpecificPrice::getQuantityDiscounts</strong>, passing the current product&#8217;s ID as first parameter, along with the others we retrieved earlier. Note that I also created an empty array, which will hold all reduced prices for this product. We need to create it here, so that it&#8217;s being reset for every product!</p>
<p>At this point, if you dump the quantity discounts variable, you&#8217;ll see your discounts appear.</p>
<div class="separator"></div>
<h2>Step 2 &#8211; Processing discounts to get the real product price</h2>
<p>We can&#8217;t use those discounts as they are, as some of them may be fixed amounts, some other percentages, or another set price. Let&#8217;s crush them down to the same thing: <strong>the real price of the product with each discount applied</strong>. Add this right after getting $quantity_discounts:</p>
<pre class="brush: php; title: ; notranslate">
				/* Process quantity discounts to get the real price */

				if ($quantity_discounts)
				{
					foreach ($quantity_discounts as $qkey =&gt; $discount) {
						
						if (!(float)$discount['reduction'])
							$price = $discount['price'];
						else {
							if ($discount['reduction_type'] == 'percentage')
							{
								$price = $product['price_without_reduction'] - ($product['price_without_reduction'] * $discount['reduction']);
							}
							else {
								$price = $product['price_without_reduction'] - $discount['reduction'];							
							}
						}

						$prices_array[] = $price;

					}

				} // end if quantity discounts
</pre>
<p><strong>Explanation:</strong> If there are quantity discounts, for each of them check the reduction. If the floating number for <strong>$product[&#8216;reduction&#8217;]</strong> is 0, it means that we applied a new fixed price, otherwise we have 2 options: percentage or amount reduction. In the first case, we do some math and reduce the product price by its percentage, in the other we simply subtract the discount amount. After this, we end up having the <strong>$price</strong> variable as a floating point number for all our discounts, so that we can compare it. As the last thing, we put this in an array with all previous prices.</p>
<p>The last things wee need to do are, after the quantity discounts foreach loop, assigning the new price to the current instance of the product in the list, and tell the system this product has quantity discounts (we will see why later on):</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;cat_products[$key]['price'] = min($prices_array);
$this-&gt;cat_products[$key]['qt_disc'] = true;
</pre>
<p>And finally, after &#8220;} // end if quantity discounts&#8221;, reassign the product list with our corrected prices:</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;context-&gt;smarty-&gt;assign('products', $this-&gt;cat_products);
</pre>
<p>And this is it! You&#8217;ll now see your lowest price appearing in the list. There is a little thing left: adding &#8220;from&#8221; in the product list.</p>
<div class="separator"></div>
<h2>Step 3 &#8211; Adding &#8220;from&#8221; in the product list</h2>
<p>Navigate to your theme&#8217;s folder, and open up <strong>product-list.tpl</strong>. Find this piece of code, at about line 52 of the original version (1.5.3.1)</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
					{if isset($product.show_price) &amp;&amp; $product.show_price &amp;&amp; !isset($restricted_country_mode)}&lt;span class=&quot;price&quot; style=&quot;display: inline;&quot;&gt;{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}&lt;/span&gt;&lt;br /&gt;{/if}
</pre>
<p>Change it the following way:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
					{if isset($product.show_price) &amp;&amp; $product.show_price &amp;&amp; !isset($restricted_country_mode)}&lt;span class=&quot;price&quot; style=&quot;display: inline;&quot;&gt;{l s='From'} {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}&lt;/span&gt;&lt;br /&gt;{/if}
</pre>
<p>This way, all products will have a &#8220;from&#8221; before the price. if you want to assign the &#8220;from&#8221; word only to those products which actually have quantity discounts, you can change the previous lines the following way instead:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
					{if isset($product.show_price) &amp;&amp; $product.show_price &amp;&amp; !isset($restricted_country_mode)}
						&lt;span class=&quot;price&quot; style=&quot;display: inline;&quot;&gt;
							{if isset($product.qt_disc)}
								{l s='From'}
							{/if}
							{if !$priceDisplay}
								{convertPrice price=$product.price}
							{else}
								{convertPrice price=$product.price_tax_exc}
							{/if}
						&lt;/span&gt;&lt;br /&gt;
					{/if}
</pre>
<p>So, basically we use the previously assigned variable to check if a product has quantity discounts. If it does, show the &#8220;from&#8221; text.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/lowest-price-prestashop-product-list/">Display the lowest price in Prestashop product list</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/lowest-price-prestashop-product-list/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Display unit price (price per&#8230;) in the Prestashop product list</title>
		<link>http://nemops.com/unit-price-in-prestashop-product-list/</link>
		<comments>http://nemops.com/unit-price-in-prestashop-product-list/#comments</comments>
		<pubDate>Thu, 13 Dec 2012 14:30:42 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[price]]></category>
		<category><![CDATA[product list]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=819</guid>
		<description><![CDATA[<p>Adding unit prices (also known as &#8220;price per&#8230;&#8221;) to your Prestashop store&#8217;s product list is not as easy as it might seem. Prestashop doesn&#8217;t assign the unit price in the list; luckily, there is an easy enough workaround Version used: Prestashop 1.5.2 Running time: 5 mins Watch the screencast &#160; Text Version First of all, [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/unit-price-in-prestashop-product-list/">Quick Tip: Display unit price (price per&#8230;) in the Prestashop product list</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Adding unit prices (also known as &#8220;price per&#8230;&#8221;) to your Prestashop store&#8217;s product list is not as easy as it might seem. Prestashop doesn&#8217;t assign the unit price in the list; luckily, there is an easy enough workaround<span id="more-819"></span></p>
<ul>
<li><strong>Version used:</strong> Prestashop 1.5.2</li>
<li><strong>Running time:</strong> 5 mins</li>
</ul>
<h2>Watch the screencast</h2>
<p>
	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/CVl8rdn5Hv8" 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>&nbsp;
<div class="separator"></div>
<h2>Text Version</h2>
<p>First of all, if you don&#8217;t know exactly what unit prices are, think of a product as a flour sack, a huge one, 5 lbs. Now, the cost is displaying for the whole sack, but in Prestashop you can setup how much that thing costs <em>per</em> any measurement you choose (see picture below). In this case, you can display, for example <strong>$2 per lb</strong></p>
<p><a href="http://nemops.com/wp-content/uploads/2012/12/unity_price1.jpg"><img class="aligncenter size-full wp-image-820" title="Unit price in Prestashop product list" src="http://nemops.com/wp-content/uploads/2012/12/unity_price1.jpg" alt="Unit price in Prestashop product list" width="563" height="306" /></a></p>
<p>You might want to show this off in the product list, not only in the product page itself. The fact is, however, that Prestashop doesn&#8217;t actually assign the <strong>unit price</strong> variable in the product list page. How to deal with it? Let&#8217;s have a look: if you print out the product variable in the product list, you&#8217;ll notice an interesting property: <strong>$product.unit_price_ratio</strong></p>
<p>What is this? Basically, it gives you the unit price ratio based on the product&#8217;s total price (product price divided by unit price). That&#8217;s useful for us, since we can do some math and retrieve the value we need!</p>
<p>Inside the <strong>&#8220;foreach from=$products&#8221; loop, in the product-list.tpl</strong> file, add the following line. You can add it where you want, just be sure it&#8217;s inside the loop, before the unit price you want to print out</p>
<pre class="brush:php">	{if $product.unit_price_ratio}
		{math equation="b/a" a=$product.unit_price_ratio b=$product.price_without_reduction assign=realunit}
	{/if}</pre>
<p><strong>Explanation:</strong> First, we check that there actually is a unit price setup for this product, to prevent &#8220;division by zero&#8221; ltype errors. Then, we are dividing the product&#8217;s final price (without reduction to be more accurate) by the ratio, thus obtaining the real unit price value. If you want the taxless one, use $product.price_tax_exc as parameter b instead.</p>
<p>Let&#8217;s print out the final ratio, correctly formatted:</p>
<pre class="brush:php">	{convertPrice price=$realunit} {l s="per"} {$product.unity}</pre>
<p>We are basically formatting the variable so to get the price with currency, adding the &#8220;per&#8221; string, and, finally, the measurement. That&#8217;s it, here is the final code:</p>
<pre class="brush:php">	{if $product.unit_price_ratio}
		{math equation="b/a" a=$product.unit_price_ratio b=$product.price_without_reduction assign=realunit}
		{convertPrice price=$realunit} {l s="per"} {$product.unity}
	{/if}</pre>
<p>Of course, in order for this to show up, <strong>it has to be placed inside the main &lt;li&gt; element, if your list, like in the default theme, is an unordered list</strong>.</p>
<div class="separator"></div>
<p>&nbsp;</p>
<h3>Additional Resources</h3>
<ul>
<li><a href="http://www.smarty.net/documentation" alt="Smarty Documentation" title="Smarty Documentation">Smarty Documentation</li>
</ul>
<p>The post <a rel="nofollow" href="http://nemops.com/unit-price-in-prestashop-product-list/">Quick Tip: Display unit price (price per&#8230;) in the Prestashop product list</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/unit-price-in-prestashop-product-list/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
