Change quantity for hasstock function
Posted: Wed May 30, 2018 11:51 pm
If in System-->Settings-->Options-->Stock Checkout is set to No, it is not possible to complete the checkout if the product quantity is zero or less. As far as I can see, this is verified by the systems-->library-->cart.php hasstock() function:
If however the quantity should for example be -5 instead of zero, before a checkout is not possible, is there any way that this can be coded? I.e. there are 0 products in stock and someone buys 1 item, that should be possible, but if there are -3 products in stock (due to previous purchases for example) and someone buys another 3 items, the error message should appear and checkout should not be possible. Any suggestions would be greatly appreciated.
Thank you.
Code: Select all
public function hasStock() {
$stock = true;
foreach ($this->getProducts() as $product) {
if (!$product['stock']) {
$stock = false;
}
}
return $stock;
Thank you.