You are here

function theme_uc_catalog_product_grid in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_catalog/uc_catalog.module \theme_uc_catalog_product_grid()
1 theme call to theme_uc_catalog_product_grid()
theme_uc_catalog_products in uc_catalog/uc_catalog.module
Display a formatted list of products.

File

uc_catalog/uc_catalog.module, line 958
Übercart Catalog module.

Code

function theme_uc_catalog_product_grid($products) {
  $product_table = '<div class="category-grid-products"><table>';
  $count = 0;
  foreach ($products as $nid) {
    $product = node_load($nid);
    if ($count == 0) {
      $product_table .= "<tr>";
    }
    else {
      if ($count % variable_get('uc_catalog_grid_display_width', 3) == 0) {
        $product_table .= "</tr><tr>";
      }
    }
    $titlelink = l($product->title, "node/{$nid}", array(), null, null, false, true);
    if (module_exists('imagecache') && isset($product->field_image_cache) && file_exists($product->field_image_cache[0]['filepath'])) {
      $imagelink = l(theme('imagecache', 'product_list', $product->field_image_cache[0]['filepath'], $product->title, $product->title), "node/{$nid}", array(), null, null, false, true);
    }
    else {
      $imagelink = '';
    }
    $product_table .= '<td>';
    if (variable_get('uc_catalog_grid_display_title', TRUE)) {
      $product_table .= '<span class="catalog_grid_title">' . $titlelink . '</span>';
    }
    if (variable_get('uc_catalog_grid_display_model', TRUE)) {
      $product_table .= '<span class="catalog_grid_ref">' . $product->model . '</span>';
    }
    $product_table .= '<span class="catalog_grid_image">' . $imagelink . '</span>';
    if (variable_get('uc_catalog_grid_display_sell_price', TRUE)) {
      $product_table .= '<span class="catalog_grid_sell_price">' . uc_currency_format($product->sell_price) . '</span>';
    }
    if (variable_get('uc_catalog_grid_display_add_to_cart', TRUE)) {
      if (variable_get('uc_catalog_grid_display_attributes', TRUE)) {
        $product_table .= theme('uc_product_add_to_cart', $product);
      }
      else {
        $product_table .= drupal_get_form('uc_catalog_buy_it_now_form_' . $product->nid, $product);
      }
    }
    $product_table .= '</td>';
    $count++;
  }
  $product_table .= "</tr></table></div>";
  return $product_table;
}