thanks - i solved it in a different way - used javascript SDK and the APIs to build a checkout and populated it with the items i wanted in there and push customer to a web window with the checkout.
works great and this way can control everything…
thanks - i solved it in a different way - used javascript SDK and the APIs to build a checkout and populated it with the items i wanted in there and push customer to a web window with the checkout.
works great and this way can control everything…
I’m trying to find a way to add a product with line item properties to a user’s existent cart using a link (without clearing their cart). Thanks to this thread I learned I can add items to an existent cart using this link: https://example.com/cart/add?id[]=variantid
But does anyone know if there’s a way to include line item properties in that link?
Hi Danstoj - did you find a solution to this? I am interested.
Hey all! FYI – we built an app that builds this link for you:
Hi everyone!
I have 3 things I would like to get out of this, and I feel like I’m so close! But would love some help in this area.
I want my link to:
With the great info that you have posted, I know how to get the product in the cart, I just don’t know how I can have these all in the URL at the same time and still work.
Here is what I have so far (please note I am not a coder in anyway):
https://(domain name)/discount/(code)?redirect=/collections/(collection)
Any thoughts?
Thanks!
Your app looks great, can it also make the customer who gets the URL go straight to a collection (not check out). I ask this because it is hard to find a pre-loaded cart with discount AND product
Best
Rose
Unfortunately, our app only works if you’re sending people directly to the checkout. I’m sorry I can’t be of more help, but I don’t know of an easy way to pre-populate a cart with a product.
Hello,
We have previously done something similar including adding custom line item properties to the permalink, feel free to send us a PM if you would like to test our beta?
Below are some example links to do various things that have been useful for me lately. These may be a bit redundant with other posts, just putting them in one place.
{These parts, including the curly brackets are placeholders.}
Redirect to url and applies coupon
https://domain.com/discount/{DISCOUNT CODE}?redirect=/{URL FOR REDIRECT}
Applies discount code and adds product and goes to cart
https://domain.com/discount/{DISCOUNT CODE}?redirect=/cart/update%3F%26updates[{VARIANT ID}]=1
Removes products in cart, adds product of variant and discount code:
https://domain.com/cart/{VARIANT ID}:{QUANTITY}?discount={DISCOUNT CODE}
Adds products and goes to checkout:
[https://domain.com/cart/update?&updates[{VARIANT](https://domain.com/cart/update?&updates[{VARIANT) ID}]={QUANTITY}
I’ve noticed there’s a problem collecting referrer and landing page data with the order when Permalinks are used, does anyone have a workaround?
If you look at the XML or JSON for an order where the person went the “normal” route (adds to cart, then checks out), it looks like this:

As you can see, this order came from a Facebook post. They landed directly on the product page, added to cart, and checked out. This is all correct.
But if the user clicks a permalink (instead of adding to cart) the order XML looks like this:

The original referrer is dropped and replaced with the landing page, and the landing page is replaced with the permalink URL. This seems to be because of the redirect after the permalink. Our permalink is to /cart/variantid:qty then the user gets redirected to /checkout/etc…
If this is in any way confusing because I blocked out the domain and product, here’s the rundown:
But when a Permalink is used, this happens:
Basically when you use a permalink, at the point where the permalink redirects the user from /cart/variantid:qty to /checkout, for some reason Shopify is dropping the referring-site and landing site values, then re-establishing them as if it were a brand new session – thus making the referring-site domain.com/products/myproduct and the landing-site /cart/variantid:qty
It’s happening consistently on every single permalink in our store, for every product. If the user checks out with a permalink, original referring-site and landing-site are lost, and replaced with the page they clicked the permalink from. I’m not sure what to do about it, because a lot of our landing pages use permalinks and it’s really starting to affect the reporting.
Hi Everyone,
I’m just adding a further note on this thread with the URL structure that worked for me.
I benefited from the helpful examples above, but needed to do a slight modification to the above to get this working for me.
I wanted a URL which would
The URL I used to achieve this was:
The key learning/amendment from the above comments for me was that rather than an ampersand character (&) in the URL I needed to encode that character to %26 and use that instead to get multiple variants added to the new cart. Otherwise only the first item was being added to the cart.
Hope it helps someone else.
Nice hack. It works. It lands on the cart page instead of checkout page.
Here’s a wiki of manipulating permalinks in Shopify :
Permalink with some products, quality, addresses, email and a discount code (disc to be created beforehand) → Land on checkout page
https://xyz.myshopify.com/cart/37415174176960:1,37415180665024:2,37415188103360:3?checkout[email]=somebody@store.com&checkout[shipping_address][city]=thisismyhometown&checkout[shipping_address][zip]=90001¬e=just-a-test&ref=refcode&discount=disc1
Update an item to a quantity of 10 → Land in cart
https://xyz.myshopify.com/cart/update?&updates[37415174176960]=10
Remove an item from the cart by set quantity to 0 → Land in cart
https://xyz.myshopify.com/cart/update?updates[37415174176960]=0
Remove an item from the cart and then add 3 → Land in cart
https://xyz.myshopify.com/cart/update?updates[37415174176960]=0&updates[37415174176960]=3
Clear the cart and do a parameter based redirect with return_to a preloaded cart in Checkout page → Land on checkout page
https://xyz.myshopify.com/cart/clear?return_to=/cart/37415174176960:1,37415180665024:2,37415188103360:3?checkout[email]=somebody@store.com&checkout[shipping_address][city]=thisismyhometown&checkout[shipping_address][zip]=90001¬e=just-a-test&ref=refcode&discount=disc1
Clear cart, add multiple items, and land in cart page. Must encode & character to %26 or only the first item is added to cart.
https://xyz.myshopify.com/cart/clear?return_to=/cart/update?updates[37415174176960]=2%26updates[37415180665024]=4
Let me know should anything else I can add to wiki.
Something people asked for earlier, and something I want, is to simply add the item to the cart but do not take the user off the current page. Anyone have any ideas?
Hmm.. I missed it. But what would be a good use case?
The use case, in my case anyway, would be to let people add multiple items without needing to go back and forth to the cart. I have a list of 2,000 digital song downloads and people usually want to buy between 10-100 at a time. I don’t want them to go to the cart after each selection.
Hi Bhuvanesh_Mille, what I believe you’re looking for is the Shopify Ajax API. The links discussed in this thread are for use outside of a Shopify site (from an email for example) to direct someone back to your site and add items to the cart at the same time. Once a customer is already on the site then you can use the Ajax API to add products without leaving the page.
Thanks! I thought I was missing something.
Thank you. I came to the same conclusion after found this thread on ‘add to basket instead of creating cart’.
My question is, can it be used for customize the cart page such as adding ‘Save Cart’ button or adding a checkbox to user agreement etc?
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?