function commerce_product_bundle_attribute_field in Commerce Product Bundle 7
Same name and namespace in other branches
- 7.2 commerce_product_bundle.module \commerce_product_bundle_attribute_field()
Implements hook_attribute_field().
File
- ./
commerce_product_bundle.module, line 1346 - Allows the bundling of products in Drupal Commerce.
Code
function commerce_product_bundle_attribute_field(&$element, &$line_item) {
// Check if we have a commerce product line item.
if (!in_array($line_item->type, commerce_product_line_item_types())) {
return;
}
$element['bundles'] = array();
$sub_items = commerce_product_bundle_get_sub_line_items($line_item, TRUE);
if (count($sub_items) > 0) {
$element['#attached']['css'][] = drupal_get_path('module', 'commerce_product_bundle') . '/theme/commerce_product_bundle_cart.css';
foreach ($sub_items as $item) {
$item_wrapper = entity_metadata_wrapper('commerce_line_item', $item);
$product_attribute_view = field_attach_view('commerce_product', $item_wrapper->commerce_product
->value(), 'attribute_view');
$element['bundles'][] = array(
'#markup' => theme('commerce_product_bundle_attribute', array(
'sub_line_item' => $item,
'product_attribute_view' => drupal_render($product_attribute_view),
)),
);
}
}
}