add quantity select to woocommerce shopping cart widget

Viewed 35

i like to give the clients an option to add more product in the woocommerce shopping cart widget.

so far i managed to find this code:

add_filter( 'woocommerce_widget_cart_item_quantity', 'add_minicart_quantity_fields', 10, 3 );
function add_minicart_quantity_fields( $html, $cart_item, $cart_item_key ) {
    $product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $cart_item['data'] ), $cart_item, $cart_item_key );

    return woocommerce_quantity_input( array('input_value' => $cart_item['quantity']), $cart_item['data'], false ) . $product_price;
}

the code make the quantity select visible in the shopping cart. but the issue is when we change the quantity, no changes take place... If i understand correctly i should add a Ajax request to change the product's quantity when the user add or remove products.

0 Answers
Related