Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Fehler in ot_coupon.php wenn Artikel in mehreren Kategorien verlinkt ist

    decepter

    • Neu im Forum
    • Beiträge: 3
    Morgen zusammen,

    ich habe noch einen Fehler in der "/includes/modules/order_total/ot_coupon.php" entdeckt. Ich glaube den gibt es schon seit xt:Commerce Zeiten.

    Wenn man einen Artikel in mehreren Kategorien verlinkt hat, funktioniert der "Coupon auf Kategorie" nicht.
    Sprich der Artikel ist mehreren "Kategorie IDs" zugewiesen, der Coupon aber nur für eine der IDs gültig. Somit greift der Coupon nicht. Hat jemand das gleiche Problem bzw. schon lösen können?

    Mit der Gutschein- und Kupon-Erweiterung Lösung von Xtc-Load funktioniert es. Aber einfach drüber bügeln ist ja auch nicht die Lösung. ;)

    Der Fehler müsste hier in der den Teil liegen:

    Code: PHP  [Auswählen]
                //allowed categories
                if ($get_result['restrict_to_categories']) {
                  $cat_ids = explode(",", $get_result['restrict_to_categories']); // Hetfield - 2009-08-18 - replaced depricated function split with explode to be ready for PHP >= 5.3

                  for ($i = 0; $i < sizeof($order->products); $i ++) {
                    $my_path = xtc_get_product_path(xtc_get_prid($order->products[$i]['id']));
                    $sub_cat_ids = explode("_", $my_path); // Hetfield - 2009-08-18 - replaced depricated function split with explode to be ready for PHP >= 5.3

                    //BOF - web28 - 2010-06-19 - test for product_id to prevent double counting
                    if ($get_result['restrict_to_products']  && in_array(xtc_get_prid($order->products[$i]['id']) ,$pr_ids) ) {
                      $p_flag = true;
                    } else $p_flag = false;
                    //EOF - web28 - 2010-06-19 - test for product_id to prevent double counting

                    for ($iii = 0; $iii < count($sub_cat_ids); $iii ++) {
                      for ($ii = 0; $ii < count($cat_ids); $ii ++) {
                        if ($sub_cat_ids[$iii] == $cat_ids[$ii] && !$p_flag) {
                          if ($get_result['coupon_type'] == 'P') {
                            $pr_c = $this->product_price($order->products[$i]['id']);//web28- 2010-07-29 - FIX no xtc_get_prid  //Fred 2003-10-28, fix for the row above, otherwise the discount is calc based on price excl VAT!
                            $pod_amount = round($pr_c*10)/10*$c_deduct/100;
                            $od_amount = $od_amount + $pod_amount;
                            continue 3;      // v5.13a Tanaka 2005-4-30: to prevent double counting of a product discount
                          } else {
                            $od_amount = $c_deduct;
                            $pr_c += $this->product_price($order->products[$i]['id']);  //web28- 2010-07-29 - FIX no xtc_get_prid  //web28- 2010-05-21 - FIX - restrict  max coupon amount
                            continue 3;
                          }
                        }
                      }
                    }
                  }
                }

    Hier der Teil aus der ot_coupon.php von xtc-load:

    Code: PHP  [Auswählen]
            // SCHLEIFE FÜR ALLE PRODUKTE IM KORB
                    $products = $_SESSION['cart']->get_products();                 
                    for ($i = 0; $i < sizeof($products); $i ++) {
                           
                            // GRUNDFORM DER ARTIKELNUMMER
                            $t_prid = xtc_get_prid($products[$i]['id']);

                            // KUPONS OHNE BESCHRÄNKUNGEN : RABATT-SUMME ANHAND ALLER ARTIKEL IM KORB BERECHNEN
                            if ($coupon_result['restrict_to_categories'] == '' && $coupon_result['restrict_to_products'] == '') {
                                    $products_price = $this->get_products_price($t_prid, $products[$i]['id']);
                                    $order_total += $_SESSION['cart']->contents[$products[$i]['id']]['qty'] * $products_price[0];
                                    $this->sum_tax["$products_price[1]"] += $_SESSION['cart']->contents[$products[$i]['id']]['qty'] * $products_price[0];

                            // BESCHRÄNKUNG AUF KATEGORIEN : RABATT-SUMME ANHAND GÜLTIGER ARTIKEL BERECHNEN
                            } else if ($coupon_result['restrict_to_categories'] != '') {
                                    $product_found = false;
                                    $cat_ids = split("[,]", $coupon_result['restrict_to_categories']);
                                    // SCHLEIFE FÜR ALLE GÜLTIGEN KATEGORIEN
                                    for ($ii = 0; $ii < count($cat_ids); $ii ++) {
                                            // IN DER AKTUELLEN KATEGORIE NACH UNTERKATEGORIEN SUCHEN
                                            $subcat_ids = array ();
                                            require_once (DIR_FS_INC . 'xtc_get_subcategories.inc.php');
                                            xtc_get_subcategories($subcat_ids, $cat_ids[$ii]);     
                                            // WENN UNTERKATEGORIEN VORHANDEN SIND, AUCH DIESE DURCHSUCHEN
                                            if (sizeof($subcat_ids) > 0) {
                                                    for ($iii = 0; $iii < sizeof($subcat_ids); $iii ++) {
                                                            $cat_query = xtc_db_query("select products_id from products_to_categories where products_id = '" . $t_prid . "' and (categories_id = '" . $cat_ids[$ii] . "' or categories_id = '" . $subcat_ids[$iii] . "')");
                                                            if (xtc_db_num_rows($cat_query) != 0  && $product_found == false) {
                                                                    $products_price = $this->get_products_price($t_prid, $products[$i]['id']);
                                                                    $order_total += $_SESSION['cart']->contents[$products[$i]['id']]['qty'] * $products_price[0];
                                                                    $this->sum_tax["$products_price[1]"] += $_SESSION['cart']->contents[$products[$i]['id']]['qty'] * $products_price[0];
                                                                    $product_found = true;
                                                            }
                                                    }
                                            // KEINE UNTERKATEGORIEN VORHANDEN, DANN NUR HAUPTKATEGORIE DURCHSUCHEN
                                            } else {                               
                                                    $cat_query = xtc_db_query("select products_id from products_to_categories where products_id = '" . $t_prid . "' and categories_id = '" . $cat_ids[$ii] . "'");
                                                    if (xtc_db_num_rows($cat_query) != 0  && $product_found == false) {
                                                            $products_price = $this->get_products_price($t_prid, $products[$i]['id']);
                                                            $order_total += $_SESSION['cart']->contents[$products[$i]['id']]['qty'] * $products_price[0];
                                                            $this->sum_tax["$products_price[1]"] += $_SESSION['cart']->contents[$products[$i]['id']]['qty'] * $products_price[0];
                                                            $product_found = true;
                                                    }
                                            }
                                    }
                   
                            // BESCHRÄNKUNG AUF PRODUKTE : RABATT-SUMME ANHAND GÜLTIGER ARTIKEL BERECHNEN
                            } else if ($coupon_result['restrict_to_products'] != '') {
                                    $pr_ids = split("[,]", $coupon_result['restrict_to_products']);
                                    // SCHLEIFE FÜR ALLE GÜLTIGEN PRODUKTE
                                    for ($ii = 0; $ii < count($pr_ids); $ii ++) {
                                            if ($t_prid == $pr_ids[$ii]){  
                                                    $products_price = $this->get_products_price($t_prid, $products[$i]['id']);
                                                    $order_total += $_SESSION['cart']->contents[$products[$i]['id']]['qty'] * $products_price[0];
                                                    $this->sum_tax["$products_price[1]"] += $_SESSION['cart']->contents[$products[$i]['id']]['qty'] * $products_price[0];
                                            }
                                    }
                            }              
                    }


    Linkback: https://www.modified-shop.org/forum/index.php?topic=18127.0

    decepter

    • Neu im Forum
    • Beiträge: 3
    Nutzt keiner von euch die Coupon-Funktion in Bezug auf Kategorien? :-(
    4 Antworten
    5975 Aufrufe
    06. Dezember 2012, 14:45:40 von Martin84
    5 Antworten
    3111 Aufrufe
    01. April 2014, 13:03:19 von VoxlWolf
               
    anything