Umbraco.Commerce.Issues icon indicating copy to clipboard operation
Umbraco.Commerce.Issues copied to clipboard

OrderReadOnly seems to be caching data but not refreshed when a Product is added

Open robertjf opened this issue 1 year ago • 29 comments

We have noticed in testing that adding an item to an Order does not refresh the OrderReadOnly, although the Order is updated succcesfully.

For example:

                commerceApi.Uow.Execute(uow =>
                {
                    var store = CurrentPage.GetStore();
                    var order = commerceApi.GetOrCreateCurrentOrder(store.Id);

                    var writableOrder = order.AsWritable(uow);

                    // order.OrderLines.Count() == 4
                    // writableOrder.OrderLines.Count() == 5

                    writableOrder.AddProduct(postModel.ProductReference, postModel.ProductVariantReference, 1,
                                    new Dictionary<string, string>{
                                        { "imageUrl", product?.RollupImageV2?.MediaUrl() }
                                    });

                    commerceApi.SaveOrder(writableOrder);

                    uow.Complete();
                });

The only way we've gotten the true order line-item count/quantity count, is to restart the website. This is a problem in both the back-office Orders list as well as the front end.

Umbraco.Commerce version: 12.1.2

robertjf avatar Nov 01 '23 01:11 robertjf