diff --git a/app/CustomFuncPao.php b/app/CustomFuncPao.php index e7abcc8a..27d7dbb7 100644 --- a/app/CustomFuncPao.php +++ b/app/CustomFuncPao.php @@ -1000,6 +1000,7 @@ class ArticleFormatter { if (!$product) { return [ + 'stock_quantity' => 0, 'quantity' => 0, 'price' => '', 'color' => 'black', @@ -1007,9 +1008,14 @@ class ArticleFormatter ]; } - $quantity = intval($product['stock_quantity']); - $price = $product['sale_price'] ?: $product['price']; - + if (isset($product['stock_quantity'])) { + $quantity = intval($product['stock_quantity']); + } + $price = $product['price']; + if (isset($product['sale_price'])) { + $price = $product['sale_price']; + } + return [ 'quantity' => $quantity, 'price' => $price,