Hi, I’m developing an app that automatically calculates both shipping and tax. But I’m failing badly.
Can someone please provide the specific endpoints for the Tax and Shipping APIs, along with their body parameters? I have tried some APIs but have not been successful. Can you provide the complete cURL request that can successfully communicate with Shopify?
Thank you.
Liam
July 10, 2024, 9:22am
2
To calculate shipping and tax on orders using the Shopify GraphQL Admin API, you can follow these steps:
Fetch the Order Details : Use the order query to retrieve details about the order, including shipping and tax information.
Calculate Shipping : The shipping cost can be found in the shippingLine field of the order.
Calculate Tax : The tax information can be found in the taxLines field of the order.
Here’s the GraphQL query to achieve this:
query GetOrderDetails($orderId: ID!) {
order(id: $orderId) {
id
totalShippingPriceSet {
presentmentMoney {
amount
currencyCode
}
}
totalTaxSet {
presentmentMoney {
amount
currencyCode
}
}
shippingLine {
title
priceSet {
presentmentMoney {
amount
currencyCode
}
}
}
taxLines {
title
priceSet {
presentmentMoney {
amount
currencyCode
}
}
}
}
}
Notes:
Order ID : Replace $orderId with the ID of the order you want to fetch details for.
Shipping Cost : The totalShippingPriceSet and shippingLine fields provide the shipping cost.
Tax Information : The totalTaxSet and taxLines fields provide the tax details.
Hope this helps!