Managed Server
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: Coupon Modul: 100% vs. anzahl und uses per coupon

    ThYpHoOn

    • Neu im Forum
    • Beiträge: 39
    Moin,

    ich hatte eben das folgende Szenario im integrierten Gutscheinsystem:
    100% Gutschein auf einen Artikel bezogen mit maximaler Benutzung von 1 erstellt.
    Artikel 2x in den Warenkorb gelegt und Gutschein eingegeben.

    Erwartetes Verhalten:
    Artikel wird 1x zu 100% abgezogen.

    Aufgetretenes Verhalten:
    Artikel wurde 2x zu 100% abgezogen bzw. bezogen auf die Summe 100% des Artikel abgezogen.

    Quickfix (ohne Test von eventuellen Nebeneffekten):
    Datei includes/modules/order_total/ot_coupon.php
    Code: PHP  [Auswählen]
             // INFOS ‹BER DEN KUPON AUSLESEN
             //web28 -2011-11-06 - FIX: only active coupon
             $coupon_get = xtc_db_query("select coupon_amount, coupon_minimum_order,
                                                restrict_to_products, restrict_to_categories,
    -                                           coupon_type
    +                                           coupon_type, uses_per_coupon
                                           from "
    .TABLE_COUPONS."
                                           where coupon_code = '"
    .$coupon_result['coupon_code']."'
                                           and coupon_active = 'Y'
                                       "
    );
     
    und etwas weiter unten:
    Code: PHP  [Auswählen]
                      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!

    +                      // Only reduce the maximum uses of the coupon
    +                      if ($get_result['uses_per_coupon'] < $order->products[$i]['qty']) {
    +                        $pr_c -= $get_result['uses_per_coupon'] * $order->products[$i]['price'];
    +                      }

                          $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
     

    Vielleicht hilft es ja dem ein oder anderen der da auch schon drauf gestoßen ist oder noch drauf stößt.

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

    web28

    • modified Team
    • Beiträge: 9.404
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #1 am: 09. Mai 2013, 21:40:26
    Danke für die Info. Mit Deinem Fix erscheint es mir auch logischer.

    ThYpHoOn

    • Neu im Forum
    • Beiträge: 39
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #2 am: 09. Mai 2013, 21:55:10
    Hatte im Beitrag noch die Ergänzung im SELECT vergessen, ist nun hinzugefügt.

    Mir gefällt das im nach hinein runter rechnen nicht so ganz, ist halt nur ein Quickfix. Wenn es für die normale Nutzung sinnvoll/logisch erscheint kann das ja mal jemand ins Repo schubsen ;)

    Anbei mein kompletter Diff, sry für die Whitespace diffs...

    web28

    • modified Team
    • Beiträge: 9.404
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #3 am: 09. Mai 2013, 22:58:19
    Teste mal statt mit:
    Code: PHP  [Auswählen]
    if ($get_result['coupon_type'] == 'P') {
    $pr_c = $this->product_price($order->products[$i]['id']);

    mit
    Code: PHP  [Auswählen]
    if ($get_result['coupon_type'] == 'P') {
    $pr_c = $get_result['uses_per_coupon'] < $order->products[$i]['qty'] ? $order->products[$i]['price'] * (int)$get_result['uses_per_coupon'] : $order->products[$i]['final_price'];

    Damit wird nichts "nachher rausgerechnet" sondern direkt gesetzt

    ThYpHoOn

    • Neu im Forum
    • Beiträge: 39
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #4 am: 10. Mai 2013, 09:52:07
    Genau das war es was mir im Kopf schwebte. Klappt, danke :)

    xxhappyxx

    • Viel Schreiber
    • Beiträge: 829
    • Geschlecht:
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #5 am: 10. Mai 2013, 10:05:25
    Hallo ThYpHoOn hallo web28,

    Danke für das finden dieses Fehlers und den Fix. Leider werde ich aus der Diff-Datei nicht so recht schlau. Könntest du bitte deine ot_coupon.php hochladen?

    Gruß Thomas

     

    Modulfux

    • Experte
    • Beiträge: 3.590
    • Geschlecht:
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #6 am: 10. Mai 2013, 11:04:40
    Dann helfe ich mal eben aus.

    Suche:
    Code: PHP  [Auswählen]
    $coupon_get = xtc_db_query("
      select coupon_amount,
               coupon_minimum_order,
               restrict_to_products,
               restrict_to_categories,
               coupon_type
      from   "
    .TABLE_COUPONS."
      where coupon_code = '"
    . $coupon_result['coupon_code'] . "'
      and     coupon_active = 'Y'
    "
    );
     
    ersetze mit:
    Code: PHP  [Auswählen]
    $coupon_get = xtc_db_query("
      select coupon_amount,
               coupon_minimum_order,
               restrict_to_products,
               restrict_to_categories,
               coupon_type,
               uses_per_coupon
      from   "
    .TABLE_COUPONS."
      where coupon_code = '"
    . $coupon_result['coupon_code'] . "'
      and coupon_active = 'Y'
    "
    );
     

    suche:
    Code: PHP  [Auswählen]
    $pr_c = $this->product_price($order->products[$i]['id']); //web28- 2010-07-29 - $order->products[$i]['id']
     
    ersetze mit:
    Code: PHP  [Auswählen]
    $pr_c = $get_result['uses_per_coupon'] < $order->products[$i]['qty'] ? $order->products[$i]['price'] * (int)$get_result['uses_per_coupon'] : $order->products[$i]['final_price'];
     

    Gruß
    Ronny

    xxhappyxx

    • Viel Schreiber
    • Beiträge: 829
    • Geschlecht:
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #7 am: 10. Mai 2013, 11:26:03
    Hallo Ronny,

    Danke dafür.   :thumbs: Die Diff-Datei war mir ein wenig zu unübersichtlich.

    Gruß Thomas

    web28

    • modified Team
    • Beiträge: 9.404
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #8 am: 10. Mai 2013, 11:56:22
    Anmerkung: $pr_c= ... ist dreimal zu ersetzen

    Dann bitte folgendes testen - Festbetragcoupon:

    Suchen:
    Code: PHP  [Auswählen]
    $pr_c += $this->product_price($order->products[$i]['id']);

    jeweils ersetzen mit:
    Code: PHP  [Auswählen]
    $pr_c += $order->products[$i]['final_price'];

    Das sollte eigentlich funktionieren , die Klassenfunktion get_product_price() wird damit überflüssig und das Modul weniger fehleranfällig

    xxhappyxx

    • Viel Schreiber
    • Beiträge: 829
    • Geschlecht:
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #9 am: 10. Mai 2013, 12:05:30
    Hallo web28,

    dachte ich es mir doch. Ich war mir nicht sicher ob es nun 1x oder 3x zu erstetzen war. Daher meine Bitte um die geänderte Datei.

    Gruß Thomas

    web28

    • modified Team
    • Beiträge: 9.404
    Re: Coupon Modul: 100% vs. anzahl und uses per coupon
    Antwort #10 am: 10. Mai 2013, 13:42:28
    Bitte unbedingt alles testen!
    22 Antworten
    6810 Aufrufe
    26. April 2012, 13:45:50 von digicam
    3 Antworten
    3058 Aufrufe
    04. April 2012, 15:29:26 von Modfan
    3 Antworten
    2340 Aufrufe
    20. November 2013, 19:12:40 von astaller
               
    anything