Have error 500 if in cart have more products if have one is okay.
Fix IT with this!
<script type="text/javascript">
$("form.checkout").on("change", "input.qty", function () {
$.ajax({
url: '\/wp-admin\/admin-ajax.php',
data: {
action: 'cqoc_update_order_review',
security: wc_checkout_params.update_order_review_nonce,
post_data: $('form.checkout').serialize()
},
type: 'post',
success: function (response) {
console.log(response);
$('body').trigger('update_checkout');
}
});
});
</script>
function cqoc_update_order_review() {
$values = array();
parse_str($_POST['post_data'], $values);
$cart = $values['cart'];
print_r($cart);
$cart_updated = false;
foreach ($cart as $cart_item_key => $cart_value) {
$passed_validation = apply_filters('woocommerce_update_cart_validation', true, $cart_item_key, $values, $quantity);
if ($passed_validation) {
WC()->cart->set_quantity($cart_item_key, $cart_value['qty'], false);
$cart_updated = true;
}
// woocommerce_cart_totals();
}
// Trigger action - let 3rd parties update the cart if they need to and update the $cart_updated variable.
$cart_updated = apply_filters('woocommerce_update_cart_action_cart_updated', $cart_updated);
if ($cart_updated) {
WC()->cart->calculate_totals();
}
exit;
}