Retrieve shipping method name of a given order

Public

Can be usefull whith a hook_commerce_checkout_complete.

</> CopyGet raw version
php
  1. $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  2. // Loop over all the line items on the order.
  3. foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
  4. // If the current line item is a shipping line item...
  5. if ($line_item_wrapper->type->value() == 'shipping') {
  6. // Return its label.
  7. $shipping_name = $line_item_wrapper->line_item_label->value();
  8. }
  9. }