Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I'm using Android Buy SDK.
When a checkout contains a product that is archived by the shop, adding another product to the checkout seems to fail.
// Kotlin
// `variantId` is a valid ID of a product, but the checkout contains a product that is already archived by the shop.
val input = listOf(Storefront.CheckoutLineItemInput(1, variantId))
val mutation = Storefront.mutation { rootQuery ->
rootQuery.checkoutLineItemsAdd(input, checkoutId) { root ->
root.checkoutUserErrors {
it.code()
it.field()
it.message()
}
}
}
val mutateGraph = graphClient.mutateGraph(mutation)
mutateGraph.enqueue(object : GraphCallResultCallback<Storefront.Mutation> {
override fun invoke(result: GraphCallResult<Storefront.Mutation>) {
val success = result as? GraphCallResult.Success
val data = success?.response?.data
if (data != null) {
android.util.Log.d(
"SHOPIFY-DEBUG",
data.checkoutLineItemsAdd.checkoutUserErrors.map { it.responseData }.toString()
)
}
}
})
This prints a message below, and the product of `variantId` is not added to the checkout.
04-27 23:24:08.615 D/SHOPIFY-DEBUG: [{message=Variant 無効です, code=INVALID, field=[lineItems, 0, variantId]}]
Updating any line items (checkoutLineItemsUpdate) also fails. But after the archived item is removed from the checkout, those operation completes successfully.
Is this behavior intended? If I want to update the cart, is it required to remove all items that are archived by the shop?
Solved! Go to the solution
This is an accepted solution.
I agree that this behaviour seems a bit less than ideal, it's awkward for a checkout to get into an error state without the user doing anything.
Would be nice if they dealt with it further on in the process like they do when line item quantity exceeds what's actually available (they reduce it automatically).
eg. "This product is no longer available and has been removed from your cart" 🤷♂️
An archived product is not intended to be for sale, so seeing an error feels expected.
https://help.shopify.com/en/manual/products/details#product-availability
Archived: the product details are complete, but the product is no longer for sale. Archiving a product hides it from your admin and sales channels. You can find the archive button at the bottom of product details page.
Adding a product that is already archived to a checkout seems to be reasonable. For example,
Products
Checkout
In the case above, it is clear that adding a banana to the checkout is forbidden.
On the other hand, in the case below,
Products
Checkout
Adding an apple also fails even though the apple is not archived. I think it might be difficult for users to understand they get errors because the checkout contains a banana, not an apple.
This is an accepted solution.
I agree that this behaviour seems a bit less than ideal, it's awkward for a checkout to get into an error state without the user doing anything.
Would be nice if they dealt with it further on in the process like they do when line item quantity exceeds what's actually available (they reduce it automatically).
eg. "This product is no longer available and has been removed from your cart" 🤷♂️