function commerce_license_get_order_licenses in Commerce License 7
Returns all licenses found on an order.
Parameters
$order: The order entity.
$configurable: Whether to only take configurable licenses.
Return value
An array of all found licenses, keyed by license id.
6 calls to commerce_license_get_order_licenses()
- commerce_license_activate_order_licenses in ./
commerce_license.module - Activates all licenses of the provided order.
- commerce_license_commerce_order_update in ./
commerce_license.module - Implements hook_commerce_order_update().
- commerce_license_complete_checkout_form in includes/
commerce_license.checkout_pane.inc - Checkout pane callback: License completion message.
- commerce_license_information_checkout_form in includes/
commerce_license.checkout_pane.inc - Checkout pane callback: License edit.
- commerce_license_information_checkout_form_submit in includes/
commerce_license.checkout_pane.inc - Checkout pane callback: license edit pane submit callback.
File
- ./
commerce_license.module, line 538 - Provides a framework for selling access to local or remote resources.
Code
function commerce_license_get_order_licenses($order, $configurable = FALSE) {
$licenses = array();
$wrapper = entity_metadata_wrapper('commerce_order', $order);
foreach ($wrapper->commerce_line_items as $line_item_wrapper) {
$field_instances = field_info_instances('commerce_line_item', $line_item_wrapper
->getBundle());
foreach ($field_instances as $field_name => $field_instance) {
$field_info = field_info_field($field_name);
if ($field_info['type'] === 'entityreference' && $field_info['settings']['target_type'] == 'commerce_license' && isset($line_item_wrapper->{$field_name})) {
$license = $line_item_wrapper->{$field_name}
->value();
if ($license && (!$configurable || $license
->isConfigurable())) {
$licenses[$license->license_id] = $license;
}
}
}
}
return $licenses;
}