Try our conversational search powered by Generative AI!

Activities Code sample question

Vote:
 

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.

#84844
Apr 08, 2014 11:21
Vote:
 

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

#84908
Edited, Apr 09, 2014 8:55
Vote:
 

Thank you for the quick answer. :-)

#84910
Apr 09, 2014 10:18
Vote:
 

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

#148645
May 19, 2016 11:55
Vote:
 

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();
            }
#148646
May 19, 2016 11:57
Vote:
 

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

#148649
May 19, 2016 12:04
Vote:
 

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

#148650
May 19, 2016 12:09
Vote:
 

When you run CartValidate Workflow, it call ValidateItems activity which might delete your items (if they are out of stock, for example)

/Q

#148651
May 19, 2016 12:10
Vote:
 

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

#148652
May 19, 2016 12:16
Vote:
 

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

#148654
May 19, 2016 12:46
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.