V
V
vadbobkov2019-01-11 20:59:04
WordPress
vadbobkov, 2019-01-11 20:59:04

How to get the ID of the product that is in the cart in Woocommerce?

Good evening. How can I implement the display of the ID of the product that is in the basket? For example, on a separate page, display the following information:
Added product with ID: 24
Only one product is added to the cart

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Riclud, 2019-10-25
@Riclud

global $woocommerce;
foreach ($woocommerce->cart->get_cart() as $item):
        echo $item['product_id'];
        
endforeach;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question