function uc_product_kit_view in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_product_kit/uc_product_kit.module \uc_product_kit_view()
- 7.3 uc_product_kit/uc_product_kit.module \uc_product_kit_view()
Implementation of hook_view().
File
- uc_product_kit/
uc_product_kit.module, line 401 - The product kit module for Übercart.
Code
function uc_product_kit_view($node, $teaser = 0, $page = 0) {
$node = node_prepare($node, $teaser);
$enabled = variable_get('uc_product_field_enabled', array(
'image' => 1,
'display_price' => 1,
'model' => 1,
'list_price' => 0,
'cost' => 0,
'sell_price' => 1,
'weight' => 0,
'dimensions' => 0,
'add_to_cart' => 1,
));
$weight = variable_get('uc_product_field_weight', array(
'image' => -2,
'display_price' => -1,
'model' => 0,
'list_price' => 2,
'cost' => 3,
'sell_price' => 4,
'weight' => 5,
'dimensions' => 6,
'add_to_cart' => 10,
));
if (isset($node->field_image_cache) && file_exists($node->field_image_cache[0]['filepath'])) {
$node->content['image'] = array(
'#value' => theme('uc_product_image', $node->field_image_cache),
'#access' => $enabled['image'] && module_exists('imagecache'),
'#weight' => $weight['image'],
);
}
$node->content['display_price'] = array(
'#value' => theme('uc_product_display_price', $node->sell_price),
'#access' => $enabled['display_price'],
'#weight' => $weight['display_price'],
);
if (!$teaser) {
$node->content['model'] = array(
'#value' => theme('uc_product_model', $node->model),
'#access' => $enabled['model'],
'#weight' => $weight['model'],
);
$node->content['body']['#weight'] = 1;
$node->content['list_price'] = array(
'#value' => theme('uc_product_price', $node->list_price, 'list_price'),
'#access' => $enabled['list_price'],
'#weight' => $weight['list_price'],
);
$node->content['cost'] = array(
'#value' => theme('uc_product_price', $node->cost, 'cost'),
'#access' => $enabled['cost'] && user_access('administer products'),
'#weight' => $weight['cost'],
);
}
else {
$node->content['#attributes'] = array(
'style' => 'display: inline',
);
}
$node->content['sell_price'] = array(
'#value' => theme('uc_product_sell_price', $node->sell_price, $teaser),
'#access' => $enabled['sell_price'],
'#weight' => $weight['sell_price'],
);
if (!$teaser) {
$node->content['weight'] = array(
'#value' => theme('uc_product_weight', $node->weight, $node->weight_units),
'#access' => $enabled['weight'],
'#weight' => $weight['weight'],
);
if ($node->mutable != UC_PRODUCT_KIT_UNMUTABLE_NO_LIST) {
$node->content['products'] = array(
'#weight' => 6,
);
foreach ($node->products as $product) {
if (node_access('view', $product)) {
$title = l($product->title, 'node/' . $product->nid);
}
else {
$title = check_plain($product->title);
}
$node->content['products'][$product->nid]['qty'] = array(
'#value' => '<div class="product-qty">' . $product->qty . ' x ' . $title . '</div>',
);
$node->content['products'][$product->nid]['#weight'] = $product->ordering;
}
}
if (module_exists('uc_cart')) {
$node->content['add_to_cart'] = array(
'#value' => theme('uc_product_kit_add_to_cart', $node),
'#weight' => 10,
);
}
}
else {
if (module_exists('uc_cart') && variable_get('uc_product_add_to_cart_teaser', true)) {
$node->content['add_to_cart'] = array(
'#value' => theme('uc_product_kit_add_to_cart', $node),
'#weight' => 10,
);
}
}
return $node;
}