I'm currently setting up a new 1.7.8.4 installation (data migrated from 1.5.4) and have run into the following problem:
I've activated ordering of items that are not in stock in the backend. However, regardless of whether an item is in stock or not, the cart page (index.php?controller=cart&action=show) will always show an error message that the selected quantity is not available and the continue button is grayed out. If the quantity up and down arrows are clicked on that same page, the error message disappears and it's possible to proceed with the order. Does anybody know how I can get rid of that error so that customers are directly able to order without seeing the incorrect error message on the checkout page? I don't know where it's coming from.
If I turn on Debug Mode, I get the following error on that page when an item is in the cart:
Whoops, looks like something went wrong.
(1/1) ContextErrorException
Notice: Undefined index: allow_oosp
in Cart.php line 4095
at CartCore->checkQuantities(true)in CartController.php line 631
at CartControllerCore->areProductsAvailable()in CartController.php line 82
at CartControllerCore->init()in Controller.php line 287
at ControllerCore->run()in Dispatcher.php line 518
at DispatcherCore->dispatch()in index.php line 28
The relevant part of Cart.php is this one, line 4095 marked in bold:
/**
* Check if product quantities in Cart are available.
*
* @param bool $returnProductOnFailure Return the first found product with not enough quantity
*
* @return bool|array If all products are in stock: true; if not: either false or an array
* containing the first found product which is not in stock in the
* requested amount
*/
public function checkQuantities($returnProductOnFailure = false)
{
if (Configuration::isCatalogMode() && !defined('_PS_ADMIN_DIR_')) {
return false;
}
foreach ($this->getProducts() as $product) {
if (
!$this->allow_seperated_package &&
!$product['allow_oosp'] &&
StockAvailable::dependsOnStock($product['id_product']) &&
$product['advanced_stock_management'] &&
(bool) Context::getContext()->customer->isLogged() &&
($delivery = $this->getDeliveryOption()) &&
!empty($delivery)
) {
$product['stock_quantity'] = StockManager::getStockByCarrier(
(int) $product['id_product'],
(int) $product['id_product_attribute'],
$delivery
);
}
if (
!$product['active'] ||
!$product['available_for_order'] ||
(!$product['allow_oosp'] && $product['stock_quantity'] < $product['cart_quantity'])
) {
return $returnProductOnFailure ? $product : false;
}
if (!$product['allow_oosp']) {
$productQuantity = Product::getQuantity(
$product['id_product'],
$product['id_product_attribute'],
null,
$this,
$product['id_customization']
);
if ($productQuantity < 0) {
return $returnProductOnFailure ? $product : false;
}
}
}
return true;
}