I am using Woocommerce plugin and I want to add a functionalty where customer can edit product price in cart page. Here is my code
add_filter( 'woocommerce_cart_item_price', 'set_price_in_cart', 999999, 3 );
function set_price_in_cart( $price, $cart_item, $cart_item_key ) {
if (isset($cart_item['_tz_original_price'])){
$original_price = $cart_item['_tz_original_price'];
} else {
$original_price = $cart_item['data']->get_price();
}
$min = $original_price;
$attributes = apply_filters( 'salesking_cart_input', array(
'class' => 'input-text text',
'min' => $min,
'step' => '1',
) );
$field = sprintf( '<input type="number" name="cart[%s][_tz_edited_price]" value="%s" %s>',
$cart_item_key,
$cart_item['data']->get_price(),
implode( '', array_map( function( $key, $value ) {
return sprintf( ' %s="%s"', $key, $value );
}, array_keys( $attributes ), $attributes ) )
);
return $field;
}
With the above code I acheive the input field in price column.
But when customer edit the price and click Update button then noting happen. Can someone please help and guide me please