From 856bc430576a1a2050805f89f15a772935743dbc Mon Sep 17 00:00:00 2001 From: Mohammad Tomaraei Date: Wed, 24 Nov 2021 00:10:05 +0100 Subject: [PATCH] added the discount field --- src/catalog/controller/vsbridge/products.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/catalog/controller/vsbridge/products.php b/src/catalog/controller/vsbridge/products.php index cd87fca..b3e8dba 100644 --- a/src/catalog/controller/vsbridge/products.php +++ b/src/catalog/controller/vsbridge/products.php @@ -382,6 +382,11 @@ public function populateProducts($input){ // Add the 'sale' label if the product is on sale $product_array['sale'] = isset($special_price_incl_tax) ? '1' : '0'; + // Discount percentage + $product_array['discount'] = round( + 100 - (($product_array['final_price'] / $product_array['regular_price']) * 100) + ); + array_push($response, $product_array); } }