Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
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!