Developer forum

Forum » Ecommerce - Standard features » RMA refund of shipping fees

RMA refund of shipping fees

Tomas Gomez
Reply

Hi,

Can the refund of an RMA include the shipping fees of the order?

For instance, a customer buy an order of 500€ with a shipping fee of 23€ (total 523€). In our solution the refund ought to be 523€, but the current refund is 500€. We didn't find any reference about how to change this configuration in the RMAs documentation (https://doc.dynamicweb.com/documentation-9/ecommerce/carts-orders/rma).

Does the RMA have any option to set the shipping fees?

Regards,
Tomas

 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Tomas

No not with the current implementation. But the actions you do on an RMA are handled by providers (ReturnMerchandiseAuthorizationReplacementOrderProvider). So below is the code from that provider, and you can change the logic of that and make your own process. But remember you have orders with maybe 2 orderlines, where only one is returned.

 

using Dynamicweb.Ecommerce.Orders;
using Dynamicweb.Ecommerce.Orders.ReturnMerchandiseAuthorization;
using Dynamicweb.Extensibility.AddIns;

namespace Dynamicweb.Ecommerce.RMAProviders.Refund
{
    [AddInName("Refund")]
    public class Refund : ReturnMerchandiseAuthorizationReplacementOrderProvider
    {
        public override Order CreateRmaOrder(ReturnMerchandiseAuthorization returnMerchandiseAuthorization)
        {
            var order = new Order();
            order.IsCart = false;
            order.Complete = true;
            order.CurrencyCode = returnMerchandiseAuthorization.OrderLines[0].OrderLine.Order.CurrencyCode;
            returnMerchandiseAuthorization.SetCustomerInfoOnOrder(order);

            foreach (ReturnMerchandiseAuthorizationOrderLine rmaOrderLine in returnMerchandiseAuthorization.OrderLines)
            {
                var unitPrice = rmaOrderLine.OrderLine.UnitPrice;
                if (unitPrice == null)
                {
                    unitPrice = rmaOrderLine.OrderLine.Price.Divide(rmaOrderLine.OrderLine.Quantity);
                }

                var orderLine = order.CreateOrderLine(rmaOrderLine.OrderLine.Product, -1, null);
                orderLine.SetUnitPrice(unitPrice, true);
            }

            order.ForcePriceRecalculation();

            return order;
        }
    }
}

Votes for this answer: 1
 
Tomas Gomez
Reply

Thanks for the code, Nicolai!

 

You must be logged in to post in the forum