Buy All 46 Premium Themes For the Price Of $129.99

WooCommecre Get Order Items

How to get loop over order items

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

 foreach ( $order->get_items() as $item_id => $item ) {
   $product_id = $item->get_product_id(); // or $order_item['product_id'];
   $variation_id = $item->get_variation_id(); // or $order_item['variation_id'];
   $product = $item->get_product(); // get the associated product
   $name = $item->get_name();
   $quantity = $item->get_quantity(); // or $order_item['quantity'];
   $subtotal = $item->get_subtotal(); // Get subtotal
   $total = $item->get_total(); // item price
   $tax = $item->get_subtotal_tax();
   $taxclass = $item->get_tax_class();
   $taxstat = $item->get_tax_status();
   $allmeta = $item->get_meta_data();
   $somemeta = $item->get_meta( '_whatever', true );
   $type = $item->get_type(); // line_item | fee | shipping
}

 

Get order ID by order item ID.

wc_get_order_id_by_order_item_id(int $item_id);

Other Items

$order->get_items_key();
$order->get_items_tax_classes();
$order->get_item_count();
$order->get_item_total();
$order->get_downloadable_items();