Edit delivery method in CheckouController does not work

Hi

I am trying to update the value for the delivery method in the API CheckoutController in the PlaceOrder() method. I need to remove the delivery costs based on some settings on the channel.

I tried something like this

var delivery = orderCarrier.Deliveries.Where(x => x.DeliveryMethodID == Guid.Parse(deliveryMethodId)).FirstOrDefault();

 var payload = new DeliveryPayloadInfo
                {
                    DeliveryCost = 0,
                    DeliveryCostWithVAT = 0,
                    DeliveryVatPercentage = 0,
                    DeliveryMethodId = delivery.DeliveryMethodID,
                    DeliveryAddress = delivery.Address,
                };
                _moduleECommerce.CheckoutFlow.EditDelivery(orderCarrier, delivery.DeliveryMethodID, payload, _moduleECommerce.AdminToken);

But I get this error:
System.ArgumentException: ‘Delivery ID is not found in order.
Parameter name: deliveryCarrierIdToEdit’.

I checked and the orderCarrier has a delivery method that has a DeliveryMethodId.
What can I do to solve this issue?

Litium version: [7.3.3]

you are passing delivery method id to EditDelivery and not the delivery Id.

Thank you! Now I do not get the error message, but the delivery methods costs are still not updated.
I was thinking to try something like this, directly on the deliveryCarrier.

 deliveryCarrier.DeliveryCost = 0;
  deliveryCarrier.DeliveryCostWithVAT = 0;
  deliveryCarrier.TotalDeliveryCost = 0;
  deliveryCarrier.DeliveryCostWithVAT = 0;
type or paste code here

i think perhaps this is better to do in a deliverycostcalculator it is possible that your changes are overwritten if cart value is calculated.

Thanks !
That worked

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.