Re: Re: Re: How can I embed the quantity in cart in node-product

Posts: 79
Joined: 01/18/2008

Sorry to keep on this, but what would you suggest doing for showing the qty, not just items?

I have a hacked up version of the block:

<?php
function phptemplate_uc_cart_block_content() {
  global
$user;

  if (
variable_get('uc_cart_show_help_text', FALSE)) {
   
$output = '<span class="cart-help-text">'
           
. variable_get('uc_cart_help_text', t('Click title to display cart contents.'))
             .
'</span>';
  }

 
$output .= '<div id="block-cart-contents">';

 
$items = uc_cart_get_contents();

 
$item_count = 0;
  if (!empty(
$items)) {
    foreach (
$items as $item) {
      if (
is_array($item->data['attributes']) && !empty($item->data['attributes'])) {
       
$display_item = module_invoke($item->module, 'cart_display', $item);
      }
     
$total += ($item->price) * $item->qty;
     
$item_count += $item->qty;
    }
  }
  else {
   
$output .= ''. t('') .'';
  }

 
$output .= '</div>';

 
$item_text = format_plural($item_count, '1', '@count');
 
$view = '('. l(t('View cart'), 'cart', array('rel' => 'nofollow')) .')';
  if (
variable_get('uc_checkout_enabled', TRUE)) {
   
$checkout = ' ('. l(t('Checkout'), 'cart/checkout', array('rel' => 'nofollow')) .')';
  }
   
$output .= $item_text;
  if (
$item_count > 0) {
  }

  return
$output;
}
?>

But this is not ideal. I would prefer a simple method of adding it directly in my node-products.tpl.php page.