• Log in
  • Contact Us

Get in touch  

Concepts • Taxes | Integrations

How taxes work

Last updated: 24 Jun 2019

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

  • Apply a custom tax item in a scenario in which you have your own tax calculation system configured, or if you want to apply a flat tax rate.
  • Integrate a third party tax calculator in a scenario in which you need a tax calculation system. 

Add tax to items in your cart to apply relevant taxes for checked out products.

This guide explains how taxes work with Moltin and you how to apply a flat rate sales tax to every cart item in a cart. 

Moltin lets you apply any tax rates to a cart. How you calculate the rates is up to you, and so this guide assumes that you already know how to calculate tax rates. Otherwise, you'll need to integrate a third party tax calculator. 

Key points about taxes and how they work

  • Tax calculation logic. The includes_tax field on the product can be set to true or false:
      • true Moltin will perform a backward calculation of taxes meaning the original product price will not be affected during checkout.
      • false Moltin will calculate tax and add it to the original product price.
  • Promotions and Taxes. Taxes are calculated after all promotional savings have been applied.
  • Cart-level promotions. Promotional savings are equally distributed across all items in the cart. If there is a remainder after distributing promotional savings across cart items, the promo saving will be rounded up, so that there is no remainder left.

Get your access token

You will need to get a client_credentials access token to follow along making the API requests outlined below.

curl -X POST https://api.moltin.com/oauth/access_token \
     -d "client_id=XXXX" \
     -d "client_secret=XXXX" \
     -d "grant_type=client_credentials"

Add a product to a cart

Add a product to a cart. If the product has the includes_tax field set to true, and you have created a tax item, the cart will apply the calculated tax rate to the product as soon as you add it to the cart.

curl -X POST https://api.moltin.com/v2/carts/:reference/items \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
        "data": {
          "type": "cart_item",
          "id": "d4fb11d4-2fd6-43a1-a047-7b869d41cf96",
          "quantity": 4

Add a tax item to a cart

To apply a tax item to a cart item, all you have to do is to add a tax item to a cart.

curl -X POST https://api.moltin.com/v2/carts/:cartID/items/:itemID/taxes \     
-H "Authorization: XXXX" \     
-H "Content-Type: application/json" \    
-d $'{
    "data": {
      "type": "tax_item",
      "name": "Tax Name",
      "jurisdiction": "UK",
      "code": "MYTAX01",
      "rate": 10.2

Get taxed item

Relationships between cart items and tax items are created automatically when the product is added to a cart.

Product added to a cart must have the includes_tax field set up to true.

Further reading

Explore More Concepts

01 Jul 2019

How to calculate cart and order totals

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...

Read More
James Carter
in Orders | Carts
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
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
George FitzGibbons
in Carts