Checkout

How to calculate real cart savings in PrestaShop so the figures always add up

A customer who can clearly see how much they are saving buys with more confidence. PrestaShop applies catalogue discounts, vouchers and free shipping, but never adds up the total saving in one place. Doing it right means the figures must match the cart, the order and the invoice to the cent. That is why we built Savings in your cart.

Why it is not trivial in PrestaShop

  • Savings come from several places: specific prices in the catalogue, cart rules with a fixed amount or a percentage, free shipping vouchers and gift products.
  • It is easy to count twice. A product given away by a cart rule, or a voucher that only grants free shipping, can show up under two headings at once.
  • Prices change after the purchase. If the saving on an old order is recalculated from today's catalogue, it no longer matches what the customer paid.
  • Taxes depend on the customer group: some see prices with VAT and others without.
  • The modern cart updates without reloading the page, and hooks do not run again.

The approach: figures that always add up

The design rule was that original total minus savings must always equal the final price. The module splits savings into products, cart discounts and shipping, each calculated from the information PrestaShop already uses to charge, with no formulas of its own that could drift.

Technical decisions

Read the order, not the catalogue

Nothing is recalculated on the order confirmation or in the order history. The module reads the amounts PrestaShop froze at the moment of purchase, so an order from a year ago still shows the saving it had even if discounts have changed since.

No duplicates

Gift products do not add catalogue savings, and vouchers that only grant free shipping go on their own shipping line rather than the discounts line. The tax mode follows the customer group.

The shipping you saved

Optionally, the module estimates the shipping that would have been charged when the store offers it free above an amount or a weight, based on the chosen carrier, or the one the cart quotes, and the visitor's zone. It is off by default and its limits are documented, because other shipping modules may change the price.

Live updates

On PrestaShop 1.7 and later, the module listens to cart events and reloads only its own block. When there is no saving it outputs an empty hidden container, so the block can appear as soon as a discounted product is added, without reloading the page.

One module from 1.6 to 9

Configuration uses PrestaShop's classic forms, valid in every version. The block can be placed in 28 theme positions or as a widget, and on 1.6 it relies on the theme repainting the cart itself.

What we learned

Touching the checkout requires knowing how PrestaShop calculates every amount, because the customer compares with what they end up paying. It is the same groundwork that custom business rules, special promotions or integrations with invoicing systems need.

What this development demonstrates

  • Knowledge of PrestaShop price, cart rule and shipping calculation
  • Using frozen order amounts to keep historical consistency
  • Integration with the AJAX cart of PrestaShop 1.7 to 9
  • Tax handling by customer group
  • One module compatible from 1.6 to 9.2
  • An amount test plan before going to production