November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
CartPrepare only needs to be run when customers already reach checkout page. It will calculate the taxes.
For normal cases like the customer adds an item to cart, you can run just CartValidate workflow
Regards,
/Q
Thank you Quan,
But specifically, in my code above -
- will "updatedCart" contain an up-to-date cart?
(it was my belief that each time I retrieve a cart from IOrderRepository it would be up-to-date... but, am I wrong? Do I actually have to run CartValidate workflow AFTER retrieving cart form IorderRepository to ensure that taxes, etc, are up-to-date?)
Hi,
You should run the workflow before saving the cart, not after loading it. <= this might not be true. The cart should be validated after loading, to make sure that any updated items or prices will be reflected. I even find it better for performance. Will blog about it soon.
In your case, if you want taxes to be included, then you should run CartPrepare. If you only want to apply promotions, then CartValidate is enough.
/Q
Thanks again,
So if I don't run cartValidate before saving, the cart will potentially save incorrect / outdated data??
In a way, yes, the cart then might contain out-of-stock items, or no longer valid discounts, etc
If I Delete a Payment and then Save the Payment, do I have to Validate & Save the cart too?
If the payment was a part of the OrderForm (it was in OrderForm.Payments) then yes, you should save the cart. Which workflow to run is a question - I don't really know - it depends a lot on your implementation - for example in some sites when you to choose to certain payments you have to pay more money. But to be safe, it would not hurt if you run the CartPrepare workflow to make sure everything is correct.
In order to understand the Cartworkflow, I highly recommend you to read the documentation thoroughly. EPi has very decent documentation for workflow activities, and once you understand what happened in each activity, you should be easily figuring out which one you need to apply for your solution.
CartValidateActivityFlow
Calculates shopping cart totals, including discounts, and validates if a product is available. This activity flow is executed every time the cart view page is loaded.
CartPrepareActivityFlow
Associates line items with shipments in the OrderForm object (allows split shipment), calculates shipment prices, tax totals, order total. Shipments require a custom shipping provider. The flow uses interfaces that your shipment and tax providers implement.
This activity flow is executed just prior to completing the order. Its calculations ensure that the cart includes all relevant discounts and ancillary costs, such as taxes and shipping charges.
CartCheckoutActivityFlow
Validates order total, process payment (again, requires custom payment provider). This flow is executed upon submission of the cart for processing.
Ref: http://world.episerver.com/documentation/developer-guides/commerce/workflows-and-activities/
Hi, I'm unsure of when CartPrepareWorkflow is needed....
I am using IOrderRepository. I get a cart, add an item to it, and accept the changes:
Will "updatedCart" contain the true updated cart? Or must I run CartPrepareWorkflow ?