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

#   Adding an item of negative quantity to the cart

##

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

Less More

- Posts: 36
- Thank you received: 0
-
-

15 years 11 months ago [\#1332](#1332) by [Redeemer](/forum/user/240-redeemer "View Redeemer's Profile")  *[Adding an item of negative quantity to the cart](/forum/3-bug-report/1332-adding-an-item-of-negative-quantity-to-the-cart#1332 "Hi,  I didn't notice this before, but it's apparently possible to add a negative amount of items to the cart. If you don't have any items in the cart, then this will cause the shopping cart to think it has an item in it; although nothing appears there. If you already have any items in the shopping cart already, adding a negative quantity will cause you to lose those number of products specified; or, if it causes you to no longer have any items in the cart, then you will have to deal with the first bug.  I would be much obliged if someone could tell me how to fix this. :) -Redeemer")* was created by *[Redeemer](/forum/user/240-redeemer "View Redeemer's Profile")*

Hi,

I didn't notice this before, but it's apparently possible to add a negative amount of items to the cart. If you don't have any items in the cart, then this will cause the shopping cart to think it has an item in it; although nothing appears there. If you already have any items in the shopping cart already, adding a negative quantity will cause you to lose those number of products specified; or, if it causes you to no longer have any items in the cart, then you will have to deal with the first bug.

I would be much obliged if someone could tell me how to fix this. ![:)](/media/kunena/emoticons/8.png ":)")
-Redeemer

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC8xMzMyLWFkZGluZy1hbi1pdGVtLW9mLW5lZ2F0aXZlLXF1YW50aXR5LXRvLXRoZS1jYXJ0P3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14269
-
-

15 years 11 months ago [\#1333](#1333) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Adding an item of negative quantity to the cart](/forum/3-bug-report/1332-adding-an-item-of-negative-quantity-to-the-cart#1333 "Hi,  I didn't notice this before, but it's apparently possible to add a negative amount of items to the cart. If you don't have any items in the cart, then this will cause the shopping cart to think it has an item in it; although nothing appears there. If you already have any items in the shopping cart already, adding a negative quantity will cause you to lose those number of products specified; or, if it causes you to no longer have any items in the cart, then you will have to deal with the first bug.  I would be much obliged if someone could tell me how to fix this. :) -Redeemer")*

Hi,

That's indeed a problem ![:)](/media/kunena/emoticons/8.png ":)")

In the file administrator/components/com_hikashop/classes/cart.php, near line 220, please replace the code Code:

function _checkQuantity(&amp;$product,&amp;$quantity,&amp;$cartContent){

by the code Code:

function _checkQuantity(&amp;$product,&amp;$quantity,&amp;$cartContent){ if($quantity&lt;0){ $quantity = 0; }

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

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

Less More

- Posts: 36
- Thank you received: 0
-
-

15 years 11 months ago [\#1335](#1335) by [Redeemer](/forum/user/240-redeemer "View Redeemer's Profile")  Replied by *[Redeemer](/forum/user/240-redeemer "View Redeemer's Profile")* on topic *[Re: Adding an item of negative quantity to the cart](/forum/3-bug-report/1332-adding-an-item-of-negative-quantity-to-the-cart#1335 "Hi,  I didn't notice this before, but it's apparently possible to add a negative amount of items to the cart. If you don't have any items in the cart, then this will cause the shopping cart to think it has an item in it; although nothing appears there. If you already have any items in the shopping cart already, adding a negative quantity will cause you to lose those number of products specified; or, if it causes you to no longer have any items in the cart, then you will have to deal with the first bug.  I would be much obliged if someone could tell me how to fix this. :) -Redeemer")*

Hello,

Thank you for the quick reply, it was very helpful; however, I now have a new (albeit minor) problem. It appears that the _checkQuantity() function definition is now missing an argument, as I am now getting this error message:

Warning: Missing argument 3 for hikashopCartClass::_checkQuantity(), called in /usr/share/joomla15/administrator/components/com_hikashop/classes/cart.php on line 167 and defined in /usr/share/joomla15/administrator/components/com_hikashop/classes/cart.php on line 193

I didn't care to take notice what this argument was before I copy/pasted your code over the old, so if you would care to enumerate on this matter, I would be much obliged. ![:)](/media/kunena/emoticons/8.png ":)")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC8xMzMyLWFkZGluZy1hbi1pdGVtLW9mLW5lZ2F0aXZlLXF1YW50aXR5LXRvLXRoZS1jYXJ0P3RtcGw9bWFya2Rvd24=) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14269
-
-

15 years 11 months ago [\#1336](#1336) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Adding an item of negative quantity to the cart](/forum/3-bug-report/1332-adding-an-item-of-negative-quantity-to-the-cart#1336 "Hi,  I didn't notice this before, but it's apparently possible to add a negative amount of items to the cart. If you don't have any items in the cart, then this will cause the shopping cart to think it has an item in it; although nothing appears there. If you already have any items in the shopping cart already, adding a negative quantity will cause you to lose those number of products specified; or, if it causes you to no longer have any items in the cart, then you will have to deal with the first bug.  I would be much obliged if someone could tell me how to fix this. :) -Redeemer")*

That's because you're not using the latest version of HikaShop and that we changed the code in the mean time. If you update and reapply the modification, that will work.
Otherwise, you can just remove the third parameter from the function line like this:
function _checkQuantity(&amp;$product,&amp;$quantity){

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

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

Less More

- Posts: 36
- Thank you received: 0
-
-

15 years 11 months ago -  15 years 11 months ago [\#1338](#1338) by [Redeemer](/forum/user/240-redeemer "View Redeemer's Profile")  Replied by *[Redeemer](/forum/user/240-redeemer "View Redeemer's Profile")* on topic *[Re: Adding an item of negative quantity to the cart](/forum/3-bug-report/1332-adding-an-item-of-negative-quantity-to-the-cart#1338 "Hi,  I didn't notice this before, but it's apparently possible to add a negative amount of items to the cart. If you don't have any items in the cart, then this will cause the shopping cart to think it has an item in it; although nothing appears there. If you already have any items in the shopping cart already, adding a negative quantity will cause you to lose those number of products specified; or, if it causes you to no longer have any items in the cart, then you will have to deal with the first bug.  I would be much obliged if someone could tell me how to fix this. :) -Redeemer")*

Ah, thank you. I was unaware you had released a new version of Hikashop so quickly. ![:)](/media/kunena/emoticons/8.png ":)")

I'll update my copy now.

EDIT: I just updated Hikashop, and I lost all of my clever hacks and fixes... Darn. Guess I'll have to go add them again.

Last edit: 15 years 11 months ago by [Redeemer](/forum/user/240-redeemer "View Redeemer's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC8xMzMyLWFkZGluZy1hbi1pdGVtLW9mLW5lZ2F0aXZlLXF1YW50aXR5LXRvLXRoZS1jYXJ0P3RtcGw9bWFya2Rvd24=) 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.233 seconds

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

[](#top)
