recalculatePercentageDiscount example


        $prices = $this->getPositionPrices($discountContext);
        $hasMultipleTaxes = $this->calculator->hasDifferentTaxes($prices);

        if ($discountContext->getDiscountType() === self::DISCOUNT_ABSOLUTE) {
            $discounts = $this->calculator->calculate(
                $discountContext->getDiscountValue(),
                $prices,
                $discountContext->isNetPrice()
            );
        } else {
            $discounts = $this->calculator->recalculatePercentageDiscount(
                $discountContext->getDiscountValue(),
                $prices,
                $discountContext->isNetPrice()
            );
        }

        $discountBaseName = $discountContext->getDiscountName();
        /** @var Price $discount */
        foreach ($discounts as $discount) {
            $discountContext->setPrice($discount);
            $discountContext->setDiscountName(
                
null,
                    null,
                    null,
                    null,
                    null,
                    null
                )
            );
            $hasMultipleTaxes = $taxCalculator->hasDifferentTaxes($prices);

            if ($voucherDetails['percental']) {
                $voucherPrices = $taxCalculator->recalculatePercentageDiscount(-$voucherValue$prices, !$this->sSYSTEM->sUSERGROUPDATA['tax'] && $this->sSYSTEM->sUSERGROUPDATA['id']);
            } else {
                $voucherPrices = $taxCalculator->calculate($voucherDetails['value']$prices, !$this->sSYSTEM->sUSERGROUPDATA['tax'] && $this->sSYSTEM->sUSERGROUPDATA['id']);
            }

            $voucherPrices = $this->eventManager->filter(
                'Shopware_Modules_Basket_AddVoucher_VoucherPrices',
                $voucherPrices,
                [
                    'subject' => $this,
                    'voucher' => $voucherDetails,
                    'vouchername' => $voucherName,
                    
Home | Imprint | This part of the site doesn't use cookies.