All Collections
Advanced Topics
Abandoned checkouts
How to build a prefilled (discounted) cart
How to build a prefilled (discounted) cart

Learn how to load a cart page that contains specific products, optionally with a Discount Ninja promotion applied

Bart Coppens avatar
Written by Bart Coppens
Updated over a week ago

Not sure how to edit your theme? Read this article first.


  • Open your theme

  • Click "Add a new template":

  • Select the template type "cart" and provide a name. In this example, we're using prefill. You can use a different name if you prefer.

  • Make sure to select "Liquid", not "JSON"

  • Replace the content of the newly created template with the following:

<!doctype html>
<script type="text/javascript">
document.addEventListener("la:dn:promotions:loaded", function() {
  • Click "Save"


You can now send your customers to a prefilled cart using a URL that has the following format:

This URL has the following required components:

  • replace this with the domain of your shop

  • /cart?view=: this part is mandatory

  • prefill: this is the name of the template; if you selected a different template name use it here

  • &variants=: this part is mandatory and requires a comma-separated list of the variant id of the product variants you want to add to the cart; for each variant you'll need to specify the quantity. Example: to add 2 of variant 1234567 and 1 of variant 2345678 use &variants=1234567x2,2345678x1

Additionally, you can add a token to the URL to trigger a Discount Ninja promotion that has a shareable link. If the trigger of your promotion is ABCDE then the link becomes:

Finally, you can define which page should be loaded once the cart is prefilled using a redirecturl parameter. By default the link will send customers to the cart page. If you want customers to land on the collections page instead you could use:


This approach:

  • clears the cart first

  • then adds the specified variants

This ensures the content of the cart will always be as defined in the URL, independent of what a customer had already added to the cart before.

Did this answer your question?