Learn how to get a tax estimate during checkouts before you have a customer's address information
Prior to collecting customers' address information, you might want to provide them with a useful tax estimate. To do this, you can define the checkout'spurchaseLocation.
The object contains the following three parameters:
Optional (except for purchase locations in the United States)
ZIP or postal code
Using purchase location to get a tax estimate
If you don't yet have a customer's shipping or billing address, purchaseLocation can be used to generate a tax estimate. The following shows two POST /checkouts requests, with and without a purchaseLocation:
Use case: Storefronts with mostly domestic customers
Your company is located in Italy, and most of your storefront customers are Italians. By having country in purchaseLocation default to IT, you can give your customers an initial tax estimate that's applicable to most of them.
Use case: Different postal codes in the United States
In the United States, tax rates can differ by postal code region. You might want to implement a text field on your storefront that collects a US-based customer's zip code and then displays estimated taxes for the products in their cart.
In the following two POST /checkouts requests, country is defined as US but different postalCode values are provided:
The responses show how, depending on the postalCode input, different items[].tax.rate values have been applied, resulting in different totalTax and items[].tax.amount values.