• Log in
  • Contact Sales
  • Evaluate

Get in touch  

Concepts • Orders | Carts

How to calculate cart and order totals

Last updated: 01 Jul 2019

There are two methods that may be used to calculate cart and order totals. The method used depends on the calculation_method setting. The default is currently the simple method and this will continue to be the case for all stores currently using this method. In future, new stores will use the line method by default.

The simple calculation method

Taxes are calculated for each line and are rounded to the nearest penny for the unit.

The cart totals are calculated by summing each of the lines and then subtracting any discounts.

Example:

Unit price $9.99 $0.03 −$10.00  
Quantity 3 1 1
Line price $29.97 $0.03 −$10.00
Tax rate 0.20 0.00   Total tax $5.97
Unit tax $1.99 $0.00  
Line tax $5.97 $0.03  
Unit subtotal $9.99 $0.03   Total $25.97
Line subtotal $29.97 $0.03  
Total $35.94 $0.03 −$10.00

In summary, discounts are applied after tax and rounding occurs at the individual unit level.

The line calculation method

Any cart-level discount is distributed among the cart items such that the amount each line gets is in proportion to its value (before tax).

Discounts are calculated for each line by subtracting from the pre-tax value and the discount is rounded to the nearest penny for the line.

Taxes are calculated for each line based on the line value after discounts have been applied and are rounded to the nearest penny for the line.

The cart totals are calculated by summing each of the lines.

Example:

Unit price $9.99 $0.03  
Quantity 3 1
Line price $29.97 $0.03
Unit discount −$3.33 −$0.01
Line discount −$9.99 −$0.01
Tax rate 0.20 0.00 Total tax

$4.00

Unit tax $1.3333r $0.00
Line tax $4.00 $0.00
Unit subtotal $5.3266666667 $0.02 Total $23.99
Line subtotal $19.97 $0.02
Total $23.97 $0.02

In summary, discounts are applied before tax and rounding occurs for whole lines.

Further reading

Explore More Concepts

18 Jun 2019

How promotions work

Promotions allow you to provide discounts to customers. By defining a Promotion and a code, you put in place the facility to offer discounts to customers applied directly to their shopping carts.

Read More
author
George FitzGibbons
in Carts | Promotions
06 Jun 2019

When to use a custom cart

Custom carts allow you to process an order for any type of item you wish to sell. The item does not need to exists in Moltin, which means custom cart items can be used for all sort of use cases.

Read More
author
George FitzGibbons
in Carts
24 May 2019

How taxes work

Moltin allows you to apply tax items to a cart for every product added to that cart.

Read More
author
Joanna Suau
in Taxes | Integrations