whitehumorous Posted May 31, 2013 Share Posted May 31, 2013 HI, Current prestashop dose not have any option to choose whether to display the reduction price in percentage or amount. Eg, old price is USD 47, i want it to be discounted to USD 42, but in don't want FO display as "you save USD 5", i want it to be displayed as "you save 11%". I know it can be done by choosing reduction type as amount, but i dont want to calculate the reduction percentage manually everytime. Thanks. Link to comment Share on other sites More sharing options...
NemoPS Posted May 31, 2013 Share Posted May 31, 2013 Hi, I'm a bit confused. I don't get the point actually, wouldn't it be easier to simply use reduction type percentage? Otherwise, you can edit the product.tpl file and do a bit of math if the discount is set to amount, you calculate the what percentage of the total this amt represents. But again, why not using percentage discount directly? Link to comment Share on other sites More sharing options...
whitehumorous Posted May 31, 2013 Author Share Posted May 31, 2013 Hi Nemo, My purpose of doing this is to impress customer that the product reduction is really big. eg. old price is USD 20, reduction is USD 5., convert to percentage will be 25%..and i think percentage is easier to catch customer's attention. I tried to modify in theme's product.tpl file as below and have the partial success. original <span id="reduction_amount_display">{if $product->specificPrice AND $product->specificPrice.reduction_type == 'amount' && $product->specificPrice.reduction|intval != 0}-{convertPrice price=$productPriceWithoutReduction-$productPrice|floatval}{/if}</span> change to <span id="reduction_amount_display">{if $product->specificPrice AND $product->specificPrice.reduction_type == 'amount' && $product->specificPrice.reduction|intval != 0}-{(($productPriceWithoutReduction-$productPrice)/$productPriceWithoutReduction)|string_format:"%.0f"}{/if}</span> However i notice a problem, this changes will only take effect to the products which do not have combination assigned. Those with combination will remain unchanged. Do i need to modify other .tpl file for the combination-assigned products? Link to comment Share on other sites More sharing options...
NemoPS Posted May 31, 2013 Share Posted May 31, 2013 Hi, Yes, for comnbinations you also need to change product.js (just look for the same classes and ids and you'll find it). This is really bad about prestashop,I mean, the fact that it mixes up js and php 1 Link to comment Share on other sites More sharing options...
whitehumorous Posted May 31, 2013 Author Share Posted May 31, 2013 Hi Nemo, Thanks for the reply...its helpful. Link to comment Share on other sites More sharing options...
vankata.be Posted September 23, 2013 Share Posted September 23, 2013 Hi Nemo. Could you help us with this issue as well? http://www.prestasho...dpost&p=1389133 It is again connected with discounts and probably js etc... Thank you in advance. Link to comment Share on other sites More sharing options...
shaft Posted September 27, 2015 Share Posted September 27, 2015 Hello,this is what I looking too. I have combination, so I have to change product.js in "themes/your_theme/js/product.js Original:Line 741: if (priceWithDiscountsWithoutTax != priceWithGroupReductionWithoutTax) { if (combination.specific_price.reduction_type == 'amount') { $('#reduction_amount_display').html('-' + formatCurrency(+discountValue * currencyRate, currencyFormat, currencySign, currencyBlank)); $('#reduction_amount').show(); } else { var toFix = 2; if ((parseFloat(discountPercentage).toFixed(2) - parseFloat(discountPercentage).toFixed(0)) == 0) toFix = 0; $('#reduction_percent_display').html('-' + parseFloat(discountPercentage).toFixed(toFix) + '%'); $('#reduction_percent').show(); } } To: if (priceWithDiscountsWithoutTax != priceWithGroupReductionWithoutTax) { if (combination.specific_price.reduction_type == 'percentage') { $('#reduction_amount_display').html('-' + formatCurrency(+discountValue * currencyRate, currencyFormat, currencySign, currencyBlank)); $('#reduction_amount').show(); } else { var toFix = 0; if ((parseFloat(discountPercentage).toFixed(0) - parseFloat(discountPercentage).toFixed(0)) == 0) toFix = 0; $('#reduction_percent_display').html('-' + parseFloat(discountPercentage).toFixed(toFix) + '%'); $('#reduction_percent').show(); } } Also I use round percentage to all number. :-) Thank you. Prestashop 1.6.0.14. Regards Shaft Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now