Guest User

Untitled

a guest
May 25th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. //If you want to get Product id from order id in Woocommerce then fetch order details.
  2.  
  3. $order = new WC_Order( $order_id );
  4. $items = $order->get_items();
  5. //then if you loop through them, you can get all the relevant data:
  6.  
  7. foreach ( $items as $item ) {
  8. $product_name = $item['name'];
  9. $product_id = $item['product_id'];
  10. $product_variation_id = $item['variation_id'];
  11. }
Add Comment
Please, Sign In to add comment