How we can get the complete cart details from the order id in woocommerce including the totals and subtotals etc.

3 Answers 3


Try this:

    global $woocommerce;
    $items = $woocommerce->cart->get_cart();
  • Not sure how this could be the accepted answer, as I know $woocommerce->cart->get_cart() will return the cart from the "current" session, but the question is about how to get the details (including totals and items) for exist (old) order!
    – Walid Ajaj
    Dec 20, 2021 at 12:07

You can get order's cart details from the order object.

if you only have the id, you can get $order object like this:

// Get $order object from order ID
$order = wc_get_order( $order_id );

to get order's details:

if ( $order ) {

    // Get Order Totals $0.00
    // etc.
    // etc.

    // Get and Loop Over Order Items
    foreach ( $order->get_items() as $item_id => $item ) {
       $product_id = $item->get_product_id();
       $variation_id = $item->get_variation_id();
       // etc.
       // etc.

You can refer to this link for more details: https://www.businessbloomer.com/woocommerce-easily-get-order-info-total-items-etc-from-order-object/


Another variant:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.