Get product detail from order line

Public
</> CopyGet raw version
php
  1. function MYMODULE_commerce_checkout_complete($order) {
  2.  
  3. $order_lines = field_get_items('commerce_order', $order, 'commerce_line_items');
  4.  
  5. // Line item IDs
  6. $line_item_ids = array();
  7. foreach ($order_lines as $order_line) {
  8. $line_item_ids[] = $order_line['line_item_id'];
  9. }
  10.  
  11. // Load line item details
  12. $line_items = commerce_line_item_load_multiple($line_item_ids);
  13.  
  14. // Get the product IDs
  15. $product_ids = array();
  16. foreach ($line_items as $line_item) {
  17. $tmp = field_get_items('commerce_line_item', $line_item, 'commerce_product');
  18. $product_ids[] = $tmp[0]['product_id'];
  19. }
  20.  
  21. // Load all to get product details
  22. $products = commerce_product_load_multiple($product_ids);
  23. }