Solution:
Are you trying to change the price custom way before sending to the cart if yes then you need to send by session the below two hooks will help a lot
add_filter( 'woocommerce_add_cart_item' , 'set_woo_prices');
add_filter( 'woocommerce_get_cart_item_from_session', 'set_session_prices', 20 , 3 );
function set_woo_prices( $woo_data ) {
session_start();
$tac_dd_discounted_price = $_SESSION['']; // get the updated new price field
if ( ! isset($tac_dd_discounted_price ) || empty ($tac_dd_discounted_price ) ) { return $woo_data; }
$woo_data['data']->set_price( $tac_dd_discounted_price );
$woo_data['my_price'] = $tac_dd_discounted_price;
return $woo_data;
}
function set_session_prices ( $woo_data , $values , $key ) {
if ( ! isset( $woo_data['my_price'] ) || empty ( $woo_data['my_price'] ) ) { return $woo_data; }
$woo_data['data']->set_price( $woo_data['my_price'] );
return $woo_data;
}