I am working on woocommerce cart page with add_filter "woocommerce_in_cart_product_title", There I want to show price with title.
Like "Product title ($price)"
i have tried this code, but i can not get price.
add_filter( 'woocommerce_in_cart_product_title', 'cart_product_title', 20, 3);
function cart_product_title( $title, $values, $cart_item_key ) {
global $woocommerce;
$items = $woocommerce->cart->get_cart();
print_r($items);
foreach ($items as $cart_item_key => $values) {
echo $name = $values['prodaddons'][0]['name'].' --- ';
echo $price = $values['prodaddons'][0]['price'].'<br>';
}
echo 'aaaa-'.$title.'-'.$pricees;
}
try this :
I don't know your version of woocommerce but woocommerce_in_cart_product_title is depreciated, it's why I use woocommerce_cart_item_name, so you should try both ;)