Headless commerce and custom storefronts with Shopify APIs and SDKs
TLDR: After adding a discount code who's line items or shipping lines don't fulfill the requirements of that code, polling for successful checkout completion after completing the checkout with the `checkoutCompleteWithTokenizedPaymentV3` mutation never returns a non nil Order object - thus failing the checkout flow
SDK Version: 5.0.0
Summary
When the user applies a discount code to the checkout that doesn't apply to any of the line items or shipping lines, for example, a free shipping discount code with a $50 limit but the line items subtotal doesn't meet this limit, after successfully completing the checkout with the `checkoutCompleteWithTokenizedPaymentV3` mutation and then polling for successful checkout completion, the polling fails because the order object is always nil.
Steps to Reproduce
1. Create checkout with `checkoutCreate` mutation
2. Using the `checkoutDiscountCodeApplyV2` mutation add a discount code who's requirements won't be met for via the line items or shipping line
3. Trigger Apple Pay flow
4. Complete checkout with `checkoutCompleteWithTokenizedPaymentV3` mutation. (This returns successfully)
5. Poll for checkout completion using `.node(id: checkoutId) { .onCheckout { $0} }` query, with retry polling condition:
let retry = Graph.RetryHandler<Storefront.QueryRoot>(endurance: infinitePollingEnabled ? .infinite : .finite(10), interval: 1) { (response, error) -> Bool in
return (response?.node as? Storefront.Checkout)?.order == nil
}
Full Query:
static func query(checkoutId: GraphQL.ID) -> Storefront.QueryRootQuery {
return Storefront.buildQuery { $0
.node(id: checkoutId) { $0
.onCheckout { $0
.ready()
.appliedGiftCards{ $0
.id()
.amountUsedV2 { $0
.amount()
.currencyCode()
}
.lastCharacters()
}
.shippingLine { $0
.title()
.priceV2 { $0
.amount()
.currencyCode()
}
}
.order { $0
.shopifyOrderFragment()
}
}
}
}
}
6. Retry polling uses up all the retries and fails because Storefront.Checkout Object's Order property is always nil.
Trouble Shooting
As soon as I remove this non applicable discount code, the checkout completes successfully and the polling returns with an order object that has a value.
Expected Results
I would expect to still be able to successfully complete a checkout with a non applicable discount code just like how the Shopify checkout web flow allows you to do.
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...
ByYour online store speed can enhance your store’s discoverability, boost conversion rates a...
ByShopping is at our fingertips with mobile devices. Is your theme optimized to be user-frie...
By