looks to not be working as of recent. don’t know when this stopped working, but this was the way we programmatically removed a discount code when an ‘X’ button was clicked on the /cart template. Anyone had success with other endpoints?
referenced this
and ended up using this code and it works:
document.getElementById('remove-button').addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
fetch('/cart/update.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
discount: ''
})
})
.then(res => res.json())
.then(cart => {
console.log('discount removed:', cart);
window.location.href = '/cart';
});
});
but ya, seems like the GET url version like /discount/none?redirect=/cart doesn’t seem to work anymore. still curious if anyone is using a cart endpoint that works tho