The cart order provider is responsible for retrieving the cart on the Storefront. This provider is used in several places on the Storefront, including on the Cart page and during the checkout process.
Retrieves the cart for the current user.
Retrieves the cart for the current session. If a cart doesn't exist for the current session, a cart will be created and associated with the session.
void SetCartOrder(CustomerOrder customerOrder);
Associates the cart (customer order) with the current session. This method is called by the GetOrCreateCartOrder if and after a cart is created.
customerOrder - The cart to associate with the current session.
If the cart provider stores the current cart in a cache (like using the PerRequestCacheManager), this will clear the current cart from that cache.
B2B Commerce provides three standard implementations: CartOrderProviderByCustomer, CartOrderProviderByShipTo, and CartOrderProviderByUser. The CartOrderProviderByCustomer associates a cart with the user that created the cart (added products) and the Bill To customer being used at the time the cart was created. The CartOrderProviderByShipTo associates a cart with the user that created the cart and the Ship To customer being used at the time the cart was created. The CartOrderProviderByUserassociates a cart with the user that created the cart. Depending on the implementation being used, the current session could include the user who created the cart or the bill-to or ship-to customer being used when the cart was created. Usually these customers are selected immediately after logging into the Storefront.
Only one provider is used at a time. The cart order provider can be configured in the Admin Console using the Site Configurations > Providers > Cart Provider setting.
Implementations of the ICartOrderProvider must be decorated with the [DependencyName] attribute. The DependencyName attribute takes a name as an argument. The name will be used to register the implementation in the IOC container. In the Admin Console, the name will appear in the dropdown when selecting a cart provider. This is how the application will know which cart provider to use during runtime.
Associate the Cart with the Current User
Last updated: Dec 11, 2020