Hi Liam, please find the outputs below. The input is the same as above, with the amount changed to 1000.00. I can confirm that the store currency is SEK and the expected precision is two decimal places.
I notice that the difference is always ~2%, which is Shopify’s conversion fee outside the US. Is it possible that this fee is somehow applied to the discount? I think it would be a bug or a really unexpected behavior if it was since the discount value is being provided in the store currency.
I also notice that the discrepancy depends on the draft order presentment currency (see at the end of this message) and disappears when the two currencies are the same.
I can achieve the desired discount by putting in the (DESIRED_DISCOUNT / 1.02), e.g. if I put in 980.392157, a 1000 discount is applied. If this kind of workaround is required, I would appreciate some confirmation/documentation of where this behavior comes from and if it can be relied on long term.
{
"data":{
"draftOrderCalculate":{
"calculatedDraftOrder":{
"totalPriceSet":{
"shopMoney":{
"amount":"5105.06",
"currencyCode":"SEK"
},
"presentmentMoney":{
"amount":"488.41",
"currencyCode":"USD"
}
},
"totalDiscountsSet":{
"shopMoney":{
"amount":"1020.05",
"currencyCode":"SEK"
},
"presentmentMoney":{
"amount":"97.59",
"currencyCode":"USD"
}
},
"appliedDiscount":{
"amountSet":{
"shopMoney":{
"amount":"1020.05",
"currencyCode":"SEK"
},
"presentmentMoney":{
"amount":"97.59",
"currencyCode":"USD"
}
},
"value":1000,
"valueType":"FIXED_AMOUNT",
"description":"Order #1197",
"title":"Returned items"
},
"lineItems":[
{
"originalTotalSet":{
"presentmentMoney":{
"amount":"586.0",
"currencyCode":"USD"
},
"shopMoney":{
"amount":"6125.1",
"currencyCode":"SEK"
}
},
"discountedTotalSet":{
"presentmentMoney":{
"amount":"586.0",
"currencyCode":"USD"
},
"shopMoney":{
"amount":"6125.1",
"currencyCode":"SEK"
}
},
"appliedDiscount":null
}
]
},
"userErrors":[
]
}
},
"extensions":{
"cost":{
"requestedQueryCost":13,
"actualQueryCost":13,
"throttleStatus":{
"maximumAvailable":2000,
"currentlyAvailable":1987,
"restoreRate":100
}
}
}
}
Here is an attempt to add the discount to the line item - the same discrepancy is present:
{
"data":{
"draftOrderCalculate":{
"calculatedDraftOrder":{
"totalPriceSet":{
"shopMoney":{
"amount":"4085.01",
"currencyCode":"SEK"
},
"presentmentMoney":{
"amount":"390.82",
"currencyCode":"USD"
}
},
"totalDiscountsSet":{
"shopMoney":{
"amount":"2040.1",
"currencyCode":"SEK"
},
"presentmentMoney":{
"amount":"195.18",
"currencyCode":"USD"
}
},
"appliedDiscount":null,
"lineItems":[
{
"originalTotalSet":{
"presentmentMoney":{
"amount":"586.0",
"currencyCode":"USD"
},
"shopMoney":{
"amount":"6125.1",
"currencyCode":"SEK"
}
},
"discountedTotalSet":{
"presentmentMoney":{
"amount":"390.82",
"currencyCode":"USD"
},
"shopMoney":{
"amount":"4085.0",
"currencyCode":"SEK"
}
},
"appliedDiscount":{
"amountSet":{
"shopMoney":{
"amount":"2040.1",
"currencyCode":"SEK"
},
"presentmentMoney":{
"amount":"195.18",
"currencyCode":"USD"
}
},
"value":1000,
"valueType":"FIXED_AMOUNT",
"description":"Order #1197",
"title":"Returned items"
}
}
]
},
"userErrors":[
]
}
},
"extensions":{
"cost":{
"requestedQueryCost":13,
"actualQueryCost":13,
"throttleStatus":{
"maximumAvailable":2000,
"currentlyAvailable":1987,
"restoreRate":100
}
}
}
}
Now varying only the presentment currency of the draft order:
[appliedDiscount] => Array
(
[amountSet] => Array
(
[shopMoney] => Array
(
[amount] => 1000.0
[currencyCode] => SEK
)
[presentmentMoney] => Array
(
[amount] => 1000.0
[currencyCode] => SEK
)
)
[value] => 1000
[valueType] => FIXED_AMOUNT
[description] => Order #1197
[title] => Returned items
)
[appliedDiscount] => Array
(
[amountSet] => Array
(
[shopMoney] => Array
(
[amount] => 1020.0
[currencyCode] => SEK
)
[presentmentMoney] => Array
(
[amount] => 2020.19
[currencyCode] => MXN
)
)
[value] => 1000
[valueType] => FIXED_AMOUNT
[description] => Order #1197
[title] => Returned items
)
[appliedDiscount] => Array
(
[amountSet] => Array
(
[shopMoney] => Array
(
[amount] => 1019.97
[currencyCode] => SEK
)
[presentmentMoney] => Array
(
[amount] => 91.98
[currencyCode] => EUR
)
)
[value] => 1000
[valueType] => FIXED_AMOUNT
[description] => Order #1197
[title] => Returned items
)