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.
Direct to cart links will not work for complex products like Bundles and Bookings.
URL syntax
[store domain]{/path}/cart/[product string]?[other-parameters]
Product string format
[sfid or slug or product code]:[quantity]{:[custom price]}
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. |
| name, 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
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/RSK-MC-22:1:35000?type=buy
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
Pre-fill from existing contact
If the user already exists in Salesforce as a Contact, this parameter fills in their details at checkout.
https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9
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
You can provide the customer’s name using either:fname and lname (recommended), which let you explicitly define the first and last namese.g. ?fname=Bob&lname=Smithorname, which accepts a full name in a single value — the first word will be used as the First Name and the rest as the Last Namee.g. ?name=Bob Smith Johnson → First Name: Bob, Last Name: Smith Johnson
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
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.
Important notes
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
