Button in Klaviyo to add multiple items to cart in Shopify?

  • 27 September 2023
  • 1 reply


TL;DR: Does anyone have any ideas how to create an ADD ALL button in an email that will add multiple items to the cart in Shopify with a single click?


FULL EXPLANATION: I am building a replenishment flow in Klaviyo for our Shopify Store. It’s functioning well in that the email goes out to customers 60 days after their last order and it lists all items that they purchased previously.

When they click on an item in the email, it takes them straight to checkout. I have added an argument to the link that now takes them to the cart instead of checkout, which is what we want, but it does this one item at a time. 

I would like to add an REPLENISH ALL button to the email that will load their cart with multiple items from a previous purchase instead of the user need to add items one at a time. 

Thank you!

1 reply

Userlevel 7
Badge +60

Hey @Chris-J 

Welcome to the community and thanks for asking for help!

Generally, we have the best of luck in using a combination of template tags, a for loop, and an if-else loop. Most recently, I have had the below logic work for a customer who was trying to repopulate the entirety of a customer's order, down to the exact same quantity of an item, in their Flow email:

{{ organization.url }}/cart/update?{% for item in event.extra.line_items %}updates[{{ item.variant_id }}]={{ item.quantity|floatformat:0 }}{% if not forloop.last %}&{% endif %}{% endfor %}

The reason why this works is largely thanks to how Shopify allows us to reconstruct orders in the cart page. We can begin a for loop that continues until the final item in the order (i.e. {% if not forloop.last %}), where each loop includes the item's variant ID and quantity, which is added to the cart in the redirect. 

Hope this helps!