less than a minute read • Updated 9 minutes ago
Add an empty cart button to the cart and checkout
How to add a button that lets customers empty their cart from the cart or checkout.
Step 1: Apply the snippet to your configuration
In the Foxy admin (https://admin.foxy.io), go to Settings > Templates and add the code to the Custom footer field (Twig is supported; it is injected before the closing </body> tag).
{% if cart_is_fullpage or context == "checkout" %}
<script>
FC.client.on('ready.done', addEmptyCartFull);
FC.client.on('render.done', addEmptyCartFull);
function addEmptyCartFull() {
var empty_cart = 'https://'+FC.settings.storedomain+'/cart?cart=empty';
if (!$('#cart_empty').html()) {
$('.fc-cancel-continue-shopping.fc-container__grid').append("<span id='cart_empty'><a href=" + empty_cart + " class='fc-button fc-button--cancel'>Empty Cart</a></span>");
}
}
</script>
{% elseif context == "cart" %}
<script>
FC.client.on('render.done', addEmptyCartSide);
function addEmptyCartSide() {
var empty_cart = 'https://'+FC.settings.storedomain+'/cart?cart=empty';
if (!$('#cart_empty').html()) {
$('#fc .fc-cart__title__header').after("<div id='cart_empty'><a href="+ empty_cart + " class='fc-button fc-button--cancel'>Empty Cart</a></div>");
}
}
</script>
{% endif %}Step 2: Customize conditions
You may modify this code to only show the button on the checkout or cart as desired. Please contact us if you need assistance in doing so.