In WooCommerce, I'm trying to calculate the price of a variable product in the cart. I want to multiply the product price with some custom cart item numerical value.
Here is my code:
add_filter( 'woocommerce_cart_item_price', 'func_change_product_price_cart', 10, 3 );
function func_change_product_price_cart($price, $cart_item, $cart_item_key){
if (isset($cart_item['length'])){
$price = $cart_item['length']*(price of variation);
return $price;
}
}
The price calculation doesn't work. What I am doing wrong ?
$price
? – B001ᛦreturn $price*$cart_item['length'];
without the extra variable. – Dave