Not enough stock for Product

  • Posts: 42
  • Thank you received: 3
1 year 2 months ago #349302

Hi,

Some of the products in my website can't be added to cart as it shows 'There is not enough stock for the product.'. I have tried all the things I can modify and create a new product with same settings but still can't solve this issue.

Hope can get some hints here.

This message contains confidential information

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

  • Posts: 81509
  • Thank you received: 13064
  • MODERATOR
1 year 2 months ago #349304

Hi,

This message should normally be displayed by the code:

if(!$wishlist && empty($msg) && $product['data']->product_quantity == 0) {
				$msg = JText::sprintf('NOT_ENOUGH_STOCK_FOR_PRODUCT', $product['data']->product_name);
			}
in administrator/components/com_hikashop/classes/cart.php
As you can see, it checks that the quantity of the product is equal to 0.
However, if I check the quantity of the product in the in the backend, it is set to unlimited and it doesn't have any bundled products (which could affect the calculated quantity if one of the bundled products had a quantity different than unlimited, and if the quantity of a bundled products would be 0, the main product quantity would be 0 too).
The only reason I can see is that there is a plugin implementing the event onBeforeProductQuantityCheck(&$products, &$cart, &$options) and dynamically modifying the product_quantity of the product.
I can see you have several custom plugins for HikaShop as well as third party plugins, so this increases the probability of the issue coming from a plugin.

I would recommend downloading the files of all the plugins in the plugins folder of Joomla and searching through all of them for the text "onBeforeProductQuantityCheck".
Hopefully, that will give a result and you can then check the code of that plugin.
If that doesn't yeld any result, then I would add some debug in administrator/components/com_hikashop/classes/cart.php around the code I pointed out. I would first use the hikashop_writeToLog($var) function to check the content of $product in the "payment log file" setting of the HikaShop configuration after a refused add to cart. That way, I would first be able to confirm that it comes from this piece of code with the product_quantity being set to 0. I would then move that debug to before the line:
$this->app->triggerEvent('onBeforeProductQuantityCheck', array(&$products, &$cart, &$options) );
If the product_quantity is -1 (unlimited) at that point, it means that it comes from one of the plugins and you messed up with the search in the plugin files. If it's 0, then it means that it comes from something else before, and it would add the debug at the beginning of the function, etc.

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

Time to create page: 0.048 seconds
Powered by Kunena Forum