Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original cart deliveries are changed in DeliveryProcessor #3664

Open
nexxome opened this issue Apr 12, 2024 · 1 comment
Open

Original cart deliveries are changed in DeliveryProcessor #3664

nexxome opened this issue Apr 12, 2024 · 1 comment
Labels

Comments

@nexxome
Copy link
Contributor

nexxome commented Apr 12, 2024

PHP Version

8.2

Shopware Version

6.5.8.8

Expected behaviour

The original cart should not be changed in cart processors

Actual behaviour

Deliveries in the original cart are changed in DeliveryProcessor

How to reproduce

For example convert an existing order to a cart and run the processors:

$cart = $this->orderConverter->convertToCart($existingOrder, $context); $behavior = new CartBehavior($salesChannelContext->getPermissions()); $cart = $this->processor->process($cart, $salesChannelContext, $behavior);

The deliveries from the original cart should be cloned and not changed for the calculation of the new cart:

`
$deliveries = $original->getDeliveries();
$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);

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant