Theme snippet for stocklevel display on product pages

qrios's picture
Offline
Cool profile pic award.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 554
Theme snippet for stocklevel display on product pages

Maybe this is usefull to somebody:

It displays a small table with the current stocklevel of all stock-enabled SKU's for a product.

<?php
if ($node->type == 'product') {
 
$arr_sku = uc_stock_skus($node->nid);
 
$stock_html .='<table>';
  foreach(
$arr_sku as $sku){
   
$stocklevel = uc_stock_level($sku);
    if (
$stocklevel) {
      if (
$stocklevel < 1) {
       
$stocklevel = '<span class="nostock">'.$stocklevel.'</span>';
      }
     
$stock_html .='<tr><td>'.$sku.'</td><td>:&nbsp;&nbsp;'.$stocklevel.'</td></tr>';
    }
  }
 
$stock_html .='</table>';
}
?>

Put it in the node.tpl.php, and print the var $stock_html in a proper place.

Feel free to ask.

Regards,

Kees

Qrios Drupal Development

Stock level on catalog page By: opa001 (44 replies) Mon, 03/31/2008 - 16:11