Adding an item of negative quantity to the cart

  • Posts: 36
  • Thank you received: 0
14 years 1 week ago #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

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
14 years 1 week ago #1333

Hi,

That's indeed a problem :)

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

function _checkQuantity(&$product,&$quantity,&$cartContent){
by the code
function _checkQuantity(&$product,&$quantity,&$cartContent){
		if($quantity<0){
			$quantity = 0;
		}

Please Log in or Create an account to join the conversation.

  • Posts: 36
  • Thank you received: 0
14 years 1 week ago #1335

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. :)

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
14 years 1 week ago #1336

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(&$product,&$quantity){

Please Log in or Create an account to join the conversation.

  • Posts: 36
  • Thank you received: 0
14 years 1 week ago #1338

Ah, thank you. I was unaware you had released a new version of Hikashop so quickly. :)

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: 14 years 1 week ago by Redeemer.

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum