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?
- To manage user permissions and access
- To define the order of execution for handlers
- To operate the handler factory (correct)
- To initiate the core business logic of handlers
What does the Order property in a handler signify?
What does the Order property in a handler signify?
- It determines the time taken for the handler to execute
- It sets the maximum number of handlers allowed in a chain
- It assigns a unique identifier to the handler
- It represents the execution priority of the handler in the chain (correct)
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?
- Including a DependencyName attribute that is unique (correct)
- Registering the handler as a NullHandler
- Setting the handler's Order property to 100
- Defining multiple Execute methods within the handler
What must be overridden in a handler to implement its core functionality?
What must be overridden in a handler to implement its core functionality?
How can a handler chain be broken when adding a new handler?
How can a handler chain be broken when adding a new handler?
What should be done when overriding an existing handler in the chain?
What should be done when overriding an existing handler in the chain?
What is the default order number for all Configured Commerce handlers?
What is the default order number for all Configured Commerce handlers?
Which attribute is necessary for a handler when replacing an existing handler?
Which attribute is necessary for a handler when replacing an existing handler?
What does the CustomGetCartLineMapper class extend from?
What does the CustomGetCartLineMapper class extend from?
What is added to the Properties collection in the MapResult method?
What is added to the Properties collection in the MapResult method?
Which method is overridden in the CustomGetCartLineMapper class?
Which method is overridden in the CustomGetCartLineMapper class?
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?
What does the absence of the 'orderLineId' in the response signify?
What does the absence of the 'orderLineId' in the response signify?
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'?
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?
What happens when multiple handlers with the same DependencyName are registered?
What happens when multiple handlers with the same DependencyName are registered?
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?
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?
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?
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?
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?
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?
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?
In the provided class, what is the purpose of the 'MapResult' method?
In the provided class, what is the purpose of the 'MapResult' method?
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?
What is the role of the 'cartId' variable within the 'MapResult' method?
What is the role of the 'cartId' variable within the 'MapResult' method?
What method should be used to pass back complex objects in HandlerBase?
What method should be used to pass back complex objects in HandlerBase?
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?
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?
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?
Which property of the CartLine object holds promotional information?
Which property of the CartLine object holds promotional information?
What action does the POST /api/v1/carts/{cartId}/promotions endpoint perform?
What action does the POST /api/v1/carts/{cartId}/promotions endpoint perform?
In the context of promotions, what should be reported alongside applied promotions?
In the context of promotions, what should be reported alongside applied promotions?
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?
Flashcards
Configured Commerce Handlers
Configured Commerce Handlers
Components for processing business logic in Configured Commerce, derived from HandlerBase. Loaded dynamically, ordered by DependencyName, and executed sequentially.
Handler Order
Handler Order
The execution sequence of handlers, determined by the 'Order' property. Lower numbers have higher precedence.
DependencyName
DependencyName
Unique identifier for a handler, used for dynamic loading and overriding. Crucial for adding or replacing handlers.
Handler Chain Breaking
Handler Chain Breaking
Signup and view all the flashcards
Overriding Handlers
Overriding Handlers
Signup and view all the flashcards
ParameterBase
ParameterBase
Signup and view all the flashcards
Result Object
Result Object
Signup and view all the flashcards
properties field
properties field
Signup and view all the flashcards
AddObjectToResultProperties
AddObjectToResultProperties
Signup and view all the flashcards
/api/v1/carts/{cartId}/promotions
/api/v1/carts/{cartId}/promotions
Signup and view all the flashcards
GetCartLineMapper
GetCartLineMapper
Signup and view all the flashcards
GetPromotionMapper
GetPromotionMapper
Signup and view all the flashcards
PromotionModel
PromotionModel
Signup and view all the flashcards
orderLineId
orderLineId
Signup and view all the flashcards
Default DependencyOrder
Default DependencyOrder
Signup and view all the flashcards
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 cartGET /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.