Overview
VirtoCommerce.Cart module represents shopping cart management system. This module doesn't have any UI in VC Manager.
VirtoCommerce.Cart module manages customers accumulated list of items, calculates a total for the order, including shipping and handling (i.e., postage and packing) charges and the associated taxes.
Features
-
Supports multiple carts - if the user is using more than one cart at the same time, all of the carts will be supported by VirtoCommerce.Cart module.
-
Named lists - the user can add the desired products to the wishlist , which will be saved in the cart. The user can later use the products added to the wishlist to make an order. The wishlist details will be saved by the VirtoCommerce.Cart module.
- Grouping multiple carts to one order - if the user is using more than one cart, the final order will be created by grouping the details from all the carts filled out by user.
- Anonymous carts - the user can put products to cart and submit order anonymously, without creating an account.
- Stock reservation - the selected products will be reserved in stock after adding them to the cart.
- Multiple payments methods - the user can choose the payment methods he wants before checkout.
- Create new cart from orders history - the user can add products to a new cart using the previously completed orders (orders history).
The main purpose of the VirtoCommerce.Cart module is to implement customer shopping cart management in VC eCommerce solution. It encapsulates data persistence, management services and exposes REST API endpoints.
The VirtoCommerce.Cart module is connected with the shopping cart API requests:
- General API request that allows saving the entire shopping cart information on the database;
- Specific API requests that allow call specific operations, for example delete, edit, choose payment method, choose delivery type, etc.
For more details about the available cart module API, please refer to our demo.
The VirtoCommerce.Cart module functionality can be extended and customized based on the specific business needs. In order to extend the cart module functionality, use "Virto Commerce 2.x Cart and Order Module extension" template that can be accessed by following the link below:
https://marketplace.visualstudio.com/items?itemName=Virto-Commerce.VirtoCommerceModuleTemplates
Concurrency handling
To add the possibility of handling concurrency conflict CartEntity
contains the concurrency token column named RowVersion
. If the same data gets modified at the same time EF Core's SaveChanges()
throws a DbUpdateConcurrencyException
. In cases when you need to handle such situations you can overrdie the CommitAsync
method and handle DbUpdateConcurrencyException
. There's an example of client-wins
scenario:
protected async override Task CommitAsync(IRepository repository)
{
bool saveFailed;
var retry = 0;
do
{
saveFailed = false;
try
{
await repository.UnitOfWork.CommitAsync();
}
catch (DbUpdateConcurrencyException ex)
{
saveFailed = true;
retry++;
if (retry == _commitRetriesCount)
{
throw;
}
foreach (var entry in ex.Entries)
{
entry.OriginalValues.SetValues(entry.GetDatabaseValues());
}
}
} while (saveFailed);
}
Installation
Installing the module: * Automatically: in VC Manager go to More -> Modules -> Shopping cart module -> Install * Manually: download module zip package from https://github.com/VirtoCommerce/vc-module-cart/releases. In VC Manager go to More -> Modules -> Advanced -> upload module package -> Install.
Available resources
- Module related service implementations as a NuGet package