function commerce_file_line_item_owner in Commerce File 7
Retrieve the owner account for a line item
2 calls to commerce_file_line_item_owner()
- commerce_file_license_line_item_update_state in includes/
commerce_file.entities.inc - Update the state of licenses for files on a line item
- commerce_file_license_line_item_update_status in includes/
commerce_file.entities.inc - Update the state of licenses for files on a line item
File
- ./
commerce_file.module, line 1340 - Provides integration of file licenses with Commerce
Code
function commerce_file_line_item_owner($line_item, $order = NULL) {
$line_item_id = $line_item->line_item_id;
// exit if we issued this already
if (empty($line_item->line_item_id)) {
return;
}
// wrap the line
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$line_item_wrapper = _commerce_file_clean_line_item_wrapper($line_item_wrapper);
// resolve order needed to determine order owner
if (empty($order)) {
// attempt to load order off of line item
$order = commerce_order_load($line_item->order_id);
if (empty($order)) {
return;
}
}
// wrap order and determine if owner exists
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
if (empty($order_wrapper->owner)) {
return;
}
// get owner account
$account = $order_wrapper->owner
->value();
if (empty($account)) {
return;
}
return $account;
}