-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Which component is this issue related to?
Umbraco Commerce (Core)
Which Umbraco Commerce version are you using? (Please write the exact version, example: 10.1.0)
13.1.16
Bug summary
Our Commerce solution has a Shipping Calculator that inherits from Commerce's Shipping Calculator class.
Within the Shipping Calculator I fetch an Umbraco Context to fetch a value from the CMS, but this value doesn't refresh in the calculator when updated in the CMS. The Umbraco Context appears to be caching beyond when asked.
Specifics
My Shipping Calculator class uses IUmbracoContextAccessor to fetch an UmbracoContext object that I can then use to fetch a decimal figure from the CMS. This figure is the threshold at which I want shipping to be free.
If I update this value within the CMS and save & publish the content node, I want the updated value to be accessible within the Shipping Calculator, but the old value is still visible.
Interestingly, I've tried to use IUmbracoContextAccessor to fetch an Umbraco Context in the Umbraco page template that is rendered, and that Umbraco Context fetches the updated value, while the Shipping Calculator fetches the old cached value.
I am injecting the IUmbracoContextAccessor into my Shipping Calculator constructor which produces an old cached value, and I am using @Inject to inject the same interface in to my Umbraco view template, which provides my up to date value.
Is there any reason that the Shipping Calculator might consistently return a cached CMS value, while a template might return an up to date value?
Steps to reproduce
-
Create a Shipping Calculator class that inherits from ShippingCalculator, and dependency inject IUmbracoContextAccessor.
-
Within:public override Attempt TryCalculateShippingRate(ShippingMethodReadOnly shippingMethod, string optionId, Guid currencyId, Guid? countryId, Guid? regionId, TaxRate taxRate, ShippingCalculatorContext context = null)
Create a new context using TryGetUmbracoContext(out var umbracoContext)
-
Use the context to fetch a CMS value (Decimal value in an Umbraco Node).
-
Compare this value to an Umbraco Template that uses @Inject IUmbracoContextAccessor fetching the same value from the same content node.
Expected result / actual result
The values should match, but after altering the value in the CMS, the values differ. Old value in the Shipping Calculator, updated value in the template.
Dependencies
No response