function commerce_email_order_item_attributes in Commerce Email 7.2
Same name and namespace in other branches
- 7 commerce_email.module \commerce_email_order_item_attributes()
Returns the labels and values of any attributes selected on the product.
Parameters
$product_id: A commerce product id
Return value
String containing the attributes
1 call to commerce_email_order_item_attributes()
- commerce_email_prepare_table in ./
commerce_email.module - Returns a table header and rows for theming.
File
- ./
commerce_email.module, line 106 - Defines additional menu item and order html email functonality.
Code
function commerce_email_order_item_attributes($product_id) {
$product = commerce_product_load($product_id);
$product_wrapper = entity_metadata_wrapper('commerce_product', $product);
$instances = field_info_instances('commerce_product', $product->type);
$attr = array();
foreach ($instances as $name => $instance) {
$commerce_cart_settings = commerce_cart_field_instance_attribute_settings($instance);
if ($commerce_cart_settings['attribute_field'] == 1) {
$field = field_info_field($instance['field_name']);
if (!empty($product_wrapper->{$field['field_name']}
->value()->name)) {
$attr[] = htmlentities($instance['label'] . ': ' . $product_wrapper->{$field['field_name']}
->value()->name, ENT_QUOTES, "UTF-8");
}
}
}
$title_attr = '';
if (!empty($attr)) {
$title_attr .= '<br /><em>' . join("<br />", $attr) . '</em>';
}
return $title_attr;
}