Jump to content

Reduction type = amount, but front office shows in percentage


Recommended Posts

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

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

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

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

  • Like 1
Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...