Podcast
Questions and Answers
What is the primary function of services within a module in Configured Commerce?
What is the primary function of services within a module in Configured Commerce?
What does the Order property in a handler signify?
What does the Order property in a handler signify?
Which of the following is essential when adding a new handler to the chain?
Which of the following is essential when adding a new handler to the chain?
What must be overridden in a handler to implement its core functionality?
What must be overridden in a handler to implement its core functionality?
Signup and view all the answers
How can a handler chain be broken when adding a new handler?
How can a handler chain be broken when adding a new handler?
Signup and view all the answers
What should be done when overriding an existing handler in the chain?
What should be done when overriding an existing handler in the chain?
Signup and view all the answers
What is the default order number for all Configured Commerce handlers?
What is the default order number for all Configured Commerce handlers?
Signup and view all the answers
Which attribute is necessary for a handler when replacing an existing handler?
Which attribute is necessary for a handler when replacing an existing handler?
Signup and view all the answers
What does the CustomGetCartLineMapper class extend from?
What does the CustomGetCartLineMapper class extend from?
Signup and view all the answers
What is added to the Properties collection in the MapResult method?
What is added to the Properties collection in the MapResult method?
Signup and view all the answers
Which method is overridden in the CustomGetCartLineMapper class?
Which method is overridden in the CustomGetCartLineMapper class?
Signup and view all the answers
What is the purpose of the cartId variable in the custom mapper for promotions?
What is the purpose of the cartId variable in the custom mapper for promotions?
Signup and view all the answers
What does the absence of the 'orderLineId' in the response signify?
What does the absence of the 'orderLineId' in the response signify?
Signup and view all the answers
What is the default order of handlers registered in a namespace that starts with 'Insite'?
What is the default order of handlers registered in a namespace that starts with 'Insite'?
Signup and view all the answers
How can custom data be sent on a REST call's query string?
How can custom data be sent on a REST call's query string?
Signup and view all the answers
What happens when multiple handlers with the same DependencyName are registered?
What happens when multiple handlers with the same DependencyName are registered?
Signup and view all the answers
What is the purpose of the Properties dictionary in the context of REST calls?
What is the purpose of the Properties dictionary in the context of REST calls?
Signup and view all the answers
How are property values treated when they are sent with a REST call?
How are property values treated when they are sent with a REST call?
Signup and view all the answers
Which method allows for the addition of arbitrary data to the Properties collection to return from a REST call?
Which method allows for the addition of arbitrary data to the Properties collection to return from a REST call?
Signup and view all the answers
What is generally advised against when sending custom data on the query string?
What is generally advised against when sending custom data on the query string?
Signup and view all the answers
What happens to child objects when properties data is passed in the parent object?
What happens to child objects when properties data is passed in the parent object?
Signup and view all the answers
What does the 'orderLineId' property indicate when it has a null value in the promotion object?
What does the 'orderLineId' property indicate when it has a null value in the promotion object?
Signup and view all the answers
Which service is used to retrieve the cart information during the mapping process?
Which service is used to retrieve the cart information during the mapping process?
Signup and view all the answers
In the provided class, what is the purpose of the 'MapResult' method?
In the provided class, what is the purpose of the 'MapResult' method?
Signup and view all the answers
How does the implementation determine which promotion is applied to an order line?
How does the implementation determine which promotion is applied to an order line?
Signup and view all the answers
What is the role of the 'cartId' variable within the 'MapResult' method?
What is the role of the 'cartId' variable within the 'MapResult' method?
Signup and view all the answers
What method should be used to pass back complex objects in HandlerBase?
What method should be used to pass back complex objects in HandlerBase?
Signup and view all the answers
Which JavaScript function is used to deserialize complex objects on the client side?
Which JavaScript function is used to deserialize complex objects on the client side?
Signup and view all the answers
When retrieving promotions for a specific shopping cart, what API endpoint should be used?
When retrieving promotions for a specific shopping cart, what API endpoint should be used?
Signup and view all the answers
What is the first step when creating a custom mapper class from GetCartLineMapper?
What is the first step when creating a custom mapper class from GetCartLineMapper?
Signup and view all the answers
Which property of the CartLine object holds promotional information?
Which property of the CartLine object holds promotional information?
Signup and view all the answers
What action does the POST /api/v1/carts/{cartId}/promotions endpoint perform?
What action does the POST /api/v1/carts/{cartId}/promotions endpoint perform?
Signup and view all the answers
In the context of promotions, what should be reported alongside applied promotions?
In the context of promotions, what should be reported alongside applied promotions?
Signup and view all the answers
What must be done before adding additional information to the Properties collection in the custom mapper?
What must be done before adding additional information to the Properties collection in the custom mapper?
Signup and view all the answers
Study Notes
Configured Commerce Handlers
- Handlers are used for processing business logic in Configured Commerce
- They are derived from
HandlerBase
and use generics to utilize Parameter Object and Result Object pattern - Handlers are dynamically loaded using
DependencyName
attribute, which is essential for adding or replacing handlers -
Order
property determines the order of execution within the chain, lower number means higher precedence - Default order for handlers is 500
Adding Handlers to the Chain
- The base code executes first followed by subsequent handlers in the chain
- Handlers with an order less than 500 will execute before the base handlers
- Ensure unique
DependencyName
for new handlers - Reuse the
DependencyName
of the base handler to override it - Breaking the handler chain can be done by returning the result directly instead of calling
this.NextHandler.Execute()
or setting the next handler toNullHandler
Overriding Handlers
- It's recommended to add handlers to the chain unless base functionality needs modification for a given implementation
- Set the
DependencyName
attribute on the handler class to the same name as the one intended to override - If multiple handlers with the same
DependencyName
are registered, the one with the lowerDependencyOrder
will be used - Handlers within the "Insite" namespace have a default
DependencyOrder
of 999, while those outside have 500 - The
DependencyOrder
can be customized using theDependencyOrder
attribute
Passing Data to and from Handlers
- Every REST call can accept a dictionary of data in the
properties
field ofBaseModel
- Query string data is also implicitly accepted as a
properties
dictionary - To pass custom data to handlers use the
properties
dictionary within theParameterBase
derived service parameter object - Custom data can be sent using query strings but requires overrides and is not recommended for ease of upgrades
- Child objects within resulting objects usually have the
Properties
dictionary populated with data from the corresponding service result child object - To return arbitrary data from a REST call, use the
Properties.Add
method - Use
AddObjectToResultProperties
to ensure the correct serialization for complex objects - On the client, use
JSON.parse
to deserialize complex objects
Working with Promotions and Discounts: Retrieval
- The
/api/v1/carts/{cartId}/promotions
endpoint returns a collection of promotions applied to a cart -
POS /api/v1/carts/{cartId}/promotions
endpoint applies promotions to a cart -
GET /api/v1/carts/{cartId}/promotions/{promotionId}
endpoint returns a single promotion for a cart
Working with Promotions and Discounts: Custom Mappers and Line Level Data
- Create a custom mapper inheriting from
GetCartLineMapper
to retrieve promotions applied to a given line item - Override the
MapResult
method and call the base method first - Access the
PromotionResult
andPromotion
properties from theGetCartLineResult
object - Add needed information to the
Properties
collection of theGetCartLineModel
object
Working with Promotions and Discounts: Custom Mappers and Order Level vs. Line Level Data
- Create a custom mapper inheriting from
GetPromotionMapper
to retrieve promotions applied to a specific order - Override the
MapResult
method and call the base method first - Access the
cartid
from the incoming request - Use the
cartid
to access the current cart using theCartService
- Iterate through
CartLineResults
to find matching promotions based onPromotionId
- Add
orderLineId
to theProperties
collection of thePromotionModel
if promotion applies to cart line level - The
orderLineId
property in the promotion response indicates if the promotion applies to order or order line level - If the property is null - the promotion applies at the order level
- If the property contains
orderLineId
- the promotion applies at the order line level - The
/api/v1/carts/current
endpoint returns both order and order line level data - The
orderLineId
property in the response helps distinguish between order and order line level promotions
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers the basic concepts of Configured Commerce Handlers used for processing business logic. It discusses how handlers are derived from HandlerBase
, their execution order, and how to manage dependencies. Additionally, it includes information on adding and overriding handlers in the execution chain.