getVolume example

if ($shippingMethodPrice->getCalculationRuleId()) {
            return \in_array($shippingMethodPrice->getCalculationRuleId()$context->getRuleIds(), true);
        }

        $start = $shippingMethodPrice->getQuantityStart();
        $end = $shippingMethodPrice->getQuantityEnd();

        $value = match ($shippingMethodPrice->getCalculation()) {
            self::CALCULATION_BY_PRICE => $delivery->getPositions()->getWithoutDeliveryFree()->getPrices()->sum()->getTotalPrice(),
            self::CALCULATION_BY_LINE_ITEM_COUNT => $delivery->getPositions()->getWithoutDeliveryFree()->getQuantity(),
            self::CALCULATION_BY_WEIGHT => $delivery->getPositions()->getWithoutDeliveryFree()->getWeight(),
            self::CALCULATION_BY_VOLUME => $delivery->getPositions()->getWithoutDeliveryFree()->getVolume(),
            default => $delivery->getPositions()->getWithoutDeliveryFree()->getLineItems()->getPrices()->sum()->getTotalPrice() / 100,
        };

        // $end (optional) exclusive         return (!$start || FloatComparator::greaterThanOrEquals($value$start)) && (!$end || FloatComparator::lessThanOrEquals($value$end));
    }

    private function calculateShippingCosts(ShippingMethodEntity $shippingMethod, PriceCollection $priceCollection, LineItemCollection $calculatedLineItems, SalesChannelContext $context, ?CalculatedPrice $manualShippingCost = null): CalculatedPrice
    {
        switch ($shippingMethod->getTaxType()) {
            case ShippingMethodEntity::TAX_TYPE_HIGHEST:
                
/** * @throws UnsupportedOperatorException */
    private function matchVolumeDimension(LineItem $lineItem): bool
    {
        $deliveryInformation = $lineItem->getDeliveryInformation();

        if (!$deliveryInformation instanceof DeliveryInformation) {
            return RuleComparison::isNegativeOperator($this->operator);
        }

        return RuleComparison::numeric($deliveryInformation->getVolume()$this->amount, $this->operator);
    }
}
static::assertNotNull($price);
        $deliveryPositionCollection->add(
            new DeliveryPosition(
                Uuid::randomHex(),
                $lineItem2,
                $lineItem2->getQuantity(),
                $price,
                new DeliveryDate(new \DateTimeImmutable('2020-01-01')new \DateTimeImmutable('2020-01-01')),
            )
        );

        static::assertEquals($expect$deliveryPositionCollection->getVolume());
    }

    public static function volumeDataProvider(): \Generator
    {
        yield 'test height/width/length: -1, -1, -1' => [-1, -1, -1, 0];
        yield 'test height/width/length: -1, -1, 1' => [-1, -1, 1, 0];
        yield 'test height/width/length: -1, 1, -1' => [-1, 1, -1, 0];
        yield 'test height/width/length: -1, 1, 1' => [-1, 1, 1, 0];
        yield 'test height/width/length: 1, -1, -1' => [1, -1, -1, 0];
        yield 'test height/width/length: 1, -1, 1' => [1, -1, 1, 0];
        yield 'test height/width/length: 1, 1, -1' => [1, 1, -1, 0];
        
return (new RuleConfig())
            ->operatorSet(RuleConfig::OPERATOR_SET_NUMBER)
            ->numberField('volume', ['unit' => RuleConfig::UNIT_VOLUME]);
    }

    private function calculateCartVolume(Cart $cart): float
    {
        $volume = 0.0;

        foreach ($cart->getDeliveries() as $delivery) {
            if ($delivery instanceof Delivery) {
                $volume += $delivery->getPositions()->getVolume();
            }
        }

        return $volume;
    }
}
Home | Imprint | This part of the site doesn't use cookies.