Direct to cart link
On this page
Direct to Cart is a flexible URL format that allows products to be added to the cart or sent directly to checkout from anywhere — including articles, emails, buttons, and clickable images.
This feature makes it easy to build seamless eCommerce experiences – from donation buttons in emails to one-click product links in articles. It also provides personalised checkout when combined with customer information.
URL syntax
css
[store domain]{/path}/cart/[product string]?[other-parameters]
Product string format
liquid
[sfid or slug or product code]:[quantity]{:[custom price]}
Products can be identified using any of the following:
| Identifier | Example |
|---|---|
| Product code | RSK-MC-22 |
| Product slug | commercial-flat-press-bench |
| Salesforce ID (SFID) | a1GMn00000ABC1234 |
Supported parameters
| Parameter | Description |
|---|---|
| type | Action to perform: add (add to cart), buy (go to checkout). Default: buy. |
| preserve | If true, preserves the existing cart contents. |
| return | Redirect behavior after action. Options: true (referrer), false (stay on site), or a callback URL. |
| code | Promotion Code (case-sensitive). |
| cid | Contact ID (sc__sc_id__c) of a known Salesforce Contact. |
| fname, lname, email, phone, street, city, state, country, postcode | Pre-fill customer information. Values are used at checkout. |
See it in action
In the below example we are sending a customer directly to the checkout to purchase a product.
Where, RSK-MC-22 is the product code and 1 is the quantity to purchase, the product string would be RSK-MC-22:1
Direct to checkout
Sends a customer directly to checkout with a product in their cart.
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy
Add to cart
Adds the product to the cart without redirecting to checkout.
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add
Preserve current cart
Adds products without clearing the existing cart.
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy&preserve=true
:::note By default, the direct to cart feature clears the cart and adds only the products included in the link. :::
Variable pricing
Override the product price using the Price Book’s variable pricing. (Requires Pricebook Variable Pricing being enabled)
https://storeconnectdemo.com/cart/bold-product-the-competition-kettlebell-set:1:35000?type=buy
:::note 35000 represents $350.00 (value is in cents). :::
Apply a promotion code
Applies a case-sensitive promotion code to the checkout session via the URL.
https://storeconnectdemo.com/cart/commercial-flat-press-bench:1?type=add&code=10OFFGYM
Return to the referring page
Adds a product and sends the customer back to where they came from. Useful for email campaigns or external landing pages.
Add and return to previous page
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add&return=true
Stay on the store after adding to cart
Adds a product and keeps the customer on the cart page without redirecting.
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add&return=false
Redirect to a custom URL
Adds a product and redirects the customer to a specific page after the action completes.
Add and redirect to custom URL
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add&return=https://storeconnectdemo.com/bike
Pre-fill details (no contact record)
Pass customer information directly into the checkout session — useful for anonymous or first-time customers.
https://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob&lname=Smith&email=bobsmith@example.com
:::note
Use fname and lname to provide the customer’s first and last name separately.
Example: ?fname=Bob&lname=Smith
:::
Pre-fill with full address
Pass all available customer information including billing address fields to fully pre-populate the checkout form.
https://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob&lname=Smith&email=bobsmith@example.com&phone=0400000000&street=123+Pitt+St&city=Sydney&state=NSW&country=AU&postcode=2000
Add multiple products
You can also add multiple products to the cart in a single link, by adding a comma between
[sfid or slug or product code]:[quantity],[sfid or slug or product code]:[quantity]
https://storeconnectdemo.com/cart/RSK-MC-22:1,RSK-MC-21:3?type=add
Combining multiple parameters
All parameters can be combined in a single URL. This example adds two products, preserves the existing cart, applies a promotion code, and pre-fills customer details before sending the customer to checkout.
https://storeconnectdemo.com/cart/commercial-flat-press-bench:1,RSK-MC-21:2?type=buy&preserve=true&code=10OFFGYM&fname=Bob&lname=Smith&email=bobsmith@example.com
Direct to cart image links
Any Direct to Cart URL can be used as the href of an image element to turn it into a Buy Button, ideal for email campaigns or landing pages.
html
<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy">
<img src="https://example.com/buy-now-button.jpg" alt="Buy Now">
</a>
Important notes
-
The default action type is
buy, which sends the customer directly to checkout. Usetype=addto add products to the cart without redirecting. -
By default, the cart is cleared before adding products from the link. Use
preserve=trueto keep existing cart contents. -
If a bundled product is included in a direct-to-cart link, the customer is redirected to the product page instead. Bundles and Bookings are not supported through direct-to-cart URLs.
-
URLs must be URL encoded if constructed dynamically (e.g. using JavaScript or Salesforce Flows).
-
Promotion codes are case sensitive.
-
Custom pricing only works with products that support Variable Pricing in the Price Book.
