Guten Morgen in die Runde,
ich hatte bei einem Shop das Problem, dass bei Neuanlage eines Coupons, mit zu berücksichtigender Kategorie, das Ganze einfach nicht so richtig funktioniert hatte.
Meine angegebene Kategorie wurde ignoriert. In dieser waren alle Produkte nur verlinkt und es handelte sich nicht um die Hauptkategorie.
Um das Ganze jetzt zum Fliegen zu bekommen habe ich zunächst in der ot_coupon.php folgende Anpassung gemacht (ca. Zeile 251):
//BOF - web28 - 2012-01-10 - new restrict_to_categories check
$cat_path = xtc_get_product_path_coupon(xtc_get_prid($order->products[$i]['id']));
Jetzt ist noch die Datei /inc/xtc_get_product_path.php um die Funktion xtc_get_product_path_coupon zu erweitern:
function xtc_get_product_path_coupon
($products_id) { //$cPath = ''; // BOF - Tomcraft - 2015-09-13 - Changed query to version from shop 2.00 to fix canonical for products in inactive categories //$category_query = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int)$products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0 limit 1"; $category_query = "SELECT p2c.categories_id
FROM " . TABLE_CATEGORIES
. " c
JOIN " . TABLE_PRODUCTS_TO_CATEGORIES
. " p2c
ON p2c.categories_id != '0'
AND p2c.categories_id = c.categories_id
AND c.categories_status = '1'
JOIN " . TABLE_PRODUCTS
." p
ON p.products_id = p2c.products_id
AND p.products_id = '" . (int
)$products_id . "'
AND p.products_status = '1'"; // EOF - Tomcraft - 2015-09-13 - Changed query to version from shop 2.00 to fix canonical for products in inactive categories $category_query = xtDBquery
($category_query); for ($i = 0; $i < xtc_db_num_rows
($category_query,true); ++$i) { $category = xtc_db_fetch_array
($category_query); $categories[] = $category["categories_id"]; } $cPath = implode('_', $categories); return $cPath; Mit dieser Funktion lese ich alle Kategorien eines Produktes aus.
So, das Ganze lief dann, bis auf die Kombination mit Sonderangeboten. Das wurde dann ganz merkwürdig.
Denn der eigentliche Rabatt wurde dann um den Rabatt eines Sonderangebotes wieder reduziert.
Beispiel:
20% auf alles in der Kategorie
1. Artikel: 500,00 EUR = 20% = 100 EUR
2. Artikel: 100,00 EUR (Sonderangebot) = 0%
Gesamt: 100,00 EUR
Leider kam dann folgendes Ergebnis:
1. Artikel: 500,00 EUR = 20% = 100 EUR
2. Artikel: 100,00 EUR (Sonderangebot) = 20,00
Gesamt: 80,00 EUR
Um das hinzubekommen habe ich in der ot_coupon.php folgende Änderungen gemacht (ab ca. Zeile 220):
//allowed products if ($get_result['restrict_to_products']) { $pr_ids = explode(",", $get_result['restrict_to_products']); for ($i = 0, $n = sizeof($order->products); $i < $n; ++$i) { for ($ii = 0, $nn = count($pr_ids); $ii < $nn; $ii ++) { if ($pr_ids[$ii] == xtc_get_prid
($order->products[$i]['id'])) { if ($get_result['coupon_type'] == 'P') { $pr_c = $this->product_price($order->products[$i]['id']); //web28- 2010-07-29 - $order->products[$i]['id'] //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; } else { $od_amount = $c_deduct; $pr_c += $this->product_price($order->products[$i]['id']); //web28- 2010-07-29 - FIX $order->products[$i]['id'] //web28- 2010-05-21 - FIX - restrict max coupon amount } } } } } //allowed categories if ($get_result['restrict_to_categories']) { $cat_ids = explode(",", $get_result['restrict_to_categories']); for ($i = 0, $n = sizeof($order->products); $i < $n; ++$i) { //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 //BOF - web28 - 2012-01-10 - new restrict_to_categories check $cat_path = xtc_get_product_path_coupon
(xtc_get_prid
($order->products[$i]['id'])); $prod_cat_ids_array = explode("_", $cat_path); for ($ii = 0 , $nn = count($cat_ids); $ii < $nn ; $ii ++) { if (in_array($cat_ids[$ii], $prod_cat_ids_array) && !$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 // hier prüfen wir ab, ob ein Sonderangebot in einer entsprechenden Kategorie drin ist. Falls ja, darf kein Rabatt berechnet werden! $product_query = "select specials_new_products_price from ".TABLE_SPECIALS
." where products_id = '".xtc_get_prid
($order->products[$i]['id'])."' and status=1"; $product_query = xtDBquery
($product_query); $product = xtc_db_fetch_array
($product_query, true); if($product['specials_new_products_price']) { $pod_amount = 0; } else { $pod_amount = round($pr_c*10)/10*$c_deduct/100; } $od_amount = $od_amount + $pod_amount; } 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 } } } //EOF - web28 - 2012-01-10 - new restrict_to_categories check } } if ($get_result['coupon_type'] == 'F' && $od_amount > $pr_c ) {$od_amount = $pr_c;} //web28- 2010-05-21 - FIX - restrict max coupon amount //EOF -web28- 2010-06-19 - FIX - new calculate coupon amount } else { if ($get_result['coupon_type'] != 'P') { $od_amount = $c_deduct; } else { $od_amount = $amount * $xtPrice->xtcCalculateCurr($get_result['coupon_amount']) / 100; //FIX - web28 - 2012-04-24 - calculate currencies } } So, jetzt läuft das Ganze bei mir im Shop soweit rund.
Falls es jemand braucht.
Für Rückfragen stehe ich Ihnen gerne zur Verfügung.
Beste Grüße
+ werk-statt +
Linkback: https://www.modified-shop.org/forum/index.php?topic=37572.0