# Direct to cart link

Source: https://support.storeconnect.com/articles/direct-to-cart · Last modified 21 August 2026

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 personalized checkout when combined with customer information.

## URL syntax

```css

[store domain]{/path}/cart/[product string]?[other-parameters]
```

### Product string format

```text

[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) or `buy` (go to checkout). Default: `buy`. |
| `preserve` | If `true`, preserves the existing cart contents. |
| `return` | Redirect behavior after the 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.

Here `RSK-MC-22` is the product code and `1` is the quantity to purchase, so the product string is `RSK-MC-22:1`.

### Direct to checkout

Sends a customer directly to checkout with a product in their cart.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy" target="_blank" rel="noopener noreferrer">Go to checkout</a>

```
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy
```

### Add to cart

Adds the product to the cart without redirecting to checkout.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add" target="_blank" rel="noopener noreferrer">Add to cart</a>

```
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add
```

### Preserve current cart

Adds products without clearing the existing cart.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy&preserve=true" target="_blank" rel="noopener noreferrer">Add without clearing cart</a>

```
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 variable pricing to be enabled on the price book entry. See [Variable pricing for donations and tips](variable-pricing).

<a href="https://storeconnectdemo.com/cart/bold-product-the-competition-kettlebell-set:1:35000?type=buy" target="_blank" rel="noopener noreferrer">Buy with custom price</a>

```
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.

<a href="https://storeconnectdemo.com/cart/commercial-flat-press-bench:1?type=add&code=10OFFGYM" target="_blank" rel="noopener noreferrer">Add with promo code</a>

```
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.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add&return=true" target="_blank" rel="noopener noreferrer">Add and return to previous page</a>

```
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.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add&return=false" target="_blank" rel="noopener noreferrer">Add and stay on cart</a>

```
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.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add&return=https://storeconnectdemo.com/bike" target="_blank" rel="noopener noreferrer">Add and redirect to custom URL</a>

```
https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add&return=https://storeconnectdemo.com/bike
```

### Pre-fill from an existing contact (`cid`)

If the customer already exists in StoreConnect as a contact, pass their StoreConnect contact ID (`sc__sc_id__c`) as `cid` to pre-fill their details at checkout.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9" target="_blank" rel="noopener noreferrer">https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9</a>

```
https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9
```

You can also load details from the contact but override specific fields: explicit parameters always take precedence over the values loaded from `cid`.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9&email=newemail@example.com" target="_blank" rel="noopener noreferrer">https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9&email=newemail@example.com</a>

```
https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9&email=newemail@example.com
```

In this example all contact details are loaded from Salesforce except the email, which is overridden by the value in the URL. This applies to any of the customer information parameters.

:::warning
`cid` only pre-fills the checkout form. It does not attach the order to that exact contact, and it does not log the customer in. When the shopper reaches checkout, the order is still matched to a contact using the email and name matching rules, not the `cid`. If the pre-filled email matches a different existing contact, the order is associated with that matched contact. See [Automated lead conversion to avoid duplication](lead-contact-and-account-deduplication) for the matching rules.

To guarantee that an order is associated with one specific contact regardless of any email collision, the shopper must be logged in to StoreConnect for that checkout.
:::

### Pre-fill details (no contact record)

Pass customer information directly into the checkout session. This is useful for anonymous or first-time customers.

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob&lname=Smith&email=bobsmith@example.com" target="_blank" rel="noopener noreferrer">Pre-fill customer details</a>

```
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.

<a href="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" target="_blank" rel="noopener noreferrer">Pre-fill with full address</a>

```
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\]

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1,RSK-MC-21:3?type=add" target="_blank" rel="noopener noreferrer">Add two products</a>

```
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.

<a href="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" target="_blank" rel="noopener noreferrer">Combine multiple parameters</a>

```
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>
```

<a href="https://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob&lname=Smith" target="_blank" rel="noopener noreferrer"><img src="https://res.cloudinary.com/hzkr6fi81/image/upload/v1781677749/documentation-media/direct-to-cart/buy_it_now.jpg" alt="Buy it now button" /></a>

## Rules for direct to cart links

-   The default action type is `buy`, which sends the customer directly to checkout. Use `type=add` to add products to the cart without redirecting.
-   By default, the cart is cleared before adding products from the link. Use `preserve=true` to 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.

---

## Follow StoreConnect

- [Email Newsletter](https://getstoreconnect.com/c/lp-newsletter)
- [LinkedIn Newsletter](https://www.linkedin.com/build-relation/newsletter-follow?entityUrn=7444956928444862464)
- [YouTube](https://www.youtube.com/channel/UCngKdP2x8l1wcbAKW3tvU8g)
- [LinkedIn](https://www.linkedin.com/company/storeconnect)
- [X / Twitter](https://x.com/storeconnecthq)

## Popular Links

- [Partners](https://getstoreconnect.com/partners)
- [News](https://getstoreconnect.com/articles/news)
- [Events](https://getstoreconnect.com/articles/events)
- [Feature Comparison](https://getstoreconnect.com/how-we-compare)
- [Download a free trial](https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FMkeKUAT)
- [Book a Demo](https://getstoreconnect.com/contact)

## Documentation

- [Help documentation](https://support.storeconnect.com/help-documentation)
- [AI agents](https://support.storeconnect.com/ai)
- [Videos & tutorials](https://support.storeconnect.com/videos-tutorials)
- [Developer reference](https://support.storeconnect.com/developer-reference)
- [Release notes](https://support.storeconnect.com/release-notes)
- [Troubleshooting](https://support.storeconnect.com/troubleshooting)
- [Trust Center](https://trust.getstoreconnect.com/)
- [Status Page](https://status.storeconnect.com/)

## Contact

- info@getstoreconnect.com
- US +1 415 745 3230
- AUS +61 2 8365 2308

100 S Ashley Dr, Suite 600-2461
Tampa FL 33602-600 USA

Level 22, Sydney Place
180 George Street
Sydney, NSW, 2000, AUS

---

StoreConnect Support — https://support.storeconnect.com/articles/direct-to-cart