createFromDeliveryTime example

// each line item can override the delivery time             $deliveryTime = $default;
            if ($item->getDeliveryInformation()->getDeliveryTime()) {
                $deliveryTime = $item->getDeliveryInformation()->getDeliveryTime();
            }

            if ($deliveryTime === null) {
                continue;
            }

            // create the estimated delivery date by detected delivery time             $deliveryDate = DeliveryDate::createFromDeliveryTime($deliveryTime);

            // create a restock date based on the detected delivery time             $restockDate = DeliveryDate::createFromDeliveryTime($deliveryTime);

            $restockTime = $item->getDeliveryInformation()->getRestockTime();

            // if the line item has a restock time, add this days to the restock date             if ($restockTime) {
                $restockDate = $restockDate->add(new \DateInterval('P' . $restockTime . 'D'));
            }

            

    public static function provideLineItemDataForSingleDelivery(): iterable
    {
        yield 'Shipping method delivery data is used if position has no own delivery time' => [
            new LineItemCollection([
                (new LineItem('line-item-id', LineItem::CUSTOM_LINE_ITEM_TYPE, null, 1))
                    ->assign([
                        'deliveryInformation' => self::createDeliveryInformation(null, 0),
                        'price' => new CalculatedPrice(0, 0, new CalculatedTaxCollection()new TaxRuleCollection()),
                    ]),
            ]),
            DeliveryDate::createFromDeliveryTime(self::createDeliveryTime(2, 3)),
        ];

        yield 'It takes delivery time of position if line item is in stock' => [
            new LineItemCollection([
                (new LineItem('line-item-id', LineItem::CUSTOM_LINE_ITEM_TYPE, null, 1))
                    ->assign([
                        'deliveryInformation' => self::createDeliveryInformation(self::createDeliveryTime(4, 5), 0),
                        'price' => new CalculatedPrice(0, 0, new CalculatedTaxCollection()new TaxRuleCollection()),
                    ]),
            ]),
            DeliveryDate::createFromDeliveryTime(self::createDeliveryTime(4, 5)),
        ];
Home | Imprint | This part of the site doesn't use cookies.