Ubercart - Tableless Product Page Part 2
by admin on Jun.19, 2009, under Linux Blerg
Basically This is an add-on for my first post for tableless product page in ubercart.
The modification in this second post is to allow the product price slashing / crossed if there is a discount price available and the discount is automatically calculated using the uc discount alternative module cck fields.
function theme_uc_catalog_product_grid($products) {
$product_table = '<div id="category-grid-products-wrapper">';
$count = 0;
$context = array(
'location' => 'catalog-grid-product',
);
foreach ($products as $nid) {
$product = node_load($nid);
$discounted_price = theme("get_discounted_price", $product);
$context['subject'] = array('node' => $product);
$titlelink = l($product->title, "node/$nid", array('html' => TRUE));
if (module_exists('imagecache') && ($field = variable_get('uc_image_'. $product->type, '')) && isset($product->$field) && file_exists($product->{$field}[0]['filepath'])) {
$imagelink = l(theme('imagecache', 'product_list', $product->{$field}[0]['filepath'], $product->title, $product->title), "node/$nid", array('html' => TRUE));
}
else {
$imagelink = '';
}
$product_table .= '<div class="category-grid-products-content">';
if (variable_get('uc_catalog_grid_display_title', TRUE)) {
$product_table .= '<div class="catalog-grid-title">'. t($titlelink) .'</div>';
}
if (variable_get('uc_catalog_grid_display_model', TRUE)) {
$product_table .= '<div class="catalog-grid-ref">'. $product->model .'</div>';
}
$product_table .= '<div class="catalog-grid-image">'. $imagelink .'</div>';
if (variable_get('uc_catalog_grid_display_sell_price', TRUE)) {
if ( is_null($discounted_price) ) {
$product_table .= '<div class="catalog-grid-sell-price">'. uc_price($product->sell_price, $context) .'</div>';
$product_table .= '<div class="catalog-grid-discount-price"></div>';
}
else {
$product_table .= '<div class="catalog-grid-sell-price"><s>'. uc_price($product->sell_price, $context) .'</s></div>';
$product_table .= '<div class="catalog-grid-discount-price">'.uc_price($discounted_price, $context) .'</div>';
}
}
if (variable_get('uc_catalog_grid_display_add_to_cart', TRUE)) {
if (variable_get('uc_catalog_grid_display_attributes', TRUE)) {
$product_table .= '<div class="catalog-addtocart-button">';
$product_table .= theme('uc_product_add_to_cart', $product);
$product_table .= '</div>';
}
else {
$product_table .= '<div class="catalog-addtocart-button">';
$product_table .= drupal_get_form('uc_catalog_buy_it_now_form_'. $product->nid, $product);
$product_table .= '</div>';
}
}
$product_table .= "</div>";
$count++;
}
$product_table .= "</div>";
return $product_table;
}
You can find the css in my first post for this matter.
Enjoy.
-=end transmission=-


















June 24th, 2009 on 7:45 am
Pretty nice post. I just came by your site and wanted to say
that I have really liked reading your posts. Anyway
I’ll be subscribing to your feed and I hope you write again soon!
June 27th, 2009 on 5:16 am
I think i’ve seen this somewhere beforeā¦but it’s not bad at all