$cart_item = $woocommerce->cart->get_cart();
I have the above code.
if I run print_r on cart_item I get a multi dimensional array:
Array( [a6292668b36ef412fa3c4102d1311a62] => Array ( [product_id] => 6803
How do I get the product_id only?
I tried $test =
To get the
product IDof each cart item in the foreach loop (for a simple product):
If it's a variable product, to get the
Or for both cases (where
WC_ProductObject in Woocommerce 3+):
1) Breaking the loop (Just to get the first item ID (product ID) of cart):
You can use directly
$product_idvariable of the first item in cart.
2) Using an array of product IDs (one for each item in cart).
To check product categories or product tags in cart item use WordPress