Get Carts

Current version: 8.2

Developer tasks for using service method GetCarts.

GetCarts is used to query cart data against the external commerce system. The method returns a collection of CartBase objects that only contains the summary of the main cart data. Examples include:

  • Getting the carts for a specific visitor across all visitors

  • Getting one of the carts for the current visitor in a multi-cart solution

  • Getting carts that have not been used within a period of time or abandoned

At your Visual Studio Solution setup:

  1. Reference the Sitecore.Commerce.Connect.CommerceServer and Sitecore.Commerce.dll.

  2. Pick the class in your solution where want to use this service method.

  3. Paste in the code below to use the service method.

    RequestResponse
    
    CartServiceProvider provider = new CartServiceProvider();
    // Should be set to a real user id.
    string userId = Guid.NewGuid().ToString();
    GetCartsRequest request = new GetCartsRequest("Website");
    request.Names = new List<string> { "Basket01", "Basket03" };
    request.UserIds = new List<string> { userId.ToString() };
    var result = provider.GetCarts(request);
    

Do you have some feedback for us?

If you have suggestions for improving this article,