November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
Can you post your code here (from adding the line item to running the workflow)?
/Q
Looks like I found the problem.
We have a special price calculation that doesn't always pick the lowest price, there for I have built my own workflows but it is only the ValidateLineItemsActivity that I have changed.
My workflow looks like this:
[ActivityFlowConfiguration(Name = "DrCartValidate")] public class DrCartValidateWorkflow : ActivityFlow { public override ActivityFlowRunner Configure(ActivityFlowRunner activityFlow) { return activityFlow.Do<DrValidateLineItemsActivity>() .Do<GetFulfillmentWarehouseActivity>() .If((Func<bool>)(() => this.ShouldCheckInstoreInventory())) .Do<CheckInstoreInventoryActivity>() .Else() .Do<CheckInventoryActivity>() .EndIf() .Do<ProcessShipmentsActivity>() .Do<CalculateTotalsActivity>() .Do<RemoveDiscountsActivity>() .Do<CalculateTotalsActivity>() .Do<CalculateDiscountsActivity>() .Do<CalculateTotalsActivity>() .Do<CalculateTaxActivity>() .Do<CalculateTotalsActivity>(); } }
After upgrade I thought I had to change to this to get the VNext to work:
[ActivityFlowConfiguration(Name = "DrCartValidate")] public class DrCartValidateWorkflow : ActivityFlow { public override ActivityFlowRunner Configure(ActivityFlowRunner activityFlow) { return activityFlow.Do<DrValidateLineItemsActivity>() .Do<GetFulfillmentWarehouseActivity>() .If((Func<bool>)(this.ShouldCheckInstoreInventory)) .Do<CheckInstoreInventoryActivity>() .Else() .Do<CheckInventoryActivity>().EndIf() .Do<RemoveDiscountsVNextActivity>() .Do<CalculateDiscountsVNextActivity>() .Do<UpdateTotalsVNextActivity>(); } }
var cart = (ICart) CartHelper.Cart; cart.ApplyDiscounts(_promotionEngine, new PromotionEngineSettings());
I tried to add this to my version 1 workflow:
.Do<RemoveDiscountsVNextActivity>() .Do<CalculateDiscountsVNextActivity>()
Then the discount calculation was made when I entered the checkout but not when adding item to the cart.
/Kristoffer
Hi Quan!
Happy New Year!
Any suggestions hos to get this to work properly?
Thanks!
/Kristoffer
In the ShoppingCart page I do this:
But still the totals are not updated:
[HttpGet] public ActionResult Index(ShoppingCartPage currentPage) { this._cartHelper(Cart.DefaultName); _cartService.RunWorkflow(Constants.CartValidateWorkflow); _cartService.SaveCart(); var cartItems = _cartService.GetCartItems(); ShoppingCartViewModel viewModel = new ShoppingCartViewModel(currentPage, cartItems) { SubTotal = _cartService.GetSubTotal(), Total = _cartService.GetTotal() - _cartService.GetShippingTotal(), ShowVat = _currencyService.GetCurrentCurrency().CurrencyCode != Constants.CurrencyWithOutWat, DiscountTotal = _cartService.GetOrderDiscountTotal() * -1 }; return this.View(viewModel); }
Hi!
So it seems to be problems with my code for adding an entry. If i use:
LineItem lineItem = CartHelper.AddEntry(entry);
The cart is updated fine. But, since I want to be able to add the same entry twice without having the quantity to be updated on the existing item I have to add the line item by myself using this:
lineItem = CreateLineItem(entry, code, productCode, quantity); lineItem["Configuration"] = configuration; CartHelper.OrderForm.LineItems.Add(lineItem);
Doing this the item was not added to any shipment and there for it is excluded in the total calculation.
Adding this fixed my problem:
var item = CartHelper.OrderForm.LineItems[CartHelper.OrderForm.LineItems.Count - 1]; shipment.AddLineItemIndex(CartHelper.OrderForm.LineItems.Count - 1, item.Quantity); shipment.AcceptChanges();
The absoluty best thing would be to add an option in the CartHelper where you can add an item with the same code as a new row instead of always updating the quantity.
Anything that might be done in the future?
/Kristoffer
Hi,
CartHelper is in Mediachase.Commerce.Website, which is open source by Episerver. You are free to modify it as you like :)
This is one of the reasons we recommend to move to the new abstraction APIs instead because it makes it much easier to work with such issues.
I definitly would like to rebuild all with the new api, so much better! I just have to convince my customer about the upside. Is the plan to remove the workflows completly or will they remain?
So, the basic is that the item needs to be placed in a shipement do be included in the cart calculations?
Thans Quan!
Hi,
Yes. On the "old" APIs - which you are using - the lineitems belong to the OrderForm, you will have to modify the LineItemIndex to "add" it to the Shipment (shipment.AddLineItemIndex in your code). The calculations, however, will calculate on Shipments. So if you have "orphan" lineitems which were not added to any Shipments, they will be left behind.
The concept of new APIs is shipment "owns" the lineitems. You always add lineitem to shipment, explicitly, so this kind of issue is now non-problem.
Any plans to provide the source code for the new order processing classes, such as DefaultLineItemValidator and DefaultInventoryProcessor, for extension purposes?
We used to have the code for the workflows which enabled us to add our own business logic on the top of it. Hopefully we can get the same for the new one.
Thanks!
Hi!
After upgrading to Commerce 10 the ValidateCart workflow has a strange behavior. It doesn't always update the cart totals.
When I add an item to the cart I run the ValidateCart workflow and before Commerce upgrade the cart totals got updated.
After upgrading it doesn't upgrade the cart totals. But when I enter the checkout page where I also run ValidateCart the cart totals gets updated, also when I remove an item from the cart and run ValidateCart it works fine so I guess I'm missing something.
So the question is, do you have to do something special to get the ValidateCart to run properly? Something like, make sure to AcceptChanges() or make sure cart in i a specific state before running ValidateCart?
As I said, it worked just fine before upgrading. Has something changed?
Thanks!
/Kristoffer