WooCommerce Setting Quantity in Checkout Using AJAX
<p>I'm trying to get a website I'm working on to update the cart using AJAX instead of having to use the 'Update Cart' button in WooCommerce but I'm running into an issue and I don't know why?</p>

<p>Essentially I have the following function:</p>

<pre><code>function kino_update_quantity() {
    $cart = WC()-&gt;cart;
    $value = $_POST['quantity'];
    $product = $_POST['product'];
    $cart-&gt;set_quantity($product, $value, true);
    echo json_encode($cart-&gt;total);
    wp_die();
}
</code></pre>

<p>I expect this function to take an product and quantity from the $_POST variables, set the quantity on this, then return a new total price.</p>

<p>However it's returning a total of 0, this is obviously incorrect. If I refresh the page however the totals have all been updated correctly. Also if I turn the boolean to false on the set_quantity call it returns the original total as expected.</p>

<p>I'm confused by this and any help on this issue would be of great use.</p>