Hello,
You will need to set the ProviderId explicitly. The purpose of ProviderId is to let workflows (and some other parts) know the origin of an order.
For example, when use go to checkout page, you can do this:
CartHelper.Cart.ProviderId = "FrontEnd";
CartHelper.RunWorkflow(Constants.CartValidateWorkflowName);
CartHelper.Cart.AcceptChanges();
Regards.
/Q
Hi Q,
Does this still work in the latest vrsion of Episerver 9 Commerce? I only ask as this is the line of code that is removing lineitmes from the basket.
Jon
This is a snippet of code that uses this:
if (!isEmpty) { // restore coupon code to context string couponCode = Session[Constants.LastCouponCode] as string; if (!String.IsNullOrEmpty(couponCode)) { MarketingContext.Current.AddCouponToMarketingContext(couponCode); } CartHelper.Cart.ProviderId = "FrontEnd"; CartHelper.RunWorkflow(Constants.CartValidateWorkflowName); // If cart is empty, remove it from the database - HERE IT IS NOW EMPTY isEmpty = CartHelper.IsEmpty; if (isEmpty) CartHelper.Delete(); CartHelper.Cart.AcceptChanges(); }
Hi,
The workflow architecture is substantially changed in Commerce 9, but the code should still work the same (more or less, we changed it to add new features and bug fixes). If you are using the old promotion system, it should still work.
Regards,
/Q
Hi,
Thanks for this - but it doesn't work - or what I should say is that now it is deleting our ListItems from the basket. Do you know what this workflow does to remove the listItems?
Thanks for your quick reply?
Jon
When you run CartValidate Workflow, it call ValidateItems activity which might delete your items (if they are out of stock, for example)
/Q
Do you know exactly what it validates as all the products have stock - otherwise we wouldnt be able to purchase them (on the test site).
It would be handy to know what it validates so we can ceck other possibilities? Or is there a Workflow that we can use that doesnt validate the item?
Jon
I can't know for sure, but there some possibilities which might cause for that:
- The items are not active, or not yet available, and there is no PreOrder set.
- The items are not available in the markets
- Out of stock
You should be able to download the source code for Workflow project and debug to see the reason the items are deleted. It should be the easiest way to figure out.
Regards,
/Q
I have downloaded the Commerce code samples package for both Commerce R3 and 7.5 and I have a question about the ValidateLineItemsActivities.cs in the OrderGroupActivities folder.
In the function 'PopulateVariationInfo' there is the following code:
// Set new price on line item.
lineItem.ListPrice = newListPrice.Value.Amount;
if (lineItem.Parent.Parent.ProviderId.ToLower().Equals("frontend"))
{
lineItem.PlacedPrice = newListPrice.Value.Amount;
}
I do not understand what the 'if' statement is for and where the term 'frontend' comes from.
In my code the ProviderId is always empty and therefor a changed ListPrice is not set as PlacedPrice, which is what we want.