# Edit delivery method in CheckouController does not work

**URL:** <https://forum.litium.com/t/edit-delivery-method-in-checkoucontroller-does-not-work/3003>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [June 28, 2023, 4:15pm UTC](https://forum.litium.com/t/edit-delivery-method-in-checkoucontroller-does-not-work/3003 "2023-06-28T16:15:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreeanenciu](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@andreeanenciu](https://forum.litium.com/u/andreeanenciu)\
**Post date:** [June 28, 2023, 4:15pm UTC](https://forum.litium.com/t/edit-delivery-method-in-checkoucontroller-does-not-work/3003/1 "2023-06-28T16:15:57Z")

</div>

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

```auto
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]_

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [June 28, 2023, 8:59pm UTC](https://forum.litium.com/t/edit-delivery-method-in-checkoucontroller-does-not-work/3003/2 "2023-06-28T20:59:59Z")

</div>

> [@andreeanenciu](#):
>
> `_moduleECommerce.CheckoutFlow.EditDelivery(orderCarrier, delivery.DeliveryMethodID, payload, _moduleECommerce.AdminToken);`

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

---

<div class="post-metadata">

**Author:** ![andreeanenciu](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@andreeanenciu](https://forum.litium.com/u/andreeanenciu)\
**Post date:** [June 29, 2023, 7:00am UTC](https://forum.litium.com/t/edit-delivery-method-in-checkoucontroller-does-not-work/3003/3 "2023-06-29T07:00:26Z")

</div>

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.

```auto
 deliveryCarrier.DeliveryCost = 0;
  deliveryCarrier.DeliveryCostWithVAT = 0;
  deliveryCarrier.TotalDeliveryCost = 0;
  deliveryCarrier.DeliveryCostWithVAT = 0;

```

```auto
type or paste code here

```

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [June 29, 2023, 7:38am UTC](https://forum.litium.com/t/edit-delivery-method-in-checkoucontroller-does-not-work/3003/4 "2023-06-29T07:38:51Z")

</div>

> [@andreeanenciu](#):
>
> 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.

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

> **[Add a delivery cost](https://docs.litium.com/platform/previous-versions/litium-7/litium-documentation/sales/pricing_rules_1/delivery_costs/add-delivery-cost)**
>
> Add a delivery cost

---

<div class="post-metadata">

**Author:** ![andreeanenciu](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@andreeanenciu](https://forum.litium.com/u/andreeanenciu)\
**Post date:** [June 29, 2023, 2:38pm UTC](https://forum.litium.com/t/edit-delivery-method-in-checkoucontroller-does-not-work/3003/5 "2023-06-29T14:38:22Z")

</div>

Thanks !  
That worked

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [July 27, 2023, 2:38pm UTC](https://forum.litium.com/t/edit-delivery-method-in-checkoucontroller-does-not-work/3003/6 "2023-07-27T14:38:29Z")

</div>

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