Reputation: 4286
I got this code:
global $woocommerce;
$items = $woocommerce->cart->get_cart();
$arr_product=array();
foreach($items as $item => $values) {
$arr_product[]= $_product->post_title;
}
It returns:
Array ( [0] => [1] => );
It should return the titles but instead I get these numbers. How do I solve this?
Upvotes: 2
Views: 6553
Reputation: 456
You should use:
WC()->cart->get_cart();
instead of `$woocommerce->cart->get_cart();`
Upvotes: 5