Projekt

Allgemein

Profil

GX-Abgewiesen #64430 » ot_coupon_fix.patch

Moritz Bunjes, 04.10.2019 17:51

Unterschiede anzeigen:

src/includes/modules/order_total/ot_coupon.php (revision Shelved Version)
241 241
        $restrictToCategoriesIds = $this->parseIdList($couponDetails['restrict_to_categories']);
242 242
        if (!empty($restrictToProductIds || !empty($restrictToCategoriesIds))) {
243 243
            $restrictedProductTotal = 0.0;
244
            for ($i = 0, $iMax = sizeof($order->products); $i < $iMax; $i++) {
244
            foreach($order->products as $orderProduct) {
245 245
                if (!empty($restrictToProductIds)) {
246 246
                    foreach ($restrictToProductIds as $productId) {
247
                        if ((int)$productId === (int)xtc_get_prid($order->products[$i]['id'])) {
247
                        if ((int)$productId === (int)xtc_get_prid($orderProduct['id'])) {
248 248
                            if ($couponDetails['coupon_type'] === 'P') {
249
                                $pr_c       = $this->product_price($order->products[$i]['id']);
249
                                $pr_c       = $this->product_price($orderProduct['id']);
250 250
                                $pod_amount = round($pr_c * 100) / 100 * $c_deduct / 100;
251 251
                                $od_amount  += $pod_amount;
252 252
                            } else {
253
                                $restrictedProductTotal += $this->product_price($order->products[$i]['id']);
253
                                $restrictedProductTotal += $this->product_price($orderProduct['id']);
254 254
                                if ($restrictedProductTotal < $c_deduct) {
255 255
                                    $od_amount = $restrictedProductTotal;
256 256
                                } else {
......
260 260
                        }
261 261
                    }
262 262
                } else {
263
                    foreach($order->products as $orderProduct) {
264
                        $productsId = xtc_get_prid($orderProduct['id']);
265
                        $productCategories = $this->getProductCategoriesIds(new IdType((int)$productsId));
266
                        $categoriesIntersect = array_intersect($productCategories, $restrictToCategoriesIds);
267
                        if (!empty($categoriesIntersect)) {
268
                            if ($couponDetails['coupon_type'] === 'P') {
269
                                $pr_c       = $this->product_price($orderProduct['id']);
270
                                $pod_amount = round($pr_c * 10) / 10 * $c_deduct / 100;
271
                                $od_amount  += $pod_amount;
272
                            } else {
273
                                $restrictedProductTotal += $this->product_price($orderProduct['id']);
274
        
275
                                if ($restrictedProductTotal < $c_deduct) {
276
                                    $od_amount = $restrictedProductTotal;
277
                                } else {
278
                                    $od_amount = $c_deduct;
279
                                }
263
                    $productsId = xtc_get_prid($orderProduct['id']);
264
                    $productCategories = $this->getProductCategoriesIds(new IdType((int)$productsId));
265
                    $categoriesIntersect = array_intersect($productCategories, $restrictToCategoriesIds);
266
                    if (!empty($categoriesIntersect)) {
267
                        if ($couponDetails['coupon_type'] === 'P') {
268
                            $pr_c       = $this->product_price($orderProduct['id']);
269
                            $pod_amount = round($pr_c * 10) / 10 * $c_deduct / 100;
270
                            $od_amount  += $pod_amount;
271
                        } else {
272
                            $restrictedProductTotal += $this->product_price($orderProduct['id']);
273
    
274
                            if ($restrictedProductTotal < $c_deduct) {
275
                                $od_amount = $restrictedProductTotal;
276
                            } else {
277
                                $od_amount = $c_deduct;
280 278
                            }
281 279
                        }
282 280
                    }
......
535 533
                
536 534
                                    $t_gm_reduce_tax = $t_gm_original_tax_value - $t_gm_reduced_price_tax;
537 535
                                } else {
538
                                    $t_gm_net_discount_ratio = (($t_gm_od_amount * $t_gm_ratio) / (100 + $tax_rate)
539
                                                                * 100);
536
                                    $t_gm_net_discount_ratio = $t_gm_od_amount * $t_gm_ratio;
540 537
                                    $t_gm_reduced_price      = $valid_array[$p]['products_price']
541 538
                                                               - $t_gm_net_discount_ratio;
542 539
                                    $t_gm_reduced_price_tax  = $t_gm_reduced_price * ($tax_rate / 100);
(1-1/3)