Marketing

This guide explains how to build a URL that adds a specific product to the cart with a defined quantity and opens the cart automatically.

🛠 How to Create the URL Parameter for a Product

This guide explains how to build a URL that adds a specific product to the cart with a defined quantity and opens the cart automatically.


1. Gather What You Need

You’ll need the following:

  • listingId: The product ID
  • variantId: The specific version of the product (e.g., size, color)
  • quantity: How many of the item to add

2. Create the Item Key

The item key format is:

[listingId].[variantId]

For example:

123.456

3. Package It with Quantity

Create an object that looks like this:

{ "123.456": 2 }

This means: "Add 2 of item 123.456 to the cart."


4. Turn It Into a URL

Convert the object to a Base64-encoded string. The final URL format is:

?session=BASE64_STRING&open=true

Example:

?session=eyIxMjMuNDU2IjoyfQ==&open=true

When someone clicks this link, the cart will open with the item already added.


✅ Example

Inputs:

  • listingId: 123
  • variantId: 456
  • quantity: 2

Result:

?session=eyIxMjMuNDU2IjoyfQ==&open=true

This adds 2 of product 123, variant 456, to the cart and opens it automatically.