PRESTASHOP - how to show regular and discounted prices in basket summary after discount code is used

155 views Asked by At

Problem

On order item list in basket summary there is no final price of one single product after using any voucher/discount code. There is just total amount of discount value in summary.

Default behavior is that discount amount is calculated and show as total amount (not showing a discount value for each product). So in cart summary we have:

product X - price 10,00$
product Y - price 20,00$
product Z - price 2,00$

and we use the code lets say: gimme20 - that gives 20% discount So in basket summary it looks like:

product X - price 10,00$
product Y - price 20,00$
product Z - price 2,00$

code: gimme20
total: 32,00$
discount: 6,40$
to pay: 25,60$

and we need to show in summary (solution we'd like):

product X - price 10,00$ after discount-> 8,00$
product Y - price 20,00$ after discount-> 16,00$
product Z - price 2,00$ after discount-> 1,60$
code: gimme20
total: 32,00$
discount: 6,40$
to pay: 25,60$

So it is strange that is not working like that by default.

We need to pass each product final discounted price to ERP.

How to do that? Do we need to recalculate every item price extra or is Presta keeping that value somewhere. It is cart summary so we have $cart object available to use.

1

There are 1 answers

2
Tom On

The problem is that in PrestaShop, creating a discount for the entire order does not apply the discount to each item separately, but to the entire order amount. This is something that causes many problems, especially when we want to generate an invoice based on an order, where in the invoicing program the only option is to apply a discount to the item on the invoice.

Therefore, to solve your problem, you have to calculate the amounts individually when downloading the order to the ERP. Watch out for missing pennies in calculations because it always causes trouble. For example, if the order amount is €100 and there are 3 products in the basket and a 10% discount code, then 10%/3 = 3.33333333333(3) so two products will have a price reduced by €3.33 and one €3.34, unfortunately.