$firstDelivery =
$deliveries->
first();
if ($firstDelivery === null
) { return;
} // Stored original edit shipping cost
$manualShippingCosts =
$toCalculate->
getExtension(self::MANUAL_SHIPPING_COSTS
) ??
$firstDelivery->
getShippingCosts();
$toCalculate->
addExtension(self::MANUAL_SHIPPING_COSTS,
$manualShippingCosts);
if ($manualShippingCosts instanceof CalculatedPrice
) { $firstDelivery->
setShippingCosts($manualShippingCosts);
} $this->deliveryCalculator->
calculate($data,
$toCalculate,
$deliveries,
$context);
$toCalculate->
setDeliveries($deliveries);
return;
} $deliveries =
$this->builder->
build($toCalculate,
$data,
$context,
$behavior);
$manualShippingCosts =
$original->
getExtension(self::MANUAL_SHIPPING_COSTS
);