- Posts: 36
- Thank you received: 0
Adding an item of negative quantity to the cart
15 years 10 months ago #1332
by Redeemer
Adding an item of negative quantity to the cart was created by Redeemer
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
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.
15 years 10 months ago #1333
by nicolas
Replied by nicolas on topic Re: Adding an item of negative quantity to the cart
Hi,
That's indeed a problem
In the file administrator/components/com_hikashop/classes/cart.php, near line 220, please replace the code
by the code
That's indeed a problem
In the file administrator/components/com_hikashop/classes/cart.php, near line 220, please replace the code
Code:
function _checkQuantity(&$product,&$quantity,&$cartContent){
Code:
function _checkQuantity(&$product,&$quantity,&$cartContent){
if($quantity<0){
$quantity = 0;
}
Please Log in or Create an account to join the conversation.
15 years 10 months ago #1335
by Redeemer
Replied by Redeemer on topic Re: Adding an item of negative quantity to the cart
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.
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.
15 years 10 months ago #1336
by nicolas
Replied by nicolas on topic Re: Adding an item of negative quantity to the cart
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){
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.
15 years 10 months ago - 15 years 10 months ago #1338
by Redeemer
Replied by Redeemer on topic Re: Adding an item of negative quantity to the cart
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.
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 10 months ago by Redeemer.
Please Log in or Create an account to join the conversation.
Time to create page: 0.155 seconds