Ik wil graag het winkelmandje met ID #cartcustom vernieuwen wanneer iemand op de button 'add to cart' klikt.
Wanneer ik onderstaande code gebruik, wordt de content binnen de div gedupliceerd ipv vernieuwd. Wanneer ik de knop nog een keer gebruik wordt het winkelmandje wel vernieuwd, maar loopt 1 achter op de telling.
Heeft iemand een idee?
javascript:
<script type="text/javascript" >
$('.woocommerce a.button.add_to_cart_button.ajax_add_to_cart').click(function(){
var $this = $(this);
$this.text('Toegevoegd aan lijst');
$('#cartcustom').load(document.URL + ' #cartcustom>*');
});
</script>
output:
<div id="cartcustom">
<a class="wcmenucart-contents" href="https://www.hetvignet.nl/aanvraag-patronen/" title="View your shopping cart">
<i class="fa fa-shopping-cart"></i>
6 items
</a>
<a class="wcmenucart-contents" href="https://www.hetvignet.nl/aanvraag-patronen/" title="View your shopping cart">
<i class="fa fa-shopping-cart"></i>
6 items
</a>
</div>