addProportionalDiscount example

$currencyFactor = empty($this->system->sCurrency['factor']) ? 1 : $this->system->sCurrency['factor'];
        $taxFree = empty($this->system->sUSERGROUPDATA['tax']) && !empty($this->system->sUSERGROUPDATA['id']);
        $sessionId = $this->session->get('sessionId');

        if ($taxFree) {
            $netPrice = $price;
        } else {
            $netPrice = round($price / (100 + $tax) * 100, 2);
        }

        if (!$taxFree && $this->config->get('proportionalTaxCalculation')) {
            $this->basketHelper->addProportionalDiscount(
                new DiscountContext(
                    $sessionId,
                    BasketHelperInterface::DISCOUNT_ABSOLUTE,
                    $price,
                    $name,
                    $orderNumber,
                    $mode,
                    $currencyFactor,
                    $taxFree
                )
            );
        }

                'subject' => $this,
                'discount' => $params,
            ]
        );

        if ($notifyUntilBeforeAdd) {
            return;
        }

        if ($this->proportionalTaxCalculation && !$this->session->get('taxFree')) {
            $this->basketHelper->addProportionalDiscount(
                new DiscountContext(
                    $this->session->get('sessionId'),
                    BasketHelperInterface::DISCOUNT_PERCENT,
                    -$basketDiscount,
                    $discountName,
                    $name,
                    3,
                    $this->sSYSTEM->sCurrency['factor'],
                    !$this->sSYSTEM->sUSERGROUPDATA['tax'] && $this->sSYSTEM->sUSERGROUPDATA['id']
                )
            );
        }
Home | Imprint | This part of the site doesn't use cookies.