public static function getProductDetails($context, $idWkPosOutlet = false, $idProduct = false, $idAddress = null) { $objOutletProduct = new WkPosOutletProduct(); $items = $objOutletProduct->getProductBasicDetails($context, $idWkPosOutlet, $idProduct); if (!$items) { return []; } $results = []; $idLang = $context->language->id; foreach ($items as $item) { $objPosValues = new WkPosCustomPosValues(); $allValues = $objPosValues->getPosCustomValuesByIdProduct($item['id_product']); if ($allValues && $allValues['pos_sale_allow'] == 0) { continue; } $productNameLength = Configuration::get('WKPOS_PRODUCT_NAME_LENGTH'); $displayProductName = Tools::strlen($item['name']) > $productNameLength ? Tools::substr($item['name'], 0, $productNameLength) . '...' : $item['name']; $idProduct = $item['id_product']; $productPrice = WkPosOutletProduct::getProductPrice($idProduct, $idAddress); $productPriceWithoutReduction = $productPrice; // omitimos cálculo extra $productTaxExcludedPrice = WkPosOutletProduct::getProductPrice($idProduct, $idAddress, false); $results[$idProduct] = [ 'id' => (int) $idProduct, 'name' => str_replace('|', ' ', $item['name']), 'display_name' => str_replace('|', ' ', $displayProductName), 'ref' => $item['reference'] ?? '', 'upc' => $item['upc'] ?? '', 'ean13' => $item['ean13'] ?? '', 'isbn' => $item['isbn'] ?? '', 'id_category_default' => $item['id_category_default'] ?? '', 'id_supplier' => $item['id_supplier'] ?? '', 'id_shop' => $item['id_shop'], 'minimal_quantity' => $item['minimal_quantity'], 'price' => $productPrice, 'displayPrice' => Tools::displayPrice($productPrice), 'displayPriceWithoutReduction' => Tools::displayPrice($productPriceWithoutReduction), 'displayPriceWithoutTax' => Tools::displayPrice($productTaxExcludedPrice), 'taxExcludedPrice' => $productPrice, 'availableForOrder' => $item['available_for_order'], 'outOfStock' => $item['out_of_stock'], 'stock_location' => $item['location'], 'quantity' => 1, // valor fijo para no consultar stock 'has_combination' => false, 'specificPrices' => [], // campo necesario aunque vacío 'image' => '', // omitimos imágenes 'tags' => [], // omitimos etiquetas ]; } return $results; }