[Skip to main content](#vessel-content)

#   Count the items in mini cart

##

- **[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")**
- [![nic7071's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/42433-nic7071 "View nic7071's Profile") Topic Author
- [ Offline](/forum/user/42433-nic7071)

Less More

- Posts: 129
- Thank you received: 0
-
-

9 years 4 months ago [\#272201](#272201) by [nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")  Replied by *[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#272201 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

it only shows the variants and options as a separate and independent product in checkout cart view and in card module!
my question is how can I remove options and variants from cart module counting and display the main product count inside module!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14277
-
-

9 years 4 months ago [\#272208](#272208) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#272208 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Hi,

That's not the case. As Philippe explained, if you have the setting "Group options with product" activated in the HikaShop configuration, the variants and options will be grouped with the main products and the counting will only be done on the main products.
So that should do what you want already.
Here is an example on a test website of mine:
[ monosnap.com/file/ZgUlNFTWyHCb1pdqQfvUTCXhK57tCo](https://monosnap.com/file/ZgUlNFTWyHCb1pdqQfvUTCXhK57tCo)
As you can see, I have one main product with one option with a quantity of 2 in my cart and the mini module on the right side properly displays "2" and not "4" since I have the "group options with products" setting activated.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")**
- [![nic7071's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/42433-nic7071 "View nic7071's Profile") Topic Author
- [ Offline](/forum/user/42433-nic7071)

Less More

- Posts: 129
- Thank you received: 0
-
-

9 years 4 months ago [\#272661](#272661) by [nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")  Replied by *[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#272661 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Hi, Nicolas.
i think i've explained bad or you have been misunderstood.
i have turned off the quantitiy option in mini cart module.

i just want to load an string of line inside an span tag to only show the total amount of main product inside cart.
for example if i have an iphone with software and another iphone with waranty i want that string at bottom of my cart to show 2
but it shows 4 even when i turn on the "Group options with product" !

i just want to count and show the total amount of main products it has nothing to do with hichashop mini cart quantity option i think !

Check this photo please

- [ ![ScreenShot2017-06-24at1.00.42PM.png](/forum/attachment/38883) ](/forum/attachment/38883 "...t1.00.42PM.png") [ ](/forum/attachment/38883?download=1 "...t1.00.42PM.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14277
-
-

9 years 4 months ago -  9 years 4 months ago [\#272675](#272675) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#272675 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Hi,

Then you should use such code: Code:

&lt;?php if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true; $cartClass = hikashop_get('class.cart'); $fullCart = $cartClass-&gt;loadFullCart(); $nbProducts = 0; foreach($fullCart-&gt;products as $product){ if($product-&gt;cart_product_option_parent_id) continue; $nbProducts += $product-&gt;cart_product_quantity; } echo $nbProducts; ?&gt;

Last edit: 9 years 4 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")**
- [![nic7071's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/42433-nic7071 "View nic7071's Profile") Topic Author
- [ Offline](/forum/user/42433-nic7071)

Less More

- Posts: 129
- Thank you received: 0
-
-

9 years 4 months ago [\#272687](#272687) by [nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")  Replied by *[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#272687 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

You're My Man Nicolas,
It Finally Worked Thank you ![;-)](/media/kunena/emoticons/24.png ";-)")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[jschroeder](/forum/user/13561-jschroeder "View jschroeder's Profile")**
- [![jschroeder's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/13561-jschroeder "View jschroeder's Profile")
- [ Offline](/forum/user/13561-jschroeder)

Less More

- Posts: 165
- Thank you received: 3
-
-

9 years 3 months ago -  9 years 3 months ago [\#273401](#273401) by [jschroeder](/forum/user/13561-jschroeder "View jschroeder's Profile")  Replied by *[jschroeder](/forum/user/13561-jschroeder "View jschroeder's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#273401 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

> nicolas wrote: Hi,
>
> Then you should use such code:
>
> Code:
>
>  &lt;?php if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true; $cartClass = hikashop_get('class.cart'); $fullCart = $cartClass-&gt;loadFullCart(); $nbProducts = 0; foreach($fullCart-&gt;products as $product){ if($product-&gt;cart_product_option_parent_id) continue; $nbProducts += $product-&gt;cart_product_quantity; } echo $nbProducts; ?&gt;

Hi, I am using the ajax version of the add to cart button. However, the issue I am having is this shows the total number of items in the cart however, the number does not update since I am using ajax how do I get the total number to update using the ajax add to cart button without refreshing the page.

Last edit: 9 years 3 months ago by [jschroeder](/forum/user/13561-jschroeder "View jschroeder's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14277
-
-

9 years 3 months ago [\#273450](#273450) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#273450 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Hi,

The best would be to use a HikaShop mini cart configured to display only the count number.
Because otherwise, it's a lot more complex. You need to add javascript to that code to be triggered upon add to cart success, you need to then do an ajax request in your javascript to call a specific URL of your website and then customize something (create a plugin for example) to catch that URL and return the number so that you can then update the display. Basically, do the same thing than the cart module we already have.
If you're not a skilled developer it will be difficult to achieve and I can't provide an easy solution to that besides using the HikaShop cart module.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[jschroeder](/forum/user/13561-jschroeder "View jschroeder's Profile")**
- [![jschroeder's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/13561-jschroeder "View jschroeder's Profile")
- [ Offline](/forum/user/13561-jschroeder)

Less More

- Posts: 165
- Thank you received: 3
-
-

9 years 3 months ago [\#273461](#273461) by [jschroeder](/forum/user/13561-jschroeder "View jschroeder's Profile")  Replied by *[jschroeder](/forum/user/13561-jschroeder "View jschroeder's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#273461 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

> nicolas wrote: Hi,
>
> The best would be to use a HikaShop mini cart configured to display only the count number.
> Because otherwise, it's a lot more complex. You need to add javascript to that code to be triggered upon add to cart success, you need to then do an ajax request in your javascript to call a specific URL of your website and then customize something (create a plugin for example) to catch that URL and return the number so that you can then update the display. Basically, do the same thing than the cart module we already have.
> If you're not a skilled developer it will be difficult to achieve and I can't provide an easy solution to that besides using the HikaShop cart module.

That is unfortunate because I am moving to the new ajax cart and this makes it impossible for me to fully do so. Unfortunately that will not work in my situation. I have a cart module that shows the number, but when you click on the number it expands the cart and shows the "1 items for $10" or whatever the price is. I am a fairly skilled php developer. However, I do not know ajax at all which makes it impossible for me to do this. Below are the pictures attached of what I am trying to achieve. I tired just displaying the $html output twice and just using css to only display the number in 1 area however, that does not work because it causes a javascript error, likely because the ajax is loading twice in 1 page through the $html output.

[ ![sidebar-closed.PNG](/forum/attachment/39091) ](/forum/attachment/39091 "...bar-closed.PNG")

[ ![sidebar-opened.PNG](/forum/attachment/39092) ](/forum/attachment/39092 "...bar-opened.PNG")

Also, I have the checkout itself working pretty well in ajax and it does not really make any sense to leave the add to product button in a non ajax environment. This is a very large client and I am guessing legacy mode will either go away at some point or not be supported so I want everything in non legacy mode. It is not cost effect to have to do 2 separate upgrades either.

This seems ridiculous to do so but would it work to load 2 carts inside of each other 1 that is just displaying the quantity and 1 that displays everything else? I would basically display a module position inside the other modules layout override to achieve this or would I get this also cause some sort of conflict?

Also, I have another question and since it mostly related I figured I would just ask it here. I noticed another issue. When you are using the ajax checkout and you login if you have a login box on your site since ajax is being used the state on the login box does not change because the page is not reloading. This is an issue because it appears like you are not logged in until get further through the checkout. Also, I noticed when you login when using the ajax checkout it logs you in but does not scroll you to the top of the page content after logging in so it appears you did not actually log in how do I address this?

- [ ![sidebar-closed.PNG](/forum/attachment/39091) ](/forum/attachment/39091 "...bar-closed.PNG") [ ](/forum/attachment/39091?download=1 "...bar-closed.PNG")
- [ ![sidebar-opened.PNG](/forum/attachment/39092) ](/forum/attachment/39092 "...bar-opened.PNG") [ ](/forum/attachment/39092?download=1 "...bar-opened.PNG")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14277
-
-

9 years 3 months ago [\#273463](#273463) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#273463 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Hi,

In that case, I see two possible ways to do it without the need of knowing javascript:
1. Configure the slider effect in your template with two module positions: one for the quantity amount and one for the mini cart standard display. Then, have two HikaShop cart modules, one displayed as a mini cart and one just displaying the quantity (it's easy to do that in the file "cart" of the view "product") and assign each one to their respective positions.
That way, the cart modules will refresh themselves automatically.

2. Integrate the slider effect inside the file "cart" of the view "product" so that the module displays the whole slider and the quantity number and the mini cart display. When the cart module will then refresh, it will refresh the whole slider.

Regarding your question about the checkout:
First, please open new threads for unrelated questions.
The Joomla login module not refreshing in that case is indeed an issue we know about. But we can't do much about it since that module doesn't have any javascript refresh feature we could integrate with. The only solution would be to have our own login module, but then you would still have the same issue if you wanted to use another 3rd party login module.
I would just recommend to remove the login module on the checkout since the checkout already provides it.
I didn't understand your point with going to the top of the page? Why going to the top of the page would be necessary for you to know that you're logged in ? You'll usually automatically know that since you'll see the address view instead of the login view or you'll be moved to the next step of the checkout (it depends on how you configure your checkout).

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")**
- [![nic7071's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/42433-nic7071 "View nic7071's Profile") Topic Author
- [ Offline](/forum/user/42433-nic7071)

Less More

- Posts: 129
- Thank you received: 0
-
-

9 years 3 months ago [\#273895](#273895) by [nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")  Replied by *[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#273895 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Hi,
as you suggested i'm using these line of codes to echo the count of products inside cart without counting the product characteristics or options.
now i want to cut the product quantity from count too.

for example, if i have 3 ipad, 1 iphone, 1 macbook it says there is 5 product inside cart.
i want to count only the product and count 3 or any quantity of ipad as 1 product.

Can you please give me another hint on this topic?

Code:

&lt;?php if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true; $cartClass = hikashop_get('class.cart'); $fullCart = $cartClass-&gt;loadFullCart(); $nbProducts = 0; foreach($fullCart-&gt;products as $product){ if($product-&gt;cart_product_option_parent_id) continue; $nbProducts += $product-&gt;cart_product_quantity; } echo $nbProducts; ?&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14277
-
-

9 years 3 months ago [\#273908](#273908) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#273908 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Hi,

Then that's easy.

Change the line:
$nbProducts += $product-&gt;cart_product_quantity;
to:
$nbProducts += 1;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")**
- [![nic7071's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/42433-nic7071 "View nic7071's Profile") Topic Author
- [ Offline](/forum/user/42433-nic7071)

Less More

- Posts: 129
- Thank you received: 0
-
-

9 years 3 months ago [\#274021](#274021) by [nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")  Replied by *[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#274021 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Works like a charm,
thank you! ![:-)](/media/kunena/emoticons/3.png ":-)")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")**
- [![nic7071's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/42433-nic7071 "View nic7071's Profile") Topic Author
- [ Offline](/forum/user/42433-nic7071)

Less More

- Posts: 129
- Thank you received: 0
-
-

9 years 3 months ago [\#274047](#274047) by [nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")  Replied by *[nic7071](/forum/user/42433-nic7071 "View nic7071's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#274047 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Sorry I got a problem in this case,
when I replace the line with:
$nbProducts += 1;

the counter also count the products with characteristic or options as 2 but the product without characteristic or options are being correctly counted as 1 !

how can I make the code to count the product with characteristic or options as 1 product instead of 2 ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14277
-
-

9 years 3 months ago [\#274054](#274054) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Count the items in mini cart](/forum/26-product-category-display/884952-count-the-items-in-mini-cart?start=20#274054 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1  hi, i'm using this code to return the number of items in my mini cart,  first i want you to tell me if my code is wrong or correct ? then i want to exclude the options from count. i want to only count the main products my current code returns 3 when i have a product with to options in my cart. i want it to return 1 instead of 3 .")*

Hi,

Then change the line to :
$nbProducts += min(1, $product-&gt;cart_product_quantity);

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL3Byb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84ODQ5NTItY291bnQtdGhlLWl0ZW1zLWluLW1pbmktY2FydD9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.127 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
