We are having some issues with entitled products, but if you wish to apply a discount to an order, you will need to add the discountcode to the request:
{
"order": {
"discount_codes": [
{
"code": "PERCENTAGE_ENTITLED_EACH",
}
]
}
}
We have not found a way to set discount_applications for either order or line_items, since they (1) gets ignored if no discount code is added and (2) discount_applications are overridden by discountcode.
When using discountcodes with entitled products, it does not work as expected. First of all the discount is applied to the whole order, instead of on itemlevel and secondly, the total price differs a bit.
The result when going through checkout, is the following: (cleaned to present only discount-related fields):
{
"order": {
"discount_applications": [
{
"type": "discount_code",
"value": "10.0",
"value_type": "percentage",
"allocation_method": "each",
"target_selection": "entitled",
"target_type": "line_item",
"code": "PERCENTAGE_ENTITLED_EACH"
}
],
"discount_codes": [
{
"code": "PERCENTAGE_ENTITLED_EACH",
"amount": "1.20",
"type": "percentage"
}
],
"line_items": [
{
"name": "Product 1 - 2",
"discount_allocations": [],
},
{
"name": "Copy of Product 2 - 1",
"discount_allocations": [
{
"amount": "1.20",
"discount_application_index": 0
}
]
}
]
}
}
When discount is applied through API, it does a bit of magic, and applies the discountcode across the order:
{
"order": {
"discount_applications": [
{
"type": "discount_code",
"value": "1.2",
"value_type": "percentage",
"allocation_method": "across",
"target_selection": "all",
"target_type": "line_item",
"code": "PERCENTAGE_ENTITLED_EACH"
}
],
"discount_codes": [
{
"code": "PERCENTAGE_ENTITLED_EACH",
"amount": "1.45",
"type": "percentage"
}
],
"line_items": [
{
"name": "Product 1 - 2",
"discount_allocations": [
{
"amount": "1.31",
"discount_application_index": 0
}
]
},
{
"name": "Copy of Product 2 - 1",
"discount_allocations": [
{
"amount": "0.14",
"discount_application_index": 0
}
]
}
]
}
}
Notice the difference in discount_applications on the orderlevel. For some reason, Shopify does only allow discounts that are across/all, and then does some “magic” to recalculate the discount.
Is there anyone from Shopify that are able to explain the implementation and how to get around it?