Index: src/includes/modules/order_total/ot_coupon.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/includes/modules/order_total/ot_coupon.php	(revision Local Version)
+++ src/includes/modules/order_total/ot_coupon.php	(revision Shelved Version)
@@ -241,16 +241,16 @@
         $restrictToCategoriesIds = $this->parseIdList($couponDetails['restrict_to_categories']);
         if (!empty($restrictToProductIds || !empty($restrictToCategoriesIds))) {
             $restrictedProductTotal = 0.0;
-            for ($i = 0, $iMax = sizeof($order->products); $i < $iMax; $i++) {
+            foreach($order->products as $orderProduct) {
                 if (!empty($restrictToProductIds)) {
                     foreach ($restrictToProductIds as $productId) {
-                        if ((int)$productId === (int)xtc_get_prid($order->products[$i]['id'])) {
+                        if ((int)$productId === (int)xtc_get_prid($orderProduct['id'])) {
                             if ($couponDetails['coupon_type'] === 'P') {
-                                $pr_c       = $this->product_price($order->products[$i]['id']);
+                                $pr_c       = $this->product_price($orderProduct['id']);
                                 $pod_amount = round($pr_c * 100) / 100 * $c_deduct / 100;
                                 $od_amount  += $pod_amount;
                             } else {
-                                $restrictedProductTotal += $this->product_price($order->products[$i]['id']);
+                                $restrictedProductTotal += $this->product_price($orderProduct['id']);
                                 if ($restrictedProductTotal < $c_deduct) {
                                     $od_amount = $restrictedProductTotal;
                                 } else {
@@ -260,23 +260,21 @@
                         }
                     }
                 } else {
-                    foreach($order->products as $orderProduct) {
-                        $productsId = xtc_get_prid($orderProduct['id']);
-                        $productCategories = $this->getProductCategoriesIds(new IdType((int)$productsId));
-                        $categoriesIntersect = array_intersect($productCategories, $restrictToCategoriesIds);
-                        if (!empty($categoriesIntersect)) {
-                            if ($couponDetails['coupon_type'] === 'P') {
-                                $pr_c       = $this->product_price($orderProduct['id']);
-                                $pod_amount = round($pr_c * 10) / 10 * $c_deduct / 100;
-                                $od_amount  += $pod_amount;
-                            } else {
-                                $restrictedProductTotal += $this->product_price($orderProduct['id']);
-        
-                                if ($restrictedProductTotal < $c_deduct) {
-                                    $od_amount = $restrictedProductTotal;
-                                } else {
-                                    $od_amount = $c_deduct;
-                                }
+                    $productsId = xtc_get_prid($orderProduct['id']);
+                    $productCategories = $this->getProductCategoriesIds(new IdType((int)$productsId));
+                    $categoriesIntersect = array_intersect($productCategories, $restrictToCategoriesIds);
+                    if (!empty($categoriesIntersect)) {
+                        if ($couponDetails['coupon_type'] === 'P') {
+                            $pr_c       = $this->product_price($orderProduct['id']);
+                            $pod_amount = round($pr_c * 10) / 10 * $c_deduct / 100;
+                            $od_amount  += $pod_amount;
+                        } else {
+                            $restrictedProductTotal += $this->product_price($orderProduct['id']);
+    
+                            if ($restrictedProductTotal < $c_deduct) {
+                                $od_amount = $restrictedProductTotal;
+                            } else {
+                                $od_amount = $c_deduct;
                             }
                         }
                     }
@@ -535,8 +533,7 @@
                 
                                     $t_gm_reduce_tax = $t_gm_original_tax_value - $t_gm_reduced_price_tax;
                                 } else {
-                                    $t_gm_net_discount_ratio = (($t_gm_od_amount * $t_gm_ratio) / (100 + $tax_rate)
-                                                                * 100);
+                                    $t_gm_net_discount_ratio = $t_gm_od_amount * $t_gm_ratio;
                                     $t_gm_reduced_price      = $valid_array[$p]['products_price']
                                                                - $t_gm_net_discount_ratio;
                                     $t_gm_reduced_price_tax  = $t_gm_reduced_price * ($tax_rate / 100);
