I have this problem in a plugin, I managed to solved 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;
}

Im 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.

Read more here: How to get product title in cart in new woocommerce 3.x


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: