getPositionPrices example


    public function getBasket($mergeProportional = true)
    {
        $shippingCosts = $this->getShippingCosts();

        $basket = $this->basket->sGetBasket();

        $currency = $this->get('shop')->getCurrency();

        $positions = $this->container->get(BasketHelperInterface::class)->getPositionPrices(
            new DiscountContext(
                $this->session->get('sessionId'),
                null,
                null,
                null,
                null,
                null,
                null,
                null
            )
        );

        
BasketQueryHelperInterface $basketQueryHelper
    ) {
        $this->basketQueryHelper = $basketQueryHelper;
        $this->calculator = $calculator;
    }

    /** * {@inheritdoc} */
    public function addProportionalDiscount(DiscountContext $discountContext)
    {
        $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(),
                
if ($voucherDetails['percental']) {
            $voucherValue = $voucherDetails['value'];
            $voucherName .= ' ' . $voucherValue . ' %';
            $voucherDetails['value'] = ($amount['totalAmount'] / 100) * (float) $voucherValue;
        }

        // Tax calculation for vouchers         [$taxRate$tax$voucherDetails$freeShipping] = $this->calculateVoucherValues($voucherDetails);

        if ($this->proportionalTaxCalculation && !$this->session->get('taxFree') && $voucherDetails['taxconfig'] === 'auto') {
            $taxCalculator = Shopware()->Container()->get('shopware.cart.proportional_tax_calculator');
            $prices = $this->basketHelper->getPositionPrices(
                new DiscountContext(
                    $this->session->get('sessionId'),
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null
                )
            );
            
Home | Imprint | This part of the site doesn't use cookies.