Cart service provider
Service providers are wrapper objects designed to make it easier to interact with Connect pipelines. The providers implement no logic other than calling Connect pipelines. All of the business logic is implemented in the pipeline processors.
For each method in the provider, there is a corresponding Request and Result object used, for example, GetCarts takes a GetCartsRequest object and returns a GetCartsResult object. In some cases, the response objects are re-used when returning the same data.
Customized versions of the default request and result arguments can be used by calling the overloaded generics based versions of the methods.
The Cart service provider contains the following methods for interacting with cart data.
GetCarts method
GetCarts method
TheGetCarts method is used to query cart data against the external commerce system and does not return a collection of Carts, but a collection of CartBase objects that only contains the summary of the main cart data.
|
Name: |
GetCarts |
|
Description: |
Gets the carts that match the specified criteria. Calls the |
|
Usage: |
Called when a list of carts is needed. Examples include:
|
|
Signature: |
GetCartsResult GetCarts(GetCartsRequest request) |
|
Input: | |
|
UserId – Optional - The ids of the users whose carts should be retrieved. If no value is specified, the user IDs are not considered when retrieving carts. | |
|
CustomerId – Optional – The ids of the customers whose carts should be retrieved. If no value is specified the customer IDs are not considered when retrieving carts. | |
|
CartName – Optional - The names of the carts that should be retrieved. If no value is specified, the cart names are not considered when retrieving carts. | |
|
CartStatus – Optional – The status of carts that should be retrieved. Examples include Active and Abandoned. If no value is specified, the cart statuses are not considered when retrieving carts. This could be used in a B2B scenario when you want to display a list of available carts to a user but only carts that are not locked. | |
|
IsLocked – Optional – If provided it means the search also filters on whether the cart is locked or not. | |
|
ShopName – Optional. Name of shop to search for carts in. | |
|
Output: | |
|
IEnumerable<CartBase> – A collection of CartBase objects. The lists represent the carts that match the criteria specified in the request. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
CreateOrResumeCart method
CreateOrResumeCart method
|
Name: |
CreateOrResumeCart |
|
Description: |
Initiate the creation of a shopping cart and in the process:
|
|
Usage: |
Called when a shopping cart is needed upon visitor arrival to shop. |
|
Signature: |
|
|
Input: |
All four input parameters are used to search and match against existing carts for the current visitor, but only two of them are mandatory. |
|
UserId – Mandatory | |
|
CustomerId – Optional | |
|
CartId or CartName – Mandatory to load or resume cart. Optional when creating cart. | |
|
ShopName – Mandatory | |
|
Output: | |
|
Cart – A Cart object instance which represents the shopping cart. In case multiple carts already exist for the current visitor and it is undecided which one to return, then no cart is returned. | |
|
IEnumerable<CartBase> - In case multiple carts already exist for the current visitor and it is undecided which one to return, then a list of CartBase objects are returned. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
LoadCart method
LoadCart method
|
Name: |
LoadCart |
|
Description: |
Gets the cart with given Cart ID on the specified shop. Calls the |
|
Usage: |
Called when a specific cart is needed |
|
Signature: |
Note The |
|
Input: | |
|
CartId – Mandatory | |
|
ShopName - Mandatory | |
|
Output: | |
|
Cart – A cart object instance which represents the shopping cart that matches the criteria specified in the request. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
SaveCart method
SaveCart method
|
Name: |
SaveCart |
|
Description: |
Saves the specified cart in the external system if supported as well as in Sitecore EA state. Calls the Called from other service layer methods implicitly, but not called explicitly |
|
Usage: |
Called when a specific cart needs to be persisted. The method should be executed after any operation that modified the cart resulting in a change of cart. It is executed implicitly when updating the cart, adding, deleting or updating cart lines, as well as locking and un-locking the cart. |
|
Signature: |
|
|
Input: | |
|
Cart – Mandatory | |
|
Output: | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
AddCartLines method
AddCartLines method
|
Name: |
AddCartLines |
|
Description: |
Responsibility is to add lines to cart. |
|
Usage: |
Called when a list of cart lines is about to be added to the shopping cart, when the user clicks Add To Cart. |
|
Signature: |
|
|
Input: | |
|
Cart – Required - The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart. | |
|
IEnumerable<CartLine> CartLines – Mandatory- A collection of cart lines to add. | |
|
ForceNewLines – Optional – If true, the cart lines items will be added as new cart lines in the customer cart. Otherwise, the lines will be merged into existing cart lines if possible. Note This parameter is only supported if the external commerce system supports this functionality. | |
|
Output: | |
|
Cart - Cart object that represent the updated cart in the external system. | |
|
AddedCartLineExternalIds – A list of the External IDs of the lines that were added to the cart. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
RemoveCartLines method
RemoveCartLines method
|
Name: |
RemoveCartLines |
|
Description: |
Responsibility is to remove lines from cart. |
|
Usage: |
Called when one or more cart lines are about to be removed from the shopping cart, when the user updates the cart by removing one or more lines. |
|
Signature: |
|
|
Input: | |
|
Cart - Mandatory. The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart. | |
|
IEnumerable<CartLine> CartLines – Mandatory - A collection of cart linesto remove. ExternalCartLineId, LineNumber or the object reference can be used to identify the line(s) to be removed. The default Connect based implementation removes lines by object reference. | |
|
Output: | |
|
Cart - Cart object that represents the updated cart in the external system. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
UpdateCartLines method
UpdateCartLines method
|
Name: |
UpdateCartLines |
|
Description: |
Responsibility is to update lines on cart. |
|
Usage: |
Occurs when a shopping cart is about to be updated referring to lines already in the cart. In terms of UI, it is when the user updates the cart regarding a specific product. Most typically it is when:
|
|
Signature: |
|
|
Input: | |
|
Cart - Mandatory - The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart. | |
|
IEnumerable<CartLine> CartLines – Mandatory- A collection of cart linesto update on cart. | |
|
Output: | |
|
Cart – Cart object that represents the updated cart in the external system. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
DeleteCart method
DeleteCart method
|
Name: |
DeleteCart |
|
Description: |
Responsibility is to delete a cart permanently:
|
|
Usage: |
Must be called when a cart needs to be deleted. In terms of the UI, this could be:
|
|
Signature: |
|
|
Input: | |
|
Cart - Mandatory. The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart. | |
|
Output: | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
UpdateCart method
UpdateCart method
|
Name: |
UpdateCart |
|
Description: |
Responsibility is to pass an updated cart to the external commerce system. Triggers an event in DMS telling that the cart is being updated. |
|
Usage: |
The method should be executed after any operation that modifies the cart, typically when Adjustments have been added, removed or modified. |
|
Signature: |
|
|
Input: | |
|
Cart - Mandatory - The cart to be updated. The cart must be unmodified. Any changes made to the cart instance will be disregarded. Only the cart Id and ShopName are considered for retrieving and modifying the cart. | |
|
Cart Base – An instance of the Cart Base containing the changes to be made to the cart Typically the only properties allowed to be modified are: UserId, CustomerId, CartName and, potentially, ShopName. Whether the IsLocked and CartStatus values are considered, depends on business logic in the external commerce system. Null values will not be considered, but blank values will be. | |
|
Output: | |
|
Cart – Cart object that represents the updated cart in the external system. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
LockCart method
LockCart method
|
Name: |
LockCart |
|
Description: |
Responsibility is to set the cart in a locked state where it is ready to be committed to an order but before any optional payment transaction is performed:
When the cart is in a locked state, it indicates two things:
There is a corresponding |
|
Usage: |
Typically executed during the checkout process, just before any payment transaction is about to be executed and before turning the cart into an order. In terms of UI, it is triggered when a user in the checkout flow has clicked Confirm and in a B2C scenario is going to pay and the order is created. |
|
Signature: |
|
|
Input: | |
|
Cart - Mandatory | |
|
Output: | |
|
Cart – Cart object that represent the updated cart in the external system. | |
|
SystemMessages - Collection of messages from the external system. |
Usage example:
UnlockCart method
UnlockCart method
|
Name: |
UpdateCartLines |
|
Description: |
Responsibility is to set the cart in an unlocked state:
By default a cart is in an unlocked state and can be edited. There is a corresponding |
|
Usage: |
Typically called if a user returns to a cart and decides to modify the content after starting the checkout process and payment transaction, but its implementation specifies how it should be handled. |
|
Signature: |
|
|
Input: | |
|
Cart – Mandatory | |
|
Output: | |
|
Cart – Cart object that represents the updated cart in the external system. | |
|
SystemMessages - Collection of messages from the external system. This is how error conditions can be reported. |
Usage example:
MergeCart method
MergeCart method
|
Name: |
MergeCart |
|
Description: |
Responsibility is to merge two specified carts:
|
|
Usage: |
Typically called when a user logs in and the system notices an anonymous cart exists. |
|
Signature: |
|
|
Input: | |
|
UserCart – Mandatory AnonymousCart - Mandatory | |
|
Output: | |
|
Cart – Cart object representing the merged user cart. | |
Usage example:
AddParties method
AddParties method
|
Name: |
AddParties |
|
Description: |
Responsibility is to add parties to a cart. |
|
Usage: |
Typically called when adding party information to a cart. |
|
Signature: |
|
|
Input: | |
|
Cart – Mandatory Parties - Mandatory | |
|
Output: | |
|
Parties – The read-only list of all parties associated with this cart after the add. | |
Usage example:
RemoveParties method
RemoveParties method
|
Name: |
RemoveParties |
|
Description: |
Responsibility is to remove parties from a cart. |
|
Usage: |
Typically called when removing party information. |
|
Signature: |
|
|
Input: | |
|
Cart – Mandatory Parties – Mandatory – The list of parties to remove from the cart. | |
|
Output: | |
|
Parties – The read-only list of all parties associated with this cart after the remove. | |
Usage example:
UpdateParties method
UpdateParties method
|
Name: |
UpdateParties |
|
Description: |
Responsibility is to update a list of parties within a cart. |
|
Usage: |
Typically called when parties need to be updated. |
|
Signature: |
|
|
Input: | |
|
Cart – Required Parties – Required – The list of parties to update in the cart. | |
|
Output: | |
|
Parties – The read-only list of all parties associated with this cart after the update. | |
Usage example:
AddPaymentInfo method
AddPaymentInfo method
|
Name: |
AddPaymentInfo |
|
Description: |
Responsibility is to add payment information to a cart. |
|
Usage: |
Typically called during a checkout flow to add the payment info for processing of an order. |
|
Signature: |
|
|
Input: | |
|
Cart – Mandatory Payments – Mandatory – a list of payment info to be added to the cart. | |
|
Output: | |
|
Payments – The read-only list of payments associated with the cart after the add. | |
Usage example:
RemovePaymentInfo method
RemovePaymentInfo method
|
Name: |
RemovePaymentInfo |
|
Description: |
Responsibility is to remove payment information from a cart. |
|
Usage: |
Typically called when a user wants to change their payment information. |
|
Signature: |
|
|
Input: |
Cart – Mandatory Payments – Mandatory– A list of payment info to be removed from the cart. |
|
Output: |
Payments – The read-only list of payments associated with the cart after the remove. |
Usage example:
AddShippingInfo method
AddShippingInfo method
|
Name: |
AddShippingInfo |
|
Description: |
Responsibility is to add shipping information to a cart. |
|
Usage: |
Typically called during a checkout flow to add the shipping info for processing of an order. |
|
Signature: |
|
|
Input: | |
|
Cart – Mandatory ShippingInfo – Mandatory – A list of shipping info to add to the cart. | |
|
Output: | |
|
ShippingInfo – A read-only list of shipping info associated with the cart after the add. | |
Usage example:
RemoveShippingInfo method
RemoveShippingInfo method
|
Name: |
RemoveShippingInfo |
|
Description: |
Responsibility is to remove shipping information from a cart |
|
Usage: |
Typically called during a checkout flow to remove the shipping info for processing of an order. |
|
Signature: |
|
|
Input: | |
|
Cart – Mandatory ShippingInfo – Mandatory – A list of shipping info to remove from the cart. | |
|
Output: | |
|
ShippingInfo – A read-only list of shipping info associated with the cart after the remove. | |
Usage example: