Shopping Cart Operations > Tips and Tricks

Category Product Count.

(1/2) > >>

zonavirtuala:

Category Product Count... similar OpenCart.  How?

(Show the number of products inside the subcategories in the storefront header category menu)

View example 

abantecart:
This is just a matter of adding
--- Code: ---<?php echo $category['product_count']?>
--- End code ---
in the template for category.

Locate this file: storefront/view/default_html5/template/blocks/category.tpl

Replace:

--- Code: ---<a class="productname" href="<?php echo $item['info_url'] ?>"><?php echo $item['name']?></a>
--- End code ---
with:

--- Code: ---<a class="productname" href="<?php echo $item['info_url'] ?>"><?php echo $item['name']?> (<?php echo $category['product_count']?>)</a>
--- End code ---

zonavirtuala:

Thanks !


 ... but in  default & template2 ? Who ?


Thank you,



abantecart:

--- Quote from: zonavirtuala on April 21, 2014, 11:02:38 AM --- ... but in  default & tamplate2 ? Who ?

--- End quote ---
This will be similar in other templates. What do you mean by who?

zonavirtuala:
not work ...:(

in default...  not found code " <a class="productname" href="<?php echo $item['info_url'] ?>"><?php echo $item['name']?></a>  " .




storefront/view/default/template/block/category.tpl

in default, code is:

<?php if ( $block_framed ) { ?>
<div class="s_block">
   <div class="block_tl">
      <div class="block_tr">
         <div class="block_tc"><img src="<?php echo $this->templateResource('/image/category.png'); ?>" alt="" /><?php echo $heading_title; ?></div>
      </div>
   </div>
    <div class="block_cl">
       <div class="block_cr">
           <div class="block_cc">
<?php } ?>
               <div class="category_list">
                  <ul>
                  <?php
                  foreach($category_list as $item){
                     $cname = $item['category_id']==$selected_category_id ? '<b>'.$item['name'].'</b>' : $item['name'];
                  echo '<li>'.str_repeat('&nbsp;&nbsp;&nbsp;',$item['level']).'<a href="'.$item['href'].'">'.$cname.'</a></li>';
                  }?>
               </ul>
               </div>
<?php if ( $block_framed ) { ?>
            </div>
        </div>
    </div>
   <div class="block_bl">
      <div class="block_br">
         <div class="block_bc">&nbsp;</div>
      </div>
   </div>
</div>
<?php } ?>

Navigation

[0] Message Index

[#] Next page

Go to full version
Powered by SMFPacks Social Login Mod