In this question WooCommerce: Add product to cart with price override? we can alter the price for all products in the cart.
What I need is to alter only products with Specific custom type called 'auction' and not change the rest of products.
Here is the code I use::
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
$custom_price = 10; // This will be your custome price
foreach ( $cart_object->cart_contents as $key => $value ) {
$value['data']->price = $custom_price;
}
}
I tried::
if ( $value['product_type'] == 'auction') {
$value['data']->price = $custom_price;
}