{"title":"Direct to cart link","slug":"direct-to-cart","url":"https://support.storeconnect.com/articles/direct-to-cart","url_markdown":"https://support.storeconnect.com/articles/direct-to-cart.md","subtitle":null,"summary":"Build URLs that add products to a cart or send customers straight to checkout. Supports multiple products, variable pricing, promotion codes, pre-filled customer details, and image-based buy buttons.","type":"Help_Documentation","video_url":"","keywords":"direct to cart, cart url, add to cart link, buy button, checkout url, url parameters, promotion code, variable pricing, pre-fill checkout, multiple products, image buy button, one-click purchase","last_modified":"2026-08-21T07:12:35+0000","body_markdown":"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.\n\nThis 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.\n\n## URL syntax\n\n```css\n\n[store domain]{/path}/cart/[product string]?[other-parameters]\n```\n\n### Product string format\n\n```text\n\n[sfid or slug or product code]:[quantity]{:[custom price]}\n```\n\nProducts can be identified using any of the following:\n\n| Identifier   | Example                                |\n|--------------|----------------------------------------|\n| Product code | `RSK-MC-22`                          |\n| Product slug | `commercial-flat-press-bench`        |\n| Salesforce ID (SFID) | `a1GMn00000ABC1234`          |\n\n## Supported parameters\n\n| Parameter | Description |\n|-----------|-------------|\n| `type` | Action to perform: `add` (add to cart) or `buy` (go to checkout). Default: `buy`. |\n| `preserve` | If `true`, preserves the existing cart contents. |\n| `return` | Redirect behavior after the action. Options: `true` (referrer), `false` (stay on site), or a callback URL. |\n| `code` | Promotion code (case-sensitive). |\n| `cid` | Contact ID (`sc__sc_id__c`) of a known Salesforce contact. |\n| `fname`, `lname`, `email`, `phone`, `street`, `city`, `state`, `country`, `postcode` | Pre-fill customer information. Values are used at checkout. |\n\n## See it in action\n\nIn the below example we are sending a customer directly to the checkout to purchase a product.\n\nHere `RSK-MC-22` is the product code and `1` is the quantity to purchase, so the product string is `RSK-MC-22:1`.\n\n### Direct to checkout\n\nSends a customer directly to checkout with a product in their cart.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eGo to checkout\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy\n```\n\n### Add to cart\n\nAdds the product to the cart without redirecting to checkout.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eAdd to cart\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?type=add\n```\n\n### Preserve current cart\n\nAdds products without clearing the existing cart.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy\u0026preserve=true\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eAdd without clearing cart\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy\u0026preserve=true\n```\n\n:::note\nBy default, the direct to cart feature clears the cart and adds only the products included in the link.\n:::\n\n### Variable pricing\n\nOverride 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).\n\n\u003ca href=\"https://storeconnectdemo.com/cart/bold-product-the-competition-kettlebell-set:1:35000?type=buy\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eBuy with custom price\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/bold-product-the-competition-kettlebell-set:1:35000?type=buy\n```\n\n:::note\n35000 represents $350.00 (value is in cents).\n:::\n\n### Apply a promotion code\n\nApplies a case-sensitive promotion code to the checkout session via the URL.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/commercial-flat-press-bench:1?type=add\u0026code=10OFFGYM\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eAdd with promo code\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/commercial-flat-press-bench:1?type=add\u0026code=10OFFGYM\n```\n\n### Return to the referring page\n\nAdds a product and sends the customer back to where they came from. Useful for email campaigns or external landing pages.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add\u0026return=true\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eAdd and return to previous page\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?type=add\u0026return=true\n```\n\n### Stay on the store after adding to cart\n\nAdds a product and keeps the customer on the cart page without redirecting.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add\u0026return=false\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eAdd and stay on cart\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?type=add\u0026return=false\n```\n\n### Redirect to a custom URL\n\nAdds a product and redirects the customer to a specific page after the action completes.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?type=add\u0026return=https://storeconnectdemo.com/bike\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eAdd and redirect to custom URL\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?type=add\u0026return=https://storeconnectdemo.com/bike\n```\n\n### Pre-fill from an existing contact (`cid`)\n\nIf 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.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9\" target=\"_blank\" rel=\"noopener noreferrer\"\u003ehttps://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9\n```\n\nYou can also load details from the contact but override specific fields: explicit parameters always take precedence over the values loaded from `cid`.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9\u0026email=newemail@example.com\" target=\"_blank\" rel=\"noopener noreferrer\"\u003ehttps://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9\u0026email=newemail@example.com\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?cid=00a65a01-aee2-452c-8e64-99225029baa9\u0026email=newemail@example.com\n```\n\nIn 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.\n\n:::warning\n`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.\n\nTo 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.\n:::\n\n### Pre-fill details (no contact record)\n\nPass customer information directly into the checkout session. This is useful for anonymous or first-time customers.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob\u0026lname=Smith\u0026email=bobsmith@example.com\" target=\"_blank\" rel=\"noopener noreferrer\"\u003ePre-fill customer details\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob\u0026lname=Smith\u0026email=bobsmith@example.com\n```\n\n:::note\nUse `fname` and `lname` to provide the customer’s first and last name separately.\n\nExample: `?fname=Bob\u0026lname=Smith`\n:::\n\n### Pre-fill with full address\n\nPass all available customer information including billing address fields to fully pre-populate the checkout form.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob\u0026lname=Smith\u0026email=bobsmith@example.com\u0026phone=0400000000\u0026street=123+Pitt+St\u0026city=Sydney\u0026state=NSW\u0026country=AU\u0026postcode=2000\" target=\"_blank\" rel=\"noopener noreferrer\"\u003ePre-fill with full address\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob\u0026lname=Smith\u0026email=bobsmith@example.com\u0026phone=0400000000\u0026street=123+Pitt+St\u0026city=Sydney\u0026state=NSW\u0026country=AU\u0026postcode=2000\n```\n\n### Add multiple products\n\nYou can also add multiple products to the cart in a single link, by adding a comma between \n\n\\[sfid or slug or product code\\]:\\[quantity\\],\\[sfid or slug or product code\\]:\\[quantity\\]\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1,RSK-MC-21:3?type=add\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eAdd two products\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/RSK-MC-22:1,RSK-MC-21:3?type=add\n```\n\n### Combining multiple parameters\n\nAll 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.\n\n\u003ca href=\"https://storeconnectdemo.com/cart/commercial-flat-press-bench:1,RSK-MC-21:2?type=buy\u0026preserve=true\u0026code=10OFFGYM\u0026fname=Bob\u0026lname=Smith\u0026email=bobsmith@example.com\" target=\"_blank\" rel=\"noopener noreferrer\"\u003eCombine multiple parameters\u003c/a\u003e\n\n```\nhttps://storeconnectdemo.com/cart/commercial-flat-press-bench:1,RSK-MC-21:2?type=buy\u0026preserve=true\u0026code=10OFFGYM\u0026fname=Bob\u0026lname=Smith\u0026email=bobsmith@example.com\n```\n\n## Direct to cart image links\n\nAny 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.\n\n```html\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?type=buy\"\u003e\n  \u003cimg src=\"https://example.com/buy-now-button.jpg\" alt=\"Buy Now\"\u003e\n\u003c/a\u003e\n```\n\n\u003ca href=\"https://storeconnectdemo.com/cart/RSK-MC-22:1?fname=Bob\u0026lname=Smith\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\u003cimg src=\"https://res.cloudinary.com/hzkr6fi81/image/upload/v1781677749/documentation-media/direct-to-cart/buy_it_now.jpg\" alt=\"Buy it now button\" /\u003e\u003c/a\u003e\n\n## Rules for direct to cart links\n\n-   The default action type is `buy`, which sends the customer directly to checkout. Use `type=add` to add products to the cart without redirecting.\n-   By default, the cart is cleared before adding products from the link. Use `preserve=true` to keep existing cart contents.\n-   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.\n-   URLs must be URL encoded if constructed dynamically (e.g. using JavaScript or Salesforce Flows).\n-   Promotion codes are case sensitive.\n-   Custom pricing only works with products that support variable pricing in the price book."}