diff --git a/services/nginx/app/routes/productsRoute.php b/services/nginx/app/routes/productsRoute.php index 14c7d09e..18914ca0 100644 --- a/services/nginx/app/routes/productsRoute.php +++ b/services/nginx/app/routes/productsRoute.php @@ -175,13 +175,17 @@ class productsRoute // return parseProduct($product); // }, self::parseProductsPrice($products, $customer, $departmentId)) //); - $response->success(array_map(function ($product) use ($customer, $departmentId) { + $result = array_map(function ($product) use ($customer, $departmentId) { $productArray = parseProduct($product); + // Get the price of the product with the department pricing and customer discounts applied + $productArray = self::parseProductsPrice([$productArray], $customer, $departmentId)[0]; // Get the options for the product $productArray['addons'] = self::parseOptionsPrice($productArray['addons'], $customer, $departmentId); // Return the product with the updated price return $productArray; - }, $products)); + }, $products); + // If the productId is set, return a single object instead of an array + $response->success($productId && count($result) > 0 ? $result[0] : $result); } // Check if the id is set in the request (to get a specific product) if (self::isParametersSet(['id'])) {