# Cart permalinks: links that fill the cart

> Build a Shopify link that adds products to the cart and opens checkout: /cart/variant-id:quantity, with discount codes, email and the cart page.

Page: https://lintelagency.com/resources/shopify-tricks/cart-permalinks

## In short

A Shopify cart permalink is a URL like your-store.com/cart/12345678901234:1 that fills the cart with that variant and quantity and opens checkout. Add more items with commas, a discount code with ?discount=CODE, and ?storefront=true to land on the cart page instead. It works on every plan without an app; selling plans are not supported.

## Facts

- **Format:** /cart/<variant ID>:<quantity>,…
- **Plan:** Every plan
- **Needs:** Numeric variant IDs
- **Status:** Legacy, still supported; successor: Cart and Checkout Permalinks (/buy/)
- **Last checked:** 2 November 2026

## How to use it

1. Find the variant ID: open the product in the admin, click the variant, and copy the number at the end of the URL.
2. Build the link: https://your-store.com/cart/<variant ID>:<quantity>. Separate several items with commas.
3. Add options as query parameters: discount=CODE, storefront=true for the cart page, checkout[email] to pre-fill the email.
4. Open the link in a private window to check the cart before you share it.

## Code

### cart-link-button.liquid

```liquid
{%- comment -%}
  A "Buy now" link for the product's selected variant, e.g. on a landing page.
  Use where `product` is available. routes.cart_url keeps the market's
  language path (/fr/cart), which cart permalinks support.
{%- endcomment -%}
{%- assign variant = product.selected_or_first_available_variant -%}
<a href="{{ routes.cart_url }}/{{ variant.id }}:1" class="button">Buy now</a>
```

### links.txt

```text
# One item: variant ID 12345678901234, quantity 1, straight to checkout
https://your-store.com/cart/12345678901234:1

# Two items, with a discount code applied
https://your-store.com/cart/12345678901234:1,12345678909876:2?discount=WELCOME10

# Fill the cart and open the cart page instead of checkout
https://your-store.com/cart/12345678901234:1?storefront=true

# Pre-fill the email and the shipping country at checkout
https://your-store.com/cart/12345678901234:1?checkout[email]=name@example.com&checkout[shipping_address][country]=Turkey
```

## Limits and edge cases

- The link replaces what is already in the cart.
- Products on a subscription (selling plan) can’t be added this way.
- Discount codes that contain a comma can’t be passed in the discount parameter.
- Links don’t get past a storefront password.
- Shopify now calls these links legacy and adds new features only to Cart and Checkout Permalinks (/buy/ links from the store’s UCP profile). The /cart/ format keeps working and is the one that supports line item properties and cart notes.

## Questions

### How do I make a Shopify link that adds a product to the cart?

Use your-store.com/cart/<variant ID>:<quantity>. It fills the cart with that variant and opens checkout; add ?storefront=true to open the cart page instead.

### Can a cart link apply a discount code?

Yes: add ?discount=CODE, or several codes separated by commas, to the end of the link.

### Where do I find the variant ID?

In the admin, open the product, click the variant; the number at the end of the page URL is the ID. On the storefront, /products/<handle>.js lists every variant with its id.

### Do cart permalinks work with Shopify Markets?

Yes. Put the market’s language path before /cart, such as /fr/cart/12345678901234:1, and the cart and checkout open in that language.

## Shopify documentation

- [Create cart permalinks](https://shopify.dev/docs/apps/build/checkout/create-cart-permalinks)
- [Cart and Checkout Permalinks](https://shopify.dev/docs/agents/carts-and-checkout/permalinks)

## Related

- [Add-to-cart links and buttons that keep the cart](https://lintelagency.com/resources/shopify-tricks/add-to-cart-links)
- [Discount links that apply a code automatically](https://lintelagency.com/resources/shopify-tricks/discount-links)
- [Find product, variant and customer IDs](https://lintelagency.com/resources/shopify-tricks/find-product-variant-customer-ids)
- [Selling in many currencies from one Shopify store](https://lintelagency.com/journal/shopify-markets-multi-currency)

License: MIT. Free to use in your own store and in client work.
