@Zameer : If you could have a look, or let me know, if you need further information.
We have following shipping rate condition set in Shopify:
$0 for orders above 30$
$2.99 for any order
And we need to implement least priced available shipping rate handle on checkout on app using storefront API version 2021-10.
For order of 40$, The available shipping rate from storefront api is:
"availableShippingRates": {
"ready": true,
"shippingRates": [
{
"handle": "shopify-Free%20Delivery-0.00",
"priceV2": {
"amount": "0.0",
"currencyCode": "AUD"
},
"title": "Free Delivery"
},
{
"handle": "shopify-Delivery-2.99",
"priceV2": {
"amount": "2.99",
"currencyCode": "AUD"
},
"title": "Delivery"
}
]
},
Once discount is applied and order amount is less than 30, we get
"availableShippingRates": {
"ready": true,
"shippingRates": [
{
"handle": "shopify-Delivery-2.99",
"priceV2": {
"amount": "2.99",
"currencyCode": "AUD"
},
"title": "Delivery"
}
]
},
But after the discount is removed using checkoutDiscountCodeRemove mutation.
There is no change in available shipping rate. We understand there is some asynchronous thing going on in background in shopify but, there is no way to tell, if the background task is finished. the ready field in checkout as well as available shipping rate is true.
Available shipping rate should include free shipping ("handle": "shopify-Free%20Delivery-0.00") but it's
"availableShippingRates": {
"ready": true,
"shippingRates": [
{
"handle": "shopify-Delivery-2.99",
"priceV2": {
"amount": "2.99",
"currencyCode": "AUD"
},
"title": "Delivery"
}
]
}
Only when checkoutDiscountCodeRemove is called 2 times or after polling checkout object again, it shows the correct result:
"availableShippingRates": {
"ready": true,
"shippingRates": [
{
"handle": "shopify-Free%20Delivery-0.00",
"priceV2": {
"amount": "0.0",
"currencyCode": "AUD"
},
"title": "Free Delivery"
},
{
"handle": "shopify-Delivery-2.99",
"priceV2": {
"amount": "2.99",
"currencyCode": "AUD"
},
"title": "Delivery"
}
]
},