vincent Posted December 19, 2024 Share Posted December 19, 2024 Does anyone know about this bug? and any fix? PHP Warning: Undefined array key "cart_quantity" in /public_html/controllers/front/ProductController.php on line 1329 /** * @param array $product * * @return int */ protected function getRequiredQuantity($product) { $requiredQuantity = (int) Tools::getValue('quantity_wanted', $this->getProductMinimalQuantity($product)); if ($requiredQuantity < $product['minimal_quantity']) { $requiredQuantity = $product['minimal_quantity']; } if ($product['cart_quantity'] >= $requiredQuantity) { return 0; } return $requiredQuantity; Link to comment Share on other sites More sharing options...
Prestashop Addict Posted December 20, 2024 Share Posted December 20, 2024 Hi, this is just a warning, disable debug. Link to comment Share on other sites More sharing options...
leonardomarinio Posted June 5 Share Posted June 5 Hola, tengo el mismo error al ingresar a la hoja de producto, aunque desactivo debug, sigue apareciendo, lo pudiste resolver? On 12/19/2024 at 5:11 PM, vincent said: Does anyone know about this bug? and any fix? PHP Warning: Undefined array key "cart_quantity" in /public_html/controllers/front/ProductController.php on line 1329 /** * @param array $product * * @return int */ protected function getRequiredQuantity($product) { $requiredQuantity = (int) Tools::getValue('quantity_wanted', $this->getProductMinimalQuantity($product)); if ($requiredQuantity < $product['minimal_quantity']) { $requiredQuantity = $product['minimal_quantity']; } if ($product['cart_quantity'] >= $requiredQuantity) { return 0; } return $requiredQuantity; Link to comment Share on other sites More sharing options...
apavlinets Posted August 17 Share Posted August 17 1) У getTemplateVarProduct() (прибл. рядок ~1211) замініть пряме звернення до масиву з результату getProductQuantity(...) на безпечне присвоєння: // було (спрощено): $product['cart_quantity'] = $this->context->cart->getProductQuantity( (int) $product['id_product'], (int) $product['id_product_attribute'] )['quantity']; // стало (безпечний варіант): $qtyInfo = $this->context->cart ? $this->context->cart->getProductQuantity( (int) $product['id_product'], (int) $product['id_product_attribute'] ) : null; $product['cart_quantity'] = isset($qtyInfo['quantity']) ? (int)$qtyInfo['quantity'] : 0; 2) У displayAjaxRefresh() (прибл. рядок ~514) підстрахуйте умову: // було: if ($product['cart_quantity'] >= $minimalProductQuantity) { // стало: if ((int)($product['cart_quantity'] ?? 0) >= $minimalProductQuantity) { 3) У getRequiredQuantity() (рядок 1333) теж додайте дефолт: // було: if ($product['cart_quantity'] >= $requiredQuantity) { // стало: if ((int)($product['cart_quantity'] ?? 0) >= $requiredQuantity) { Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now