Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How to create a direct link to a preloaded cart page?

How to create a direct link to a preloaded cart page?

Ariav_Cohen
Visitor
2 0 2

Hello, I am trying to create a link which will allow users to reach the cart page directly with the product already added to cart with quantity of 1.

I was following the exact instructions from this link and it still does not work. https://help.shopify.com/en/themes/customization/cart/use-permalinks-to-preload-cart?utm_source=guru...

This is how I did it according to the insturctions but not working, its showing cart is empty. 

https://store.uprightpose.com/cart/415226036260:1

 

Any help please?

 

Thank you

 

Replies 16 (16)

Nick
Shopify Staff (Retired)
4531 434 1028

Hi Ariav, 

Nick here from Shopify. 

I did a test and clicked the link which you provided in the post also and found the same result. This is what I see here when I followed the process. I'm going to take a deeper look into this for you and get back to you when I have an update if that's ok. I'm not quite sure why it isn't working. 

All the best, 

Nick

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

Nick
Shopify Staff (Retired)
4531 434 1028

Hi Ariav, 

I did some further testing on this for you and found out why the link you added was not working. The reason behind the link not working is because it is a product id and not a variant id for the product. For the permalink to sync properly it must be a variant id. For example, it is like saying t-shirt instead of black t-shirt with the logo in red in small. So just to make sure to get the variant id in the search console after adding .xml at the end of the product page. 

I did one which works which you can see from the link below:

https://store.uprightpose.com/cart/43106781710:1

Hope this helps and makes it clear why this wasn't working with the link you used. Don't hesitate to ask should you have any other questions about this or anything else. 

Nick

 

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

Luke_f
Shopify Partner
9 0 2

What about add to cart — but remain on the page where you are? Anyone got ideas on this?

Ariav_Cohen
Visitor
2 0 2

Thank you Nick, that's great and its working for me now. 
But this looks like its sending you directly to checkout page. Can we use the same concept for Cart page?

Jason
Shopify Partner
11206 226 2315

You can do do a link like so:

https://yourstore.com/cart/add/43106781710

 

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
Luna8030L
Shopify Partner
10 0 3

What about the product that hasn't any variant, How Can I get the permalink cart of that product? 

NoQlue
Tourist
3 0 8

I don't understand how shopify is so inept with this basic feature - I had to look through 20 different articles to explain this in simple terms.

 

To find the variant id of a product with no variants: in shopify backend goto Products > Click the product you want to add > Now add .xml to the end of the url so store.com/admin/products/id.xml 

From the xml page, look for <id type="integer">#########</id> - This is the number you need to add instead of the product number.

 

Thanks for not clarifying this anywhere, shopify. 

FilipposD
Shopify Partner
45 1 19

Shopify actually creates a new silent variant when you create a product.

This can be found with their API with a simple query, but they could have included an easier way to access ids like that in the dashboard, for non-developers.

Keep in mind, in the .xml file, the right id is in the variants array, as opposed to the <product> field directly.

<variants type="array">
    <variant>
        <id type="integer">38169489375384</id>
        ....

 

BB_Tech
Excursionist
106 1 7

What code did you use to query what you got in the above picture

simon_evolution
Tourist
7 0 4

Just add the product to the basket and then click on the item in the basket and the URL of the new product page that opens has the ID appended at the end of the URL for example https://shop.evolutionpowertools.com/products/hulk-electro-v2-h320e-230v-electric-plate-compactor?va...  I have no idea why this variable isn't exposed within the back end of shopify along with the product SKU.

Avalon_Yarnes
Visitor
1 0 0

This is how I found it, hope that helps anyone running into this issue (I'm using chrome):

 

1. On the product page on the front end, right-click on the "add to cart" button, then click "Inspect".

2. Go on below the selection, it should look something like this: <div id="VariantsJson-4520496300141" class="hide" aria-hidden="true">, click to toggle it open.

3. Under should be the variant id under "id" (see screenshot).

 

varient for shopify.png

Supriya
Tourist
7 0 1

Hi,

I am trying to add Unique URL for add to cart for each product through meta
Its working fine like adding that product in cart but on checkout page its showing Sold out, and I have done setting of Continue selling when out of stock

Supriya_0-1622009762471.png

can you tell me what's the issue is?

 

Nick
Shopify Staff (Retired)
4531 434 1028

Hi Ariav, 

Yep just as Jason shows us here, just to put /add after /cart should do the trick for you here. Yours would like this for example: - https://store.uprightpose.com/cart/add/43106781710

There is also a way to add different quantities for this feature also. It would slightly change the layout of this to something like this for example https://store.uprightpose.com/cart/add?id=43106781710&quantity=99. Maybe Jason knows a more simple way to put the link together for a different quantity in the cart?

Nick

 

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

JoVelarde
Visitor
1 0 0

How do I make this AJAX add to cart?

kalid
Shopify Partner
1 0 0

Hi Nick! is there a way to add a discount code to that link (cart) and then it applies in the next step (checkout page).

 

Thanks!

DeeLT
Excursionist
21 0 5

I'm trying to do this too. While also adding an affiliate ID to the URL.