Question

I have a product designer on my woocommerce site and when someone goes to edit it, instead of it editing the current cart item, it creates a new one.

The problem is it also leaves the old one. I have the cart-item-key. How can I tell woocommerce to delete the old one after the new item is added? Without generating and making a user click the remove link...

Was it helpful?

Solution

I did this via an AJAX call.

<?php
global $woocommerce;
$removeUrl = $woocommerce->cart->get_remove_url();
?>
<script>
jQuery(document).ready(function($) {
    $.get( '<?php echo $removeUrl; ?>', function( data ) { /**/ });
});
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top