The default shopping cart calculation in Kentico uses a composite implementation of the IShoppingCartCalculator interface – the ShoppingCartCalculatorCollection class. The default implementation prepares the calculation data using IShoppingCartAdapterService, runs the calculation using IShoppingCartCalculationFactory, and ensures automatic adding of free products to shopping carts for Buy X Get Y discounts. IShoppingCartEvaluator – contains an Evaluate method that encapsulates the entire shopping cart evaluation and calculation logic.If you need to use custom result properties to apply values to the shopping cart, convert the CalculationResult parameter to your derived type within the Appl圜alculationResult method.Define the GetCalculationRequest and GetCalculationResult methods within your IShoppingCartAdapterService implementation and return instances of your derived request or result classes.Add properties to the classes according to your requirements.Create custom classes that inherit from CalculationRequest or CalculationResult.You can create and register your own IShoppingCartAdapterService implementation if you need to add custom properties into the calculation data for use within IShoppingCartCalculator classes: GetCalculationRequest, GetCalculationResult – methods that initialize the CalculationRequest and CalculationResult objects for the calculation using the data of a specified shopping cart ( ShoppingCartInfo).Īppl圜alculationResult – applies the results ( CalculationResult) to the specified shopping cart ( ShoppingCartInfo) after the calculation.Implementations must contain the following methods: IShoppingCartAdapterService – prepares the data for the IShoppingCartCalculator calculations and applies the results to the shopping cart.The E-commerce API uses the following interfaces to connect the main calculation logic to shopping cart objects: See the Default calculation pipeline section for details. The default shopping cart calculation in Kentico uses a composite IShoppingCartCalculator step, consisting of multiple other IShoppingCartCalculator implementations that are executed in a specific order. To fully replace the shopping cart calculation logic, the Calculate method of your IShoppingCartCalculator implementation needs to process the data provided in CalculatorData.Request and set all available properties of CalculatorData.Result. For example, the CalculationRequest.PaymentOption property has a null value when calculating shopping carts where the customer has not selected a payment option yet. The system runs the calculation process during early stages of the shopping cart life cycle where many properties are not set yet. Note: To ensure that your custom calculator implementations work without errors, you need to perform null checks before accessing CalculationRequest properties.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |