1. Dashboard
  2. Artikel
  3. Forum
    1. Unerledigte Themen
  4. Bugtracker
    1. Ticketübersicht
    2. Roadmap
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Forum
  • Artikel
  • Seiten
  • Bugtracker
  • Erweiterte Suche
  1. commerce:seo Support
  2. Ticketübersicht

Rabatt wird falsch berechnet

  • 0000037
  • Googlebug
  • Googlebug
  • 5.5.06
  • 22. Dezember 2025 um 15:19
  • 10. Februar 2026 um 11:43
  • Erledigt

Wichtig

eingesetzte Version
V5
Fehlerbeschreibung
Rabatt wird falsch berechnet

Beschreibung

Ich habe lange gesucht und nicht gefunden ob man das eventuell im Backend einstellen kann.

1. Versand wird mit rabattiert. Das ist zwar nicht zwangsläufig falsch aber wenn man das nicht raus nehmen kann, dann ist es doch falsch.

2. Ich habe einen normalen 5% Coupon angelegt. Der Rabatt wird wie folgt berechnet:

Warenwert (Netto) + Versand (Netto) - 5% (Brutto)

Diese Rechnung stimmt so nicht. Wenn 5% Brutto abgezogen wird, dann natürlich auch von den Brutto Werten.


Ich habe das per Overload überschrieben:

PHP
<?php/* --------------------------------------------------------------  Myot_coupon.inc.php 2025-12-22 @Googlebug  B2BWeb - Ralf Hillmann  http://www.b2b-web.de  Copyright (c) 2025 B2BWeb  Released under the GNU General Public License (Version 2)  [http://www.gnu.org/licenses/gpl-2.0.html]Mit dieser Overload wird die Berechnung des Shops korrigiert. Ohne diese Datei wird bei Rabatt-Coupon`s vom Netto-Wert Produktsumme (Netto) + Versand (Netto) - Rabatt (Brutto) berechnet.Um Versand wieder in die Rabatt-Berechnung mit rein zu nehmen: private $b2bweb_shipping_discount = true;  --------------------------------------------------------------*/class Myot_coupon extends Myot_coupon_parent{    /**     * B2BWeb: Konfigurationsvariable     * true = Versandkosten werden rabattiert     * false = Versandkosten werden NICHT rabattiert     */    private $b2bweb_shipping_discount = false;    /**     * B2BWeb: Überschreibt die zentrale Logik, um die Berechnungsbasis für den Rabatt zu korrigieren.     */    protected function calculateAmountToBeDiscounted(): float    {        if (!$this->isCouponValid()) {            return 0;        }        $amountToBeDiscounted = 0;        $products = $this->getFilteredProducts();        $couponNeedsGross = $this->doesCouponIncludeTax();        if ($couponNeedsGross) {            // B2BWeb: Kupon ist Brutto. Wir bauen die Brutto-Basis.                        // 1. Produkte            foreach ($products as $product) {                // Debugging hat gezeigt, dass $product['final_price'] bereits der Brutto-Preis ist.                $price = $product['final_price'];                $amountToBeDiscounted += $this->applyTotalOrderValueDiscount($price);            }            // 2. Versandkosten            if ($this->shouldShippingCostsBeIncluded()) {                $shippingCosts = $this->getXtcPrice()->xtcCalculateCurr($GLOBALS['order']->info['shipping_cost']);                // Sicherstellen, dass die Versandkosten Brutto sind                if ($this->doShippingCostsIncludeNoTax()) { // true wenn Netto                    $shippingCosts = $this->addTax($shippingCosts, $this->getTaxRate($this->getShippingTaxClassId()));                }                $amountToBeDiscounted += $shippingCosts;            }        } else {            // B2BWeb: Kupon ist Netto. Original-Logik verwenden.            foreach ($products as $product) {                $finalPrice           = $this->calculateProductPrice($product);                $amountToBeDiscounted += $finalPrice;            }                        if ($this->shouldShippingCostsBeIncluded()) {                $amountToBeDiscounted += $this->getShippingCosts();            }        }                return $amountToBeDiscounted;    }    /**     * B2BWeb: Korrigierte Preisberechnung für einzelne Produkte (wird für prozentuale Rabatte genutzt).     */    protected function calculateProductPrice($product): float    {        $finalPrice = $product['final_price'];                // B2BWeb: Fix for double tax deduction        // If coupon needs gross prices and prices are already gross, do NOT remove tax.        if ($this->doesCouponIncludeTax() && $this->displayedPricesIncludeTax()) {             // Do nothing, price is already gross        } else {            // Original logic            if (!$this->displayedPricesIncludeTax() && $this->considerTaxForAmountToBeDiscounted()) {                $finalPrice = $this->addTax($finalPrice, $product['tax']);            } elseif ($this->displayedPricesIncludeTax() && !$this->considerTaxForAmountToBeDiscounted()) {                $finalPrice = $this->removeTax($finalPrice, $product['tax']);            }        }                return $this->applyTotalOrderValueDiscount($finalPrice);    }    /**     * B2BWeb: Korrigierte Versandkostenberechnung (wird für prozentuale Rabatte genutzt).     */    protected function getShippingCosts(): float    {        $shippingCosts = $this->getXtcPrice()->xtcCalculateCurr($GLOBALS['order']->info['shipping_cost']);        $couponNeedsGross = $this->doesCouponIncludeTax();        $shippingIsNetto = $this->doShippingCostsIncludeNoTax();        if ($couponNeedsGross && $shippingIsNetto) {            // Kupon will Brutto, Versand ist Netto -> Steuer drauf            $shippingCosts = $this->addTax($shippingCosts, $this->getTaxRate($this->getShippingTaxClassId()));        } elseif (!$couponNeedsGross && !$shippingIsNetto) {            // Kupon will Netto, Versand ist Brutto -> Steuer runter            $shippingCosts = $this->removeTax($shippingCosts, $this->getTaxRate($this->getShippingTaxClassId()));        }        // In allen anderen Fällen (Brutto/Brutto oder Netto/Netto) passt der Preis schon.        return $shippingCosts;    }    /**     * B2BWeb: Versandkosten sollen NIE rabattiert werden.     * Wir überschreiben diese Methode und geben immer false zurück.     */    protected function shouldShippingCostsBeIncluded(): bool    {        // B2BWeb: Alten Code auskommentieren (gibt es hier nicht, da neue Methode)        return $this->b2bweb_shipping_discount;    }}

So schaut das richtig aus. Aber eventuell war das ja auch für umsonst, da man es im Shop doch irgend wie einstellen kann.

Eintrags-Beziehungen

Kommentare 1

admin
10. Februar 2026 um 11:43
  • Inhalt melden

Es muss die korrekte Reichenfolge definiert sein. ot_coupon liegt bei mir auf der 31.

Zu Ticket springen

Ticket-ID
  1. Datenschutzerklärung
  2. Impressum
Community-Software: WoltLab Suite™