Adding/Updating a checkout containing archived product

Solved
motoi_washida
New Member
2 0 1

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?

Jason
Shopify Expert
10296 146 1949

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.
I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
motoi_washida
New Member
2 0 1

Adding a product that is already archived to a checkout seems to be reasonable. For example,

 

Products

  • apple ... selling
  • banana ... archived
  • coffee … selling

 

Checkout

  • apple … 1
  • coffee … 1

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

  • apple … selling
  • banana … archived
  • coffee … selling

 

Checkout

  • banana … 1 (this is added before bananas are archived)
  • coffe … 1

 

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.

 

0 Likes
c10s
Shopify Partner
23 6 5

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" 🤷‍