Skip to main content

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!

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 %}updatese{{ 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!


Reply