我在插件中遇到此问题,我设法解决了除此之外的所有错误.这是原始代码......
$products = WC()->cart->cart_contents;
$cartTitles = '';
foreach ($products as $product) {
$cartTitles .= $product['quantity'] . '-' . $product['data']->post->post_title;
}
Run Code Online (Sandbox Code Playgroud)
我在这里收到典型的通知信息 -
Post was called incorrectly. Properties should not be accessed directly.
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得帖子标题?我试过$product['data']->get_post()但它会触发错误.
谢谢.