I have this problem in a plugin, I managed to solve all errors except this one. Here is the original code...
$products = WC()->cart->cart_contents;
$cartTitles = '';
foreach ($products as $product) {
$cartTitles .= $product['quantity'] . '-' . $product['data']->post->post_title;
}
I'm getting here the typical notice message -
Post was called incorrectly. Properties should not be accessed directly.
How can I get the post title? I tried with $product['data']->get_post()
but it triggers an error.
Thank you.
Try using