Fixed Custom Value you want to add in All product
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
$custom_price = 100; //Custom price you want to add
$value['data']->price = $value['data']->price + $custom_price;
}
Add an Extra Cost ( 10% of Actual Price ) based on SIZE Attribute
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
foreach ( $cart_object->cart_contents as $key => $value ) {
$p_size = $value['variation'][attribute_pa_size];//Get Attribute size
if($p_size >= 44)
{
$c_price = $value['data']->price;
$cp_10 = $c_price * 10/100;
$value['data']->price = $value['data']->price + $cp_10;
}
}
}
It just an example you can use any attribute or any condition