Add products to shopping cart

The items the end customer is buying is saved into the OrderCarrier in the CurrentState.Current.ShoppingCart instance. This section describes how to add items to shopping cart. (In the Litium Accelerators, a custom buy button is implemented that utilizes the programming API presented in "How to place an order" section.)

There are two ways of adding an item to shopping cart.

  1. Using ProductBuyButton webcontrol.
  2. Writing your own buy button webcontol or link. Programmatically calling method
    CurrentState.ShoppingCart.Add(Product product, Article article, decimal quantity, string comments, Language language, bool tryAddToExistingOrderRow). Product and article parameters identify the product and the language parameter is used to the translated article name to be used as the order row description.
     

B2C accelerator "buy button" behaviour:

When the "CurrentState.Current.ShoppingCart.Add()" method is called, internals of this method will first check whether a similar item is already in the shopping cart, by examining the OrderCarrier of the shopping cart.

  • If the item is found, it will call following method with a quantity increased by 1.

CheckoutFlow.EditOrderRow(OrderCarrier orderCarrier, Guid orderRowIdToEdit, decimal quantity, string comments, decimal discountPercentage, SecurityToken token);
  • If this is a new item it construct a new ShoppingCartCarrier with the information provided and calls the method
CheckoutFlow.AddOrderRow(OrderCarrier orderCarrier, ShoppingCartCarrier shoppingCartRow, SecurityToken token)

the defualt implementation of ICheckoutFlow.AddOrderRow and ICheckoutFlow.EditOrderRow methods add the item into the order carrier. (The shopping cart does NOT automatically add or edit the order row into the Order carrier in the shopping cart, instead uses the checkout flow plugin implementation of AddOrderRow and EditOrderRow methods)

B2B Accelerator "buy button" behaviour:

In B2B accelerator the add button adds a new order row each time it is clicked into the order carrier. It is achieved by using the overload to CurrentState.Current.ShoppingCart.Add() method described above, with last parameter 'tryAddToExistingOrderRow' set to false.

 

 

 


 

 

Is this page helpful?
Thank you for your feedback!