<?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; rrp</title>
	<atom:link href="http://nemops.com/tag/rrp/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>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>
	</channel>
</rss>
