What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Retrieving Value Added Tax included in price in a custom storefront

Retrieving Value Added Tax included in price in a custom storefront

jacobmellin
Shopify Partner
1 0 0

Hi everyone,

 

im building a frontend shop with the JS Buy SDK, but I am using the standard Shopify checkout, meaning, the buyer will enter their delivery address in the Shopify checkout. I have implemented a separate cart that displays the sum cost of items added to cart, but I would like to display Value Added Tax that is included in the sum cost.

 

I think I should be able to get the included tax through the JS Buy SDK / Custom Storefront API, since it is displayed in the Shopify checkout based on the buyers automatically detected country. However, the value of `totalTax.amount` or `totalTaxV2.amount` is always 0.

 

I've read that it might be required to set a shipping address (https://community.shopify.com/c/hydrogen-headless-and-storefront/storefront-api-totaltax-always-0/td...), but even if I supply a shipping address, the value remains at 0 and shippingAddress remains unset, but there isn't any error.

 

  shopifyClient.checkout.create({
      shippingAddress: {
          address1: 'Musterstraße 1',
          address2: '',
          city: 'Berlin',
          zip: '10115',
          country: 'Deutschland'
      }
      // This address doesn't return an error,
      // but an error is returned when 
      // adress1, city, zip or country are missing.
  }).then(async checkout => {
      setShopState('checkoutId', checkout.id);
      setLocalStorage('checkoutId', checkout.id);
      setShopState('checkout', checkout);


      console.log("checkout created", checkout);
      // checkout.shippingAddress is null
      // checkout.totalTax.amount is 0 after adding line items and using new checkout from response.
      // checkout.totalTaxV2.amount is 0 after adding line items and using new checkout from response.
  });

Do you have an Idea what I could try here? Is there way to get the tax data from an API based on only the country that the user is in, or automatically determined as in the checkout?

 

Thanks a lot!

Replies 0 (0)