Skip to content
Log in

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

URL syntax

```css

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

Product string format

```text

```

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.

Go to checkout

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

Add to cart

Adds the product to the cart without redirecting to checkout.

Add to cart

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

Preserve current cart

Adds products without clearing the existing cart.

Add without clearing 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 variable pricing to be enabled on the price book entry. See Variable pricing for donations and tips.

Buy with custom price

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.

Add with promo code

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.

Add and stay on cart

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

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

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.

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

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

Pre-fill customer details

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.

Pre-fill with full address

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]

Add two products

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.

Combine multiple parameters

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

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

Buy Now ```

Buy it now button

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

Was this article helpful?

Was this article helpful?