function commerce_gc_product_pane_review in Commerce GC 7
File
- modules/
commerce_gc_product/ includes/ commerce_gc_product.checkout_pane.inc, line 93 - Provides Commerce Checkout pane functionality for giftcards.
Code
function commerce_gc_product_pane_review($form, $form_state, $checkout_pane, $order) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$output = array();
// Validate the line item form(s).
foreach ($order_wrapper->commerce_line_items as $line_item_wrapper) {
$line_item = $line_item_wrapper
->value();
if ($line_item && commerce_gc_product_line_item_is_giftcard($line_item_wrapper)) {
$output[$line_item->line_item_id]['title'] = array(
'#prefix' => '<div ' . drupal_attributes(array(
'class' => 'commerce-gc-line-item-review-title',
)) . '>',
'#markup' => check_plain($line_item_wrapper->commerce_product->title
->value()),
'#suffix' => '</div>',
);
// Special markup for free product line items
if ($line_item->type == 'product_discount') {
$output[$line_item->line_item_id]['title']['#markup'] .= ' ' . t('(Free product)');
}
foreach (field_info_instances('commerce_line_item', $line_item->type) as $instance) {
if (!empty($instance['commerce_cart_settings']['field_access'])) {
$field_name = $instance['field_name'];
$field_render = field_view_field('commerce_line_item', $line_item, $field_name, 'default');
// Special handling for the email field.
if ($field_name == 'commerce_gc_mail' && !$field_render) {
$render = array(
'#markup' => '<strong>' . t('Purchased for myself') . '</strong>' . '<div ' . drupal_attributes(array(
'class' => 'commerce-gc-line-item-review-title',
)) . '>' . check_plain($order->mail) . '</div>',
);
}
else {
$render = $field_render;
}
$output[$line_item->line_item_id][$field_name] = $render;
}
}
}
}
return drupal_render($output);
}