Subscriptions on Checkout line items, or gift card apply on Cart through Storefront API

Matt_Lein
Shopify Partner
6 0 8

Hello,

I have an application that has been happily using checkouts as carts on the Storefront API (carts did not exist at that time).

Now I would like to add subscription products, and I see that subscriptions are not supported on checkout line items https://shopify.dev/api/storefront/reference/checkouts/checkoutlineiteminput

I see that the new(ish) Carts do support selling plans, which I assume allow subscriptions https://shopify.dev/api/storefront/reference/cart/cartlineinput

However, carts have no mutation to apply gift cards like checkouts do, with https://shopify.dev/api/storefront/reference/checkouts/checkoutgiftcardapply

My store needs gift card application, and subscription products, but I don't see any way to do that in the storefront api.

Is this possible?

Replies 12 (12)

J-ROM
Shopify Staff (Retired)
66 6 8

Hey Matt_Lein,

I want to apologize for not getting back to you about this in a timely manner.

If this problem is still relevant to you, can I ask that you submit this question again? (with information about your current situation)

Sincerely,
J-ROM

To learn more visit the Shopify Help Center or the Community Blog.

Matt_Lein
Shopify Partner
6 0 8

I had completely forgotten about it. From looking at the latest docs, it looks like 13 months later nothing has changed. I may be wrong.

 

I did my best to lay out what I need in the original question, if anything is unclear I can go into more detail. Rephrasing it:

 

I have an application that uses the storefront API.

I would like something that looks like a cart to users.

  1. Add products, checkout, the usual cart stuff
  2. It needs to be able to apply gift cards.
  3. I would like to be able to add subscription products, like a yearly recurring membership.

Currently I use Checkouts. I create a Checkout for each user to act as a cart. They add products, apply gift cards, discount codes, etc. It works well. However, I don't think there is a way to add subscription products to a Checkout.

 

The alternative would be to use Carts. They can add subscription products. However, I think there is no way to apply gift cards to a Cart. I'm not sure what other limitations there would be.

 

If Carts had all the mutations/features of Checkouts (applying gift cards and more), I could use them.

Or, if Checkouts line items accepted a subscription product (through seller id or whatever method makes that work) I could use them.

But as is now, I don't seem to be able to use either for this purpose.

 

 

 

 

J-ROM
Shopify Staff (Retired)
66 6 8

Hey Matt_Lein,

Thanks for confirming your question still applies, I will do my best to answer it now.

There's no plan to introduce Selling Plans in the Checkout API. In general, it's recommended to add subscription products via the Cart API, and redirect the customer to the web checkout where they will be able to apply their gift cards. Hope this helps.


Sincerely,
J-ROM

To learn more visit the Shopify Help Center or the Community Blog.

krishrentech
Shopify Partner
1 0 0

But you did not answer the question. How do we apply for gift cards when using carts in the storefront there is no mutation for that.

weotch
Shopify Partner
24 0 10

You can add a Gift Card to a Cart using the cartLinesAdd mutation, it acts like any other product with variants.

 

I'm not sure how to allow the customer to specify a recipient though.

weotch
Shopify Partner
24 0 10

Actually, I figured how to send to a recipient, it's done by adding specially named line attributes. 

 

Here's what my mutation looks like:

 

 

mutation ($cartId: ID!, $lines: [CartLineInput!]!) {
  cartLinesAdd(cartId: $cartId, lines: $lines) {
    userErrors {
      ...cartUserError
    }
  }
}

 

 

And here's the variables

 

 

{
  "cartId": "gid://shopify/Cart/c1-xxxxxxxxxxxxxxxxxxxxx",
  "lines": [
    {
      "merchandiseId": "gid://shopify/ProductVariant/123456789",
      "quantity": 1,
      "attributes": [
        {
          "key": "__shopify_send_gift_card_to_recipient",
          "value": "on"
        },
        {
          "key": "Recipient email",
          "value": "whatever@email.com"
        },
        {
          "key": "Recipient name",
          "value": "Robert Reinhard"
        },
        {
          "key": "Message",
          "value": "I celebrate your magnificence"
        }
      ]
    }
  ]
}

 

 

That `merchandiseId` is a Gift Card variant

Matt_Lein
Shopify Partner
6 0 8

@weotch wrote:

You can add a Gift Card to a Cart using the cartLinesAdd mutation, it acts like any other product with variants.

 

I'm not sure how to allow the customer to specify a recipient though.


I do not want to purchase a new gift card, I want to apply an existing gift card to a Cart.

The 2023-04 Checkout mutation is checkoutGiftCardsAppend https://shopify.dev/docs/api/storefront/2023-04/mutations/checkoutGiftCardsAppend

Shaibt
Shopify Partner
34 1 31

+1 to this question:

How to add a giftcard code to a Storefront API Cart so its included in the checkout.

 

Tried providing the giftcard code as a discount code in the cartDiscountCodesUpdate mutation: This adds the code to the cart but does not appear to affect the checkout and no discount/giftcard is added to the checkout.

lukasgjetting
Shopify Partner
5 0 2

Did you figure out a way to achieve this combination through either the Cart og Checkout API?

 

Based on the docs, there still seems to be no way to support both.

 

Would be nice to hear from @Shopify whether there are any plans to support gift cards with the Cart API.

Matt_Lein
Shopify Partner
6 0 8

No, I don't believe there is a way. The shopify staff member above said it was not planned.

 

Shopify also maintains another, somewhat secret, place for discussing the api on GitHub. I have asked the same question there without any response:

 

https://github.com/Shopify/storefront-api-feedback/discussions/162

lukasgjetting
Shopify Partner
5 0 2

Thanks for the swift response, Matt. Let's see if we can get a response on GitHub...

lukasgjetting
Shopify Partner
5 0 2

Confirmed on GitHub to be in progress 🚀 (on the roadmap at least)