Re: Cart - Use permalinks to pre-load the cart

Cart - Use permalinks to pre-load the cart

TyW
Shopify Staff (Retired)
463 71 1237


What is a cart permalink?

A cart permalink takes your customers directly to the first page of the checkout screen with items pre-loaded into their cart.

Have you ever wanted to link directly to the Shopify checkout screen with a specific cart already loaded with items? Have you ever wanted to put a "Buy it now" button in blogs and newsletters? Have you ever wanted to provide an easy reorder link to customers? Cart permalinks are the answer.

This is what a cart permalink looks like:

http://your-store.myshopify.com/cart/70881412:1,70881382:1

Where 70881412 is the product variant's unique ID and 1 is the quantity.

So the format of the url is:

http://yourstore.com/cart/#{variant_id}:#{quantity}(,...)


Appending cart and checkout parameters

You can pre-fill any of the checkout fields, simply by appending checkout query parameters in the cart permalink URL. When appending checkout query parameters, use the following URL format:

/cart/{variant_id}:{quantity}?checkout[email]=somebody@store.com&checkout[shipping_address][city]=thisismyhometown

where [email] represents any of the possible checkout fields in the form, and [shipping_address][city] shows how you can use nesting to populate child fields.

List of supported checkout parameters

You can pre-fill any of the following query parameters:

Checkout parameter Description
checkout[email] Email of the customer making the checkout.
checkout[shipping_address][first_name] Address [first_name].
checkout[shipping_address][last_name] Address [last_name].
checkout[shipping_address][address1] Address [address1].
checkout[shipping_address][address2] Address [address2].
checkout[shipping_address][city] Address [city].
checkout[shipping_address][zip] Address [zip].


Applying a discount

You can directly apply a discount to a cart permalink.

The following format applies the discount:

/cart/{variant_id}:{quantity}?discount=test

where test is the string value of a discount code.

Note: Notes, cart attributes, and tracking parameters can be added as query parameters as usual. If customer accounts are enabled on your website, and the user is not logged in, they will see the login page before reaching the checkout.

Adding a "Buy this" link to a blog post

  1. From your Shopify admin, go to Online Store > Blog Posts.
  2. On the Blog posts page, either add a new blog post or click on an existing blog post.
  3. In the Rich Text Editor, under the "Content" header, click the HTML button:

    preload01.jpg

  4. Add your link. It should look something like this:

    <p><a href="http://your-store.com/cart/70881412:1">Buy this item</a></p>
  5. Save your changes and test it out in your store.

Adding a "Reorder" link

You can add a "reorder" link right in your theme's customers/order.liquid template for each line item in the order.

 

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. Under the Templates folder, locate and click on customers/order.liquid to open it in the online code editor. Don't see the template? Create one by clicking the Add a new template link.
  4. In the online code editor, paste the following piece of code where you would like your link to appear:

    <a href="/cart/{{ line_item.variant_id }}:{{ line_item.quantity }}">Reorder this</a>

     

  5. Click Save to confirm your changes.

Conversion tracking

Wish to add some tracking info to the URL, which will then show up on the order details page in your admin, when orders come in?

Use a cart note:

/cart/70881412:1,70881382:1?note=came-from-newsletter-2013-02-14


Or use a cart attribute (you can have several of those):

/cart/70881412:1,70881382:1?attributes[where-from]=came-from-newsletter-2013-02-14&attributes[some-other-key]=some-value


The cart note and cart attributes are shown on the order details page under Order Note.

Or use the 'ref' parameter:

/cart/70881412:1,70881382:1?ref=came-from-newsletter-2013-02-14


The ref value is shown as a referral code in the Conversion summary section on the order details page. Click View conversion details and then click View full sessions to view the session details page:

 

preload02.png


Sales attribution

To attribute an order to a sales channel or app, you can add an additional parameter to the permalink. You can view sales attributions in the Sales by Channel report, which shows the name of the channel or app that the customer used to place their order. Sales attributions also appear on the sidebar in your Shopify Home. You can specify a storefront access token in the cart permalink as shown in the following example:

/cart/70881412:1,70881382:1?access_token=#{access_token}
 

Can I let the customer edit quantities?

You can't. Quantities cannot be edited when the customer follows a cart permalink.

Finding a variant ID

Click here to learn how to find a variant ID from within your Shopify admin.

 

TyW | Online Community Manager @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Replies 130 (130)

Martin-NZPost
Tourist
11 1 2

Hi

Does anyone know how updating the input on the checkout page can work with Online Store 2.0 themes?

 

E.g. this works with a vintage theme e.g. Debut
https://a-vintage-theme-shop.myshopify.com/cart/31923935772751:1?checkout[shipping_address][address1...

But this does not work for a new theme e.g. Dawn

 
It partially works by redirecting to the checkout page and populating the product, but not the address.

 

Thanks

 

 



 

Jesse_Meyers
Shopify Partner
23 1 12

Hi @Martin-NZPost both of your example shops are unavailable but if you test with the Shopify Dawn theme demo then you can see it does work on Dawn so it is likely something else going on with your test shops.

Try the link below to see that it does work with Dawn as the theme should have no impact on this behavior.

https://theme-dawn-demo.myshopify.com/cart/39577056936025:1?checkout[shipping_address][address1]=Martin%20St
faredrop
Shopify Partner
2 0 0

Is it possible to use cart permalinks with Discount Combinations?

 

I've tried comma seperating the discount codes like the products as well as specifying the discount query parameter multiple times, but neither combination appears to work...

pcslicer
Tourist
5 0 1

Why can't I pass in a state code in the URL?  

rohanrajpal
Shopify Partner
40 0 13

Great guide!

Is there a way to do the same with abandoned cart URLs?

This is how an abandoned cart URL looks like:

https://royalkirana.myshopify.com/55621124183/checkouts/9ad3cf58038131b41a6838e3abf53384/recover?key...

Now I want to use `notes` or `ref` params to know where the cart was recovered from, but both the params don't show on the orders page 😞

Founder | Spur Feel free to reach out to me at @rohanrajpal98 on Twitter

Adujust
Visitor
2 0 2

Right now this doesn't work for checkout page with URL "checkouts/c/".

https://xyz.com/checkouts/c/7d9c2373f19897e4b9b1d1b97470ddde/information?checkout[email]=somebody@st...

Johno-BARPIG
Visitor
2 0 1

I've been trying to get this to work for the longest time ever, and still I keep getting an error page saying "Link expired". 

What's going on here? I'm trying to add my product to my cart automatically:
https://barpig.myshopify.com/cart/4292591059015:1

HELP!

Jesse_Meyers
Shopify Partner
23 1 12

Hi @Johno-BARPIG your test link uses a product id but you need to use the variant id which is 30917721358407 so the link is https://barpig.myshopify.com/cart/30917721358407:1
Screenshot 2022-11-22 at 11.02.11 AM.png

Johno-BARPIG
Visitor
2 0 1

OMG @Jesse_Meyers YOU ARE A SAINT!

Thanks for such a speedy reply, and showing where I can actually find this - I never declared variants for the products, but this makes it a dream!

YOU'RE AMAZING!!

George_C
Trailblazer
162 2 150

I'v not had a lot of luck with some of the code in the replies in this thread, but for anyone looking to send the user to the cart page, with multiple items that have multiple quantities, and add an existing discount code ("test" in this example), this works for me:

 

https://yourstore.com/cart/update?updates[12345]=2&updates[67890]=3&return_to=/discount/test?redirect=/cart

The number strings are where you place your Variant IDs.  The number after the equals sign are the quantities for each variant. 

 

I am trying to figure out how to add the name/email/address parameters, but no luck. I don't know enough about the coding/parameters syntax to know where to place that stuff. 

Monster, creature & cryptozoology patches, buttons & stickers.
George_C
Trailblazer
162 2 150

IN additional to adding multiple items with quantities, also looking for a way to add multiple discount codes, so I can combine with free shipping and an order discount. 

 

I have tried 

https://youshop.com/cart/update?updates[1234]=2&updates[5678]=2&return_to=/discount/test&return_to=/discount/test2?redirect=/cart
https://youshop.com/cart/update?updates[1234]=2&updates[5678]=2&return_to=/discount/test&/discount/test2?redirect=/cart
https://youshop.com/cart/update?updates[1234]=2&updates[5678]=2&return_to=/discount/test?return_to=/discount/test2?redirect=/cart

 None of these work. They all add the products/quantities, but only add one discount code. I can manually add the second discount code, so I know it is valid. And I can run two 

Monster, creature & cryptozoology patches, buttons & stickers.

pcslicer
Tourist
5 0 1

This syntax works:

https://slicesupplies.com/cart/41845808005273:10,42180480991385:5,42180484104345:10?checkout[email]=xxx@gmail.com&checkout[shipping_address][last_name]=Gino's Pizza&checkout[shipping_address][address1]=380 Central Avenue&checkout[shipping_address][city]=Jersey City&checkout[shipping_address][country]=US&checkout[shipping_address][province]=New Jersey&checkout[shipping_address][zip]=07307&checkout[shipping_address][phone]=000-000-0000&ref=NFC

asfakansari
Shopify Partner
1 0 0

I am trying to create cart permalink need information about rates parameter details.Screenshot 2023-02-01 160009.png Building a sales channel with cart permalinks (shopify.dev)

 

CB2023
Visitor
2 0 0

I am having trouble getting sales attribution to work (tt worked a few months ago but it's currently not working for me) - I am appending access token to the cart/checkout url but the orders are still shown as from "online store"... please help!

KnivesEtCetera
Shopify Partner
6 0 4

Is there a way to add metafields, in addition to the custom attributes?

Stephanie_Smit5
Visitor
1 0 0

We use the Buy Channel often to show an entire collection on another site. Can we use a permalink to automatically apply a discount to someone shopping that channel on a particular page? The automatic discount codes do not work on the Buy Button Channel. If I could do this with a link that would be perfect!

jam_chan
Shopify Partner
925 23 188

I'm using cart permalink redirecting customers to checkout. Currently, it cleared the existing items in the cart. Can these items be preserved? Any way to do so?

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
yellowwebmonkey
Shopify Partner
15 0 3

We use the Ziplinks app mentioned higher in the thread and it gives you the option to replace cart or just add to it: Shell Shock CBD · New ZipLink · Shopify Plus 2023-07-03 at 9.25.33 AM.jpg

 

https://apps.shopify.com/permalinks

Alexis Priddy

B-Bubbles
Tourist
8 0 1

Has anyone been able to work out how to add tags to permalink, I've tried:
tag=tagA
tag=tagA,tagb
tags=tagA
tags=tagA,tagb

None of these work. Any help would be appreciated.

PaulNewton
Shopify Partner
7450 656 1562

permalinks do not create tags., and tags are not using for product urls they are used for  collections tag-based-filtering.

What is the actual goal https://xyproblem.info/ 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


B-Bubbles
Tourist
8 0 1

My actual goal is to apply tags to an order because I have automated scenarios that filter orders based on tags. On my case, tags are used in every order to determine how we deliver to them

PaulNewton
Shopify Partner
7450 656 1562

Assuming the products themselves cannot be directly used as the thing to trigger tagging,

You'd need to try and either use cart-attributes, cart note , or line item properties.

Then in shopify-flow use custom-attributes of the order as conditions to internally tag those orders.

 

💣Caveat - Keeping in mind an import point here is: if a process only listens for order-creation and at that time then checks for a tag nothing might happen as an order might not have a tag yet. So it may only work only for processes that listen for order updates then checks tags. 

Always do test order-edits, or test checkouts to verify post-tagging behavior of automations.

 

A workaround for some situations can be adding a "free" utility product to the checkout  that represents the info that is used to trigger a behavior when other methods do not work; the "free" thing is something innocuous like a manual that's already included with one of the other products anyway, an order brochure, stickers , or just a platitude like "$0 free - our gratitude - " etc

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


yellowwebmonkey
Shopify Partner
15 0 3

The app I mentioned earlier in the thread can tag orders and customers.

Alexis Priddy
B-Bubbles
Tourist
8 0 1

Your app doesn't provide permalinks that I can generate dynamically. It's not fit for pyrpoy

frst_10
Shopify Partner
11 0 4

@yellowwebmonkey is correct here. ZipLinks is a good solution for your tagging method, @B-Bubbles .

B-Bubbles
Tourist
8 0 1

As i mentioned... Ziplinks doesn't provide permalinks that I can generate dynamically. It's not fit for purpose (excuse the typo in the previous reply)

Mario_
Shopify Partner
8 0 5

Hello everybody!

I want to contribute to this topic I found extremely useful:

I've read all the conversation and I think there is a missing case:

 

1- Add a product to an existing cart
2- Try to apply a discount code to the existing cart

3- Land to the checkout page

 

In this case, the permalink should be:

 

https://yourshop.com/cart/add?id[]={variantID}&return_to=/discount/{discountCODE}%3fredirect=/checkout

The redirect to the checkout does the trick! 😉

I hope it helps someone!

RobFarmLink
Shopify Partner
43 2 43

So helpful. Thanks @Mario_!

onescales
Shopify Partner
98 3 17

For non technical people (especially as its difficult to find the variant id's) we made a tool you can add to your site to easily create permalinks

 

See our youtube explainer - https://www.youtube.com/watch?v=3X33Iwu4PjE 

See https://onescales.com/blogs/main/shopify-pre-loaded-cart

 

OneScales.com Teaches Shopify and Solves Ecommerce Problems for Free. See our Youtube Channel for Tutorials - https://www.youtube.com/@onescales
We Also Share Insight about E-commerce, Web, Tech, AI, Analytics, SEO, PPC, Marketing and More.

onescales
Shopify Partner
98 3 17

It's hard for most users to find the variant id, therefore we made a tool you can use on your store to create a url yourself without having to look up one product at a time - https://onescales.com/blogs/main/shopify-pre-loaded-cart . there's also a youtube explainer at https://www.youtube.com/watch?v=3X33Iwu4PjE 

OneScales.com Teaches Shopify and Solves Ecommerce Problems for Free. See our Youtube Channel for Tutorials - https://www.youtube.com/@onescales
We Also Share Insight about E-commerce, Web, Tech, AI, Analytics, SEO, PPC, Marketing and More.
RareArtifact
Excursionist
17 0 4

Easiest way is just to view the product in a browser on the normal website and add .json to the end of the URL. You’ll see variant_id in there.