It sounds like your shipment has the wrong shipping gateway/plugin attached. It should have been a class that implements IShippingPlugin, but it only implements IShippingGateway
Hi Quan. When did this change? It seems it stopped working for us when going from 11.2.5 to 11.8.5.
I can't recall any change related to this. Which is the shipping method attached to this shipment. What does the implementation of that shipping method look like?
It is a custom gateway which implements IShippingGateway. The invalid cast occurs in GetRate() since it expects a Shipment but gets an IShipment.
I'll try to change the implementation but one thing occured to me. We rely on data from the orderform and ordergroup which we get from LineItem.Parent and LineItem.Parent.Parent. I don't see any replacement for that in IShipment. How can we resolve which OrderForm an IShipment belongs to?
<?xml version="1.0" encoding="utf-8"?>
<Application defaultApplicationName="xxxxx.CommerceAdmin">
<Roles>
<add name="AdminRole" value="Admins"/>
<add name="ManagerUserRole" value="Management Users"/>
<add name="EveryoneRole" value="Everyone"/>
<add name="RegisteredRole" value="Registered"/>
</Roles>
<Connection connectionStringName="EcfSqlConnection"/>
<Cache enabled="true" appTimeout="0:0:10"/>
<Languages>
<add key="en-us" value="English"/>
<add key="da-DK" value="Danish"/>
<add key="sv-SE" value="Svenska"/>
<add key="fi-FI" value="Suomi"/>
<add key="nl-NL" value="Netherlands"/>
<add key="nb-NO" value="Norsk"/>
<add key="fr-FR" value="French"/>
</Languages>
<Features>
<add feature="WorkflowsVNext" state="Disabled" type="Mediachase.Commerce.Core.Features.WorkflowsVNext, Mediachase.Commerce"/>
</Features>
</Application>
Please reach out for developer support service, and we can take it from there
HI Quan
Did you get to the bottom of this. We seem to ebe getting the same error when trying to do a return in commerce manager.
Regards
Sandeep
Hi all,
After upgrading from Commerce 11.2.5 to 11.8.5, which should not contain any breaking change, we get the following error in Commerce Manager when trying to create a return. Anyone seen this error? Is this an undocumented breaking change?
[InvalidCastException: Unable to cast object of type 'EPiServer.Commerce.Order.Internal.InMemoryShipment' to type 'Mediachase.Commerce.Orders.Shipment'.]
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.GetShippingRate(IShipment shipment, ShippingMethodRow row, IMarket market) +282
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.CalculateShippingCost(IShipment shipment, IMarket market, Currency currency) +575
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.GetDiscountedShippingAmount(IShipment shipment, IMarket market, Currency currency) +388
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.CalculateShippingTaxTotal(IShipment shipment, IMarket market, Currency currency, Func`3 getShippingTotalFunc, Func`3 getDiscountedPriceFunc, Boolean isReturn) +311
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.CalculateShippingTaxTotal(IShipment shipment, IMarket market, Currency currency) +259
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.GetShippingTaxTotal(IShipment shipment, IMarket market, Currency currency) +367
EPiServer.Commerce.Order.Calculator.<>c__DisplayClass7_0.<GetTotalForReturns>b__1(IShipment shipment) +157
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +233
System.Linq.Enumerable.Sum(IEnumerable`1 source) +98
EPiServer.Commerce.Order.Calculator.DefaultReturnPurchaseOrderCalculator.GetTotalForReturns(IPurchaseOrder order) +788
EPiServer.Commerce.Order.Calculator.DefaultReturnPurchaseOrderCalculator.CalculateReturnTotal(IPurchaseOrder purchaseOrder, IReturnOrderForm currentReturnForm, Boolean isCompletingReturnForm) +338
Mediachase.Commerce.Manager.Apps.Order.Modules.OrderCreateReturn.CalculateReturnTotal() +147
Mediachase.Commerce.Manager.Apps.Order.Modules.OrderCreateReturn.Page_Load(Object sender, EventArgs e) +1241
System.Web.UI.Control.OnLoad(EventArgs e) +106
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785