Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi there,
I'm running into an issue where trying to add my bundle to a checkout returns a null:
```
mutation {
checkoutCreate(input: { lineItems: [{ quantity: 1, variantId: "the_base_64_encoded_string_of_the_product_variant" }] }) {
checkout {
id
webUrl
}
}
}
```
returns
```
{
"data": {
"checkoutCreate": {
"checkout": null
}
}
}
```
What am I missing to be able to add a bundle to a cart using the storefront API?
Solved! Go to the solution
This is an accepted solution.
Interesting error, I have a feeling it's just not supported with Checkouts yet, for creating a cart with a bundle items this should work:
mutation {
cartCreate(
input: {
lines: [
{
quantity: 1
merchandiseId: "VARIANT_ID_FOR_BUNDLE"
}
]
}
) {
cart {
id
lines(first: 10) {
edges {
node {
id
merchandise {
... on ProductVariant {
id
title
}
}
}
}
}
}
}
}
Then you can get check out URL:
query checkoutURL {
cart(
id: "CARTR_ID_FROM_PREVIOUS_STEP"
) {
checkoutUrl
}
}
The Cart and Checkout API seem fairly similar, so migrating shouldn't be too painful, although it is an unexpected headache for sure.
Yes, I've already confirmed these steps. The same request with a non-bundle product variant id does function as expected.
with the bundle:
with any other product:
The bundle is available on all markets, in stock, and available on the headless storefront.
I'm having the same issue, normal product variants work, but not variants from Bundles, also tried using the latest storefront endpoint but no luck, did you find a solution?
Glad to see I'm not the only one—unfortunately I haven't found a solution. Started a ticket yesterday with Shopify but I'm yet to have an answer (hence that community post).
I'm pretty sure it's something stupid that needs to be done for bundles, but the docs are extremely confusing and not very clear
Some progress on my end: while it seems we can't add bundles to Checkout objects, we can add them to Cart objects, and then retrieve a Checkout URL... so it seems maybe we're supposed to migrate to using Cart objects for working with bundles?
Could you walk me through the requests you're using?
FYI, I realized I could add checkoutUserErrors to the request to understand why it's not adding the bundle. Here's what I got:
```
"checkoutUserErrors": [
{
"code": "PRODUCT_NOT_AVAILABLE",
"field": [
"input",
"lineItems",
"0",
"variantId"
],
"message": "Variant the product is not published for this customer"
}
]
```
Update: indeed, creating a cart does work:
```
mutation {
cartCreate(input: {
lines: [
{
merchandiseId: "the_variant_id",
quantity: 1
}
]
}) {
cart {
id
checkoutUrl
}
userErrors {
field
message
}
}
}
```
This is an accepted solution.
Interesting error, I have a feeling it's just not supported with Checkouts yet, for creating a cart with a bundle items this should work:
mutation {
cartCreate(
input: {
lines: [
{
quantity: 1
merchandiseId: "VARIANT_ID_FOR_BUNDLE"
}
]
}
) {
cart {
id
lines(first: 10) {
edges {
node {
id
merchandise {
... on ProductVariant {
id
title
}
}
}
}
}
}
}
}
Then you can get check out URL:
query checkoutURL {
cart(
id: "CARTR_ID_FROM_PREVIOUS_STEP"
) {
checkoutUrl
}
}
The Cart and Checkout API seem fairly similar, so migrating shouldn't be too painful, although it is an unexpected headache for sure.
Yeah it's definitely a head-scratcher.
By any chance, would you happen to know how to transcribe that graphQL query into the shopify-buy node package? That's my missing piece to get it to work on my nextjs headless storefront
Unfortunately, I don't since I'm calling GraphQL directly. If you take that same route, it's also easier to get the checkout URL from what I had above. It's a field within the Cart object. So no need to call the separate `checkoutUrl` query
Yeah sounds like that's what I do.
Shopify finally replied to my support ticket saying that they wouldn't help (it's their own app and their own library but ¯\_(ツ)_/¯)
hello,Can you send me the format of "merchandiseId"?