Custom shipping cost for SRO

I’m trying to set a custom delivery cost for a SRO delivery, but it won’t update.

I’m trying with the following code:

var order = _moduleECommerce.Orders.GetOrder(sroId, _moduleECommerce.AdminToken);
if (order == null || order.Type != OrderType.SalesReturnOrder)
{
     return;
}

var orderCarrier = order.GetAsCarrier(false, true, false, false, false, false);
var delivery = orderCarrier.Deliveries.FirstOrDefault();

delivery.IsCustomDeliveryCost = true;
delivery.VATPercentage = 0;
delivery.DeliveryCost = Math.Abs(shippingCost);
delivery.DeliveryCostWithVAT = 0;
delivery.KeepDeliveryCostWithVatConstant = true;
orderCarrier.TotalDeliveryCost = Math.Abs(shippingCost);
orderCarrier.TotalDeliveryCostVAT = 0;

Litium version: 7.6.2

Try with this:

var deliveryCarrier = delivery.GetAsCarrier().Clone();

Update the deliveryCarrier instead.

Thanks, but makes no difference…
Do I have to save the delivery after I changed the cost, somehow?

Note, this is for a SRO delivery.
I try to the set the delivery cost before confirming the return (before calling /action/confirmReturn), is this correct?

You need to change the delivery cost by creating an override to the SRO calculator, see this example:
Refund amount (litium.com)

Thanks. Got it working!

1 Like

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