Closed yannicsmeets closed 2 years ago
Hey @yannicsmeets, you say this is running on the demo store, do you have a fork / branch with this in place so I can run the test myself?
Ok, so I know the issue.
So basically, we calculate prices in a certain order, first of all calculating the normal price of each item (without adjustments) and then we apply any adjustments once this initial calculation is done.
It's this adjusted prices that is stored within the OrderCalculation?.SubtotalPrice.Value
property and hence why in your calculator this value is zero as this is set in cycle 2 and your code is in cycle 1. The value you have access to in your calculator which is part of that first cycle is the OrderCalculation?.SubtotalPrice.WithoutAdjustments
property which will give you the base prices without and adjustments applied.
I've made a change in the order calculation pipeline such that when we calculate the WithoutAdjustments
price (on all relevant price properties), we temporarily set the .Value
price too, even though this will shortly get overwritten by the actual calculation for that price.
This should mean that even though you are in cycle 1 of the calculation process, you can still access the .Value
property and it's value will be set to the value that is known at that time (which may later change when discounts etc are calculated) but it at least means you don't have to fully understand the calculation process to be able to access the correct price.
That update will be in 2.1.3 for which there is a beta build available on our unstable feed if you wish to test it https://nuget.outfield.digital/unstable/vendr/v3/index.json
2.1.3 has now been released with this fix in. Thanks for reporting 👍
This might be the same/similar issue as #348.
Describe the bug I added a ShippingCalculator that sets the shipping costs based on the subtotalprice of the order. When calling ShippingMethod.CalculatePrice(), the subtotalPrice is filled correctly. In the checkoutstep after selecting the shippingMethod, the calculation function is called again. This time, the subtotalPrice of the order and the orderLines are 0.
Steps To Reproduce I tested this in the demo store Steps to reproduce the behavior:
Add the following shipping calculator:
and the following in the DemoStoreComposer:
builder.Services.AddUnique<IShippingCalculator, CustomShippingCalculator>();
Expected behavior The shipping costs should remain 5. The subtotalPrice of the order and the orderLines should not be 0 in the shippingCalculator, but should be the same as the price of the item that was selected.
Screenshots The shipping method step:
After selecting a shipping method:
Additional context This is tested on the latest commit of the netcore/dev branch of the demo store.
Stack trace of when the prices are not set correctly:
Vendr version: 2.1.2 (The store uses 2.1.0, so this was updated by me)