I am trying to change product price in cart using the following function:
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price', 10);
function add_custom_price( $cart_obj ) {
foreach ( $cart_obj->get_cart() as $key => $value ) {
$item_data = $value['data'];
$price0 = $item_data->get_attributes('per_one_price');
$price = (int) $price0;
$value['data']->set_price( $num_int );
}
}
But for any number I set as product attribute value for per_one_price
attribute I get the number 1 in cart price.