0
votes

I'm just a beginner on woocommerce and

just want to ask if how am I able to show 'current product items' on shopping cart?

I can't find on their documentation, only I've found the 'total number of items' currently on cart

but my question is 'the item lists' on the current cart with their corresponding thumbnails, quantity and price (single product price).

Thank you for future answers.

1

1 Answers

0
votes

This code will iterate through all products in the cart and get all the required data:

foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
    $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
    $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
    $quantity = $_product->get_stock_quantity();
    $product_subtotal = apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key );
}