*

pitbull

  • ***
  • 98 posts
How can i get the total number of items PER category ?
« on: October 18, 2017, 09:19:49 AM »
I need to display at the main page the total number of items for 2-3 categories/subcategories.

eg

Smartphones: 300 items, Laptops:220 items, Tablets:130 items

I tried some code but doesnt display anything. i know its a simple function but i cant find it. I think the function already exists because when you click a main category on the main/home page inside the fancy box it displays the total number of the items per category and also in the search page it display the number of items per subcategory.. I tried to find some code that will do the job inside the file inc.category.php but i didnt figure it out how i can make it work. Then after many failures i tried to add this in veronika's functions.php file:

Code: [Select]
function cust_cat_item_count($id) {
    $cat = osc_get_category('id', $id);
    View::newInstance()->_exportVariableToView('category', $cat);
    return osc_category_total_items();
}

and then i called it inside the main.php file of veronika theme with:

Code: [Select]
<?php echo cust_cat_item_count('12'); ?>
<?php echo cust_cat_item_count('54'); ?>
<?php echo cust_cat_item_count('85'); ?>

12, 54, 85 are the category ids for the categories smartphones,laptops,and tablets

But it didnt work. If you could take a look it would be great as i really need your help !!!!!
 
 

*

MB Themes

Re: How can i get the total number of items PER category ?
« Reply #1 on: October 18, 2017, 09:25:17 AM »
@pitbull
oc-includes/osclass/model/CategoryStats.php

Code: [Select]
<?php echo CategoryStats::newIntance()->countItemsFromCategory($cat_id); ?>
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

pitbull

  • ***
  • 98 posts
Re: How can i get the total number of items PER category ?
« Reply #2 on: October 18, 2017, 10:23:26 AM »
Thank you it worked !!!

Mark it as solved !!


Re: How can i get the total number of items PER category ?
« Reply #3 on: October 22, 2017, 01:05:48 AM »
Thank you it worked !!!

Mark it as solved !!
Please how did you arrange that
please can you screenshot it for me

*

Darwazo

  • ***
  • 81 posts
Re: How can i get the total number of items PER category ?
« Reply #4 on: October 25, 2017, 01:09:31 AM »
Pls. how did u get the total categories show up?

Thanks in advance