Skip to content

Instantly share code, notes, and snippets.

@zenith6
Created January 20, 2015 13:53
Show Gist options
  • Select an option

  • Save zenith6/8afd1afb901d37fad41a to your computer and use it in GitHub Desktop.

Select an option

Save zenith6/8afd1afb901d37fad41a to your computer and use it in GitHub Desktop.
Drupal Commerce 注文データから項目を取得する
<?php
$order = /* order object */;
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$items = [];
foreach ($wrapper->commerce_line_items as $line_item) {
$items[] = [
'type' => $line_item->type->value(), # Product type machine name
'line_item_label' => $line_item->line_item_label->value(), # SKU
'quantity' => $line_item->quantity->value(), # Quantity
];
}
// dd($items);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment