From 5802ab415b4b42d6b277fcc0db7447adb3ae66a4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 16 Oct 2023 15:58:07 +0700 Subject: Fix variant solr map --- src/pages/api/shop/variant.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/pages/api') diff --git a/src/pages/api/shop/variant.js b/src/pages/api/shop/variant.js index 30213cc3..302b5d4a 100644 --- a/src/pages/api/shop/variant.js +++ b/src/pages/api/shop/variant.js @@ -103,17 +103,12 @@ const escapeSolrQuery = (query) => { const productResponseMap = (products, pricelist) => { return products.map((product) => { - let price = product.price_f || 0 - let priceDiscount = product.price_discount_f || 0 - let discountPercentage = product.discount_f || 0 + let price = product.price_tier1_v2_f || 0 + let priceDiscount = 0 + let discountPercentage = 0 - if (pricelist) { - const pricelistDiscount = product?.[`price_${pricelist}_f`] || false - const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false - - if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount - if (pricelistDiscountPerc && pricelistDiscountPerc > 0) - discountPercentage = pricelistDiscountPerc + if (pricelist && product?.[`price_${pricelist}_f`] < price) { + price = product?.[`price_${pricelist}_f`] || 0 } if (product?.flashsale_id_i > 0) { -- cgit v1.2.3