Order completion: need total order value less shipping and tax

Excursionist
20 0 12

Hi all

 

Example:

 

Purchase of £2.50 including £0.42 tax

Shipping of £1.00 including £0.17 tax

Total order of £3.50 including £0.59 tax

 

I am trying to calculate the value of the order minus shipping and tax on the order completion page, to pass through a tracking pixel. Our store prices include tax. The trouble is that order.tax_price includes the tax that's included in order.shipping_price, so we end up deducting the shipping tax twice. Here's what I've got so far:

 

{{ total_price | minus: order.tax_price | minus: order.shipping_price | money_without_currency }}

 

This returns £1.91, but it should be £2.08. Any ideas?

Thanks in advance.

0 Likes
Highlighted
Shopify Partner
87 29 20
{{ checkout.line_items_subtotal_price | money_without_currency }}

That may be what you're looking for.  According to Shopify (https://shopify.dev/docs/liquid/reference/objects/checkout)

The subtotal doesn't include taxes (unless taxes are included in the prices), cart discounts, or shipping costs.

 

Is your store fast enough? Compare your store's speed against hundreds of others for free with our benchmarker - https://www.rvere.com/
0 Likes
Highlighted
Excursionist
20 0 12

Thanks @Alex_Lam, but unfortunately because our prices have tax included, this would return £2.50, which in itself is fine but we then need to deduct the tax of just the line items (not the shipping).

0 Likes
Highlighted
Shopify Partner
87 29 20

Would the tax rate be constant across products? If so, just dividing by that rate may give you what you need. Something like:

 

{{ order.line_items_subtotal_price | divided_by: 1.15 | money_without_currency }}

Assuming a 15% tax in the example

 

 

Is your store fast enough? Compare your store's speed against hundreds of others for free with our benchmarker - https://www.rvere.com/
0 Likes
Highlighted
Excursionist
20 0 12
@Alex_Lam Sadly it’s not consistent. It is mostly 20% but some products are zero rated. I feel like the solution would be to loop through the line items and add up the tax, then this can be deducted as well as the gross shipping price.
0 Likes