Shopify themes, liquid, logos, and UX
Can permalink attributes be used to pre-load the cart with subscription/plan products? There's an option to include a product variant id, but can we include a plan id?
Solved! Go to the solution
This is an accepted solution.
I believe I figured it out, this url will clear the cart, add items with a selling_plan and then redirect to checkout:
`https://{SHOP}.myshopify.com/cart/clear?return_to=/cart/add?items[][id]={VARIANT_ID}%26items[][quantity]={QUANTITY}%26items[][selling_plan]={SELLING_PLAN_ID}%26return_to=/checkout`
To head to the cart page instead of directly to checkout, you can remove the `%26return_to=/checkout`.
Cheers,
Phil
I have a same question.
Would love to have an answer to this as well.
This is an accepted solution.
I believe I figured it out, this url will clear the cart, add items with a selling_plan and then redirect to checkout:
`https://{SHOP}.myshopify.com/cart/clear?return_to=/cart/add?items[][id]={VARIANT_ID}%26items[][quantity]={QUANTITY}%26items[][selling_plan]={SELLING_PLAN_ID}%26return_to=/checkout`
To head to the cart page instead of directly to checkout, you can remove the `%26return_to=/checkout`.
Cheers,
Phil
Yes that works!
Thanks Phillip!
Awesome! I'll try it out.
This worked! Thank you so much for posting the solution. I was pulling my hair out.
Hi Phillip, thank you for providing the solution to add a subscriptions product directly to the cart. I can't figure out how to add a second or subsequent variant and quantity. Can you assist?
Hi, have you figured this out? I still don’t understand how to add additional subsequent variants.
Hi @happygree and @achieve,
Sorry for the late reply! You can always add more variants by adding more `items[][id]`, like so:
`https://{SHOP}.myshopify.com/cart/clear?return_to=/cart/add?items[][id]={VARIANT_ID}%26items[][quantity]={QUANTITY}%26items[][selling_plan]={SELLING_PLAN_ID}%26items[][id]={SECOND_VARIANT_ID}%26items[][quantity]={SECOND_QUANTITY}%26items[][selling_plan]={SELLING_PLAN_ID}%26return_to=/checkout`
Cheers,
Phil
Thank you Phil, that worked perfectly!
Phil,
I was able to use this to add my product with its specific plan to the cart, but then I was also trying to add another item to the cart (free upgrade for first month when signing up for 6 or 12 month plan) but it doesn’t seem to want to add the second product because it is not a subscription product - any thoughts? And I would like to have it add it at a zero cost.
Thanks!
Hi @WowieDogs!
You should be able to have non-subscription and subscription products in the same cart, it works for me so the issue is most likely somewhere else. Could you write up an example of what you're inputing?
As for the 0$ product, there's multiple ways to get that done I believe, you could have a 0$ variant of that product or have a discount code that sets that particular product to 0.
Let me know if I've answered your questions, cheers,
Phil
Hi!
I can't seem to get two products in the cart even if they are non-subscription, so I feel like I'm doing something wrong. For this link:
https://wowiedogs.myshopify.com/cart/add/?id=33005749469277&quantity=1&id=39277088309341&quantity=1
it only adds the second one to the cart. If I reverse the order, it also just adds the second one.
I've tried:
https://wowiedogs.myshopify.com/cart/add/?id=33005749469277&quantity=1,id=39277088309341&quantity=1
I've also done the :1 for the quantity and that won't work at all.
Any thoughts?
Thanks!
Julie
Ah take a look at the accepted solution @WowieDogs, the `items[]` before each argument are important! It makes it so you're sending an array to the server.
Trying to create a cart permalink with one subscription item (selling plan) and one regular item. I can get it to work with the subscription item but when I add a second product i get an error. What am I doing wrong?
THIS WORKS FOR JUST SUBSCRIPTION PRODUCT:
THIS DOES NOT WORK WHEN ADDING 2ND PRODUCT
This is not working for me , so I used this
function joinToday(type){
$.get('/cart/clear',()=>{
if(type=='monthly'){
window.location.href = "/cart/add?items[][id]={varId}&items[][quantity]=1&items[][selling_plan]={planId}&items[][id]={varId}&items[][quantity]=1&return_to=/checkout";
}else if(type == 'yearly'){
window.location.href = "/cart/add?items[][id]={varId}&items[][quantity]=1&items[][selling_plan]={planId}&return_to=/checkout";
}
});
}
Hey @Phillip_Malboeu , thank you so much for this great solution. It works very well - I'm just wondering if you can add a discount code on to it somehow, as you can with permalinks like the below?
e.g. https://{SHOP}.myshopify.com//cart/39434614276148:1,39408637149236:1?discount=MEMBERSHIP
I put a ?discount=MEMBERSHIP at the end of your suggested URL but I guess it's never going to like two question marks.
Thanks so much.
Hey @Amelia7, no worries!
Adding a `%26discount=MEMBERSHIP` would do it. %26 is the URL encoding of the &.
Cheers,
Phil
You're amazing, thank you so much!
I can't get the discount code to work. I've tried moving it to different locations in the URL but none of them seem to work.
https://{SHOP}.myshopify.com/cart/clear?return_to=/cart/add?items[][id]=39619404562467%26items[][quantity]=1%26items[][selling_plan]=524091427%26discount=MYDISCOUNTCODE%26return_to=/checkout
@techadmin can you try this format:
https:///SHOP-NAME/discount/DISCOUNT_CODE/?redirect=/cart/add?items[][id]=ITEM_ID%26items[][quantity]=QUANTITY%26items[][selling_plan]=SELLING_PLAN_ID%26return_to=/checkout
YES! That works, thank you.
Great! Glad to help.
When I try this pattern I get an error: "Parameter Missing or Invalid: Required parameter missing or invalid: items".
It's pretty important to the flow that I'm trying to manage that I'm also able to clear the cart as well but haven't been able to find a permalink combination of cart clear / cart add / set discount (that supports subscriptions) that is working. Has anyone had any luck with this combination?
I'm having the exact same issue.
Hi Darzouras,
Yasaman's here from the Subify subscription app.
You can use this permalink for the mentioned requirements:
https://[MY STORE].myshopify.com/cart/clear?return_to=/cart/add?items[][id]=[VARIANT ID]%26items[][quantity]=1%26items[][selling_plan]=[SELLING PLAN ID]%26return_to=/checkout?discount=[SHOPIFY DISCOUNT CODE]
As an example, this is the created permalink for our demo store:
Password is: 1234
Hope this will be helpful.
@amanda3e, guess you had the same question.
Hi, Is there any way to also pre-populate the checkout fields with the permalink while a product with subscription is added. Similar to the below link but subscription is also added to the product: https://shopify.dev/docs/apps/channels/cart-permalinks/cart-permalinks
Alternatively, is there a way to add address and other checkout fields to the below permalink:https://[MY STORE].myshopify.com/cart/clear?return_to=/cart/add?items[][id]=[VARIANT ID]%26items[][quantity]=1%26items[][selling_plan]=[SELLING PLAN ID]%26return_to=/checkout?
Hi.
This is really helpful, but I couldn't find any official documentation about the URL query params for subscriptions. Is this method officially supported by Shopify? Or is there a possibility that this method will stop working someday?
Thanks.
(I didn't mention anyone in the above post, so just in case.)
Hi.
Is there any possibility that you could share your ideas on this?
Hey @d_tehrani,
Well can't be sure, but I based the previous answers on the Cart ajax API: https://shopify.dev/api/ajax/reference/cart
I'm trusting it!
Cheers,
Phil
Hey @Phillip_Malboeu, I am trying to build a link that takes customers to a cart page (not checkout page) - that is pre loaded with any combo of subscriptions / one time products. I then want a discount code to be auto applied when they get to checkout based on the code I put in the URL, I am trying this but it isn't working:
https://[MY STORE].myshopify.com/cart/clear?return_to=/cart/add?items[][id]=[VARIANT ID]%26items[][quantity]=1%26items[][selling_plan]=[SELLING PLAN ID]%26items[][id]= [VARIANT ID] %26items[][quantity]=1?discount=[DISCOUNT CODE]
Any ideas on how I can get this to work?
Thanks
Sam
Hi, @Phillip_Malboeu! I have the same question about discount applying to permalink, as @coysammy. Adding "%26discount=my_discount_code_here" at the end of permalink doesn't work. If I add promocode manually it works as expected. Any ideas?
Hi @Phillip_Malboeu thank you for this excellent solution! One question: is there any way to structure the link so the customer does not see the "cart" breadcrumb in checkout? We want to prevent the customer from navigating back to the cart.
When we create a "checkout link" as described below, the product gets sent straight to checkout and the "cart" breadcrumb is not visible.
https://help.shopify.com/en/manual/products/details/checkout-link
The only problem is, it sends the product as a one-time product instead of a subscription product, and the subscription is essential in our case
Any way to get the best of both worlds here?
Thanks!!
Hi @VSozinov after puzzling with this for a bit, I found out a way to do this:
That works for me and puts the discount into scheckout automatically.
Thank you very much! It helped me
Any clue on how to add attributes to this? I know it has been a long time but I am kinda blocked and this has proved to be very useful.
Hi @Rronz1!
You can try: `https://{SHOP}.myshopify.com/cart/clear?return_to=/cart/add?items[][id]={VARIANT_ID}%26items[][quantity]={QUANTITY}%26items[][selling_plan]={SELLING_PLAN_ID}%26items[][properties][{ATTRIBUTE}]={ATTRIBUTE_VALUE}%26return_to=/checkout`
If it helps, I mentioned in a previous reply here that it's all based on the Cart ajax API: https://shopify.dev/docs/api/ajax/reference/cart
Cheers,
Phil
Hi Phillip! Are you able to help me with creating a link for my store for this exact issue?
I am trying to do this for a subscription product + two non-subscription products and discount.
It adds all of the products and the discount but it set the first product for one time purchase instead of subscription. Here is the base product page for reference -
`shop.myphenology.com/products/morning-evening-gummy-duo-supplements`
Here is the permalink I'm working with-
`shop.MyPhenology.com/cart/39853678231617:1,39853677903937:1,39870377590849:1?selling_plan=578977857?discount=SamplerGift`
Hello @Phillip_Malboeu
This setup works great! However, for some reason, when I append any of the UTM query parameters to the link, none of the values are being recorded in the "Conversion Summary".
EXAMPLE:
https://{SHOP}.myshopify.com/cart/clear?return_to=/cart/add?items[][id]={VARIANT_ID}%26items[][quantity]={QUANTITY}%26items[][selling_plan]={SELLING_PLAN_ID}%26return_to=/checkout%26utm_source=test
Is there a workaround for this?
@Phillip_Malboeu, thank you for this article, it was extremely helpful!
Have you had any success creating a mixed cart permalink? My store features both subscription and single purchase selling plans, and we'd love to be able to create pre-loaded carts via permalink with our subscription products PLUS a one-time product for the customer to try.
Do you think this is possible?
If there was a way to find out the selling id I would be possibly be able to do this.
So far, I have not found a way to do it.
@tbambara @scotts1 I have managed to do a mix between subscription and "normal" one-time products it looks something like this:
In case you are still around, this is something I am trying to do now and cannot seem to get done right.
Here is an example of one link for a product that is working fine https://d7ea93.myshopify.com/cart/clear?return_to=%2Fcart%2Fadd%3Fitems%5B0%5D%5Bid%5D%3D45203860914...
Here is the product I am trying to do it for
{"product":{"id":8565646623010
product variant: 46559953486114
selling id 5905056034
This is what I have tried to do so far and it isn't working https://d7ea93.myshopify.com/cart/clear?return_to=/cart/add?items8565646623010id=46559953486114%26it...
What am I missing?
Hello in case you are still around, I am still trying to figure this out.
Here is an example of a link for a different product that is working with the selling plan/subscription https://d7ea93.myshopify.com/cart/clear?return_to=%2Fcart%2Fadd%3Fitems%5B0%5D%5Bid%5D%3D45203860914...
That is what it is supposed to look like.
I am also following the example you gave but must be missing something about how it is put together right.
'
This is the product and selling plan I am trying to use it for
{"product":{"id":8565646623010
product variant: 46559953486114
selling id 5905056034
Here is the attempt I have so far:
What am I missing? Thanks.
Any suggestion on the format that WOULD NOT clear the cart? It would just add the product?
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024