Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
@using Grand.Domain.Orders
@model CustomerModel
@inject AdminAreaSettings adminAreaSettings
@{
var area = ViewContext.RouteData.Values["area"]?.ToString();
}
<div class="grand-card">
<div class="grand-card__header">
<h2 class="grand-card__title">@Loc["Admin.Customers.Customers.CurrentShoppingCart"]</h2>
</div>
<partial name="Partials/WidgetZone.ShoppingCartTop" model="Model"/>
<div class="grand-card__body grand-card__body--flush">
@*unit prices are edited in the cells and sent with Save changes, one request per changed item*@
<admin-grid id="currentshoppingcart-grid"
confirm-destroy="true"
read-url="@Url.Action("GetCartList", "Customer", new { customerId = Model.Id, cartTypeId = (int)ShoppingCartType.ShoppingCart, area = area })"
update-url="@Url.Action("UpdateCart", "Customer", new { customerId = Model.Id, area = area })"
destroy-url="@Url.Action("DeleteCart", "Customer", new { customerId = Model.Id, area = area })"
pager="Compact"
auto-bind="false"
edit-mode="Batch">
<grid-toolbar-save/>
<grid-column field="ProductName" title="@Loc["Admin.CurrentCarts.Product"]" width="500">
<cell-template>
<a class="text-decoration-none" href="@Url.Action("Edit", "Product", new { area = area })/{{ ProductId }}">{{ ProductName }}</a>
@*AttributeInfo is markup built by the product attribute formatter*@
<span data-if="AttributeInfo && AttributeInfo.length > 0"><br />{{{ AttributeInfo }}}</span>
</cell-template>
</grid-column>
<grid-column field="Quantity" title="@Loc["Admin.CurrentCarts.Quantity"]" width="200"/>
<grid-column field="UnitPriceValue" title="@Loc["Admin.CurrentCarts.UnitPrice"]" width="200" format="{0:n2}" editor="Numeric" decimals="2"/>
<grid-column field="Total" title="@Loc["Admin.CurrentCarts.Total"]" width="200"/>
@if (area == "Admin" && !adminAreaSettings.HideStoreColumn)
{
<grid-column field="Store" title="@Loc["Admin.CurrentCarts.Store"]" width="200"/>
}
<grid-column field="UpdatedOn" title="@Loc["Admin.CurrentCarts.UpdatedOn"]" width="200" format="{0:G}"/>
<grid-column title="@Loc["Admin.Common.Delete"]" width="200">
<cell-template>
<button type="button" class="btn btn-outline-danger btn-sm k-grid-delete" data-grid-click="deleteCartItem">Delete</button>
</cell-template>
</grid-column>
</admin-grid>
</div>
<partial name="Partials/WidgetZone.ShoppingCartBottom" model="Model"/>
</div>
<script>
function deleteCartItem(dataItem) {
deleteRow(dataItem.Id);
}
function deleteRow(id) {
var grid = GrandAdmin.grids.get("#currentshoppingcart-grid");
var dataItem = grid.dataSource.get(id);
var tokenInput = $('input[name=__RequestVerificationToken]');
$.ajax({
url: "@Html.Raw(Url.Action("DeleteCart", "Customer", new { customerId = Model.Id, area = area }))",
type: "POST",
data: {
id: dataItem.Id,
customerId: "@Model.Id",
__RequestVerificationToken: tokenInput.val(),
},
success: function () {
grid.dataSource.remove(dataItem);
//the Kendo data source reloaded after destroy (requestEnd)
grid.dataSource.sync().then(function () {
grid.dataSource.read();
});
},
error: function (e) {
display_kendoui_grid_error(e);
}
});
}
</script>