Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
<div class="add-to-cart">
<form class="inline">
<input type="hidden" name="productId" value="@Model.Id" />
<input type="hidden" name="categoryName" value="@Model.Categories.Select(c => c.Name).Single()" />
<div class="product-quantity">
<button type="button" class="quantity-button" name="subtract" value="-">-</button>
<input type="text" class="quantity-field" readonly="readonly" name="qty" value="1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<IActionResult> AddToCart([FromBody] AddToCartModel model)
var result = await _cartService.AddToCart(currentUser.Id, model.ProductId, model.Quantity);
if (result.Success)
{
return RedirectToAction("AddToCartResult", new { productId = model.ProductId });
return RedirectToAction("AddToCartResult", new { productId = model.ProductId, categoryName = model.CategoryName });
}
else
{
Expand All @@ -57,7 +57,7 @@ public async Task<IActionResult> AddToCart([FromBody] AddToCartModel model)
}

[HttpGet("cart/add-item-result")]
public async Task<IActionResult> AddToCartResult(long productId)
public async Task<IActionResult> AddToCartResult(long productId,string categoryName)
{
var currentUser = await _workContext.GetCurrentUser();
var cart = await _cartService.GetCartDetails(currentUser.Id);
Expand All @@ -74,6 +74,7 @@ public async Task<IActionResult> AddToCartResult(long productId)
model.ProductPrice = addedProduct.ProductPrice;
model.CalculatedProductPrice = addedProduct.CalculatedProductPrice;
model.Quantity = addedProduct.Quantity;
model.CategoryName = categoryName;

return PartialView(model);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ public class AddToCartModel
{
public long ProductId { get; set; }

public string CategoryName { get; set; }

public string VariationName { get; set; }

public int Quantity { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ public AddToCartResultVm(ICurrencyService currencyService)
public string ProductPriceString => _currencyService.FormatCurrency(ProductPrice);

public string CartAmountString => _currencyService.FormatCurrency(CartAmount);


public string CategoryName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">@Localizer["Continue shopping"]</button>
<a href="/@Model.CategoryName" class="btn btn-light">
@Localizer["Continue shopping"]
</a>
<a href="~/cart" role="button" class="btn btn-light">@Localizer["View cart"]</a>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ $(function () {
var quantity,
$form = $(this).closest("form"),
productId = $(this).closest("form").find('input[name=productId]').val(),
categoryName = $(this).closest("form").find('input[name=categoryName]').val(),
$quantityInput = $form.find('.quantity-field');

quantity = $quantityInput.length === 1 ? $quantityInput.val() : 1;

$.ajax({
type: 'POST',
url: '/cart/add-item',
data: JSON.stringify({ productId: Number(productId), quantity: Number(quantity) }),
data: JSON.stringify({ productId: Number(productId), categoryName: categoryName, quantity: Number(quantity) }),
contentType: "application/json"
}).done(function (data) {
if (data.success === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/SimplCommerce.WebHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"DefaultConnection": "Server=.;Database=SimplCommerce;Trusted_Connection=True;TrustServerCertificate=true;MultipleActiveResultSets=true"
"DefaultConnection": "Server=SWD-HUMAYOUN-L\\SQLEXPRESS;Database=SimplCommerce;Trusted_Connection=True;TrustServerCertificate=true;MultipleActiveResultSets=true"
},
"Authentication" : {
"Facebook" : {
Expand Down
1 change: 1 addition & 0 deletions src/SimplCommerce.WebHost/tempkey.jwk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"AdditionalData":{},"Alg":"RS256","Crv":null,"D":"RpRMAuZhHSx-CZAB30_Xud24sse-1-JA8706liy3ZbNa6iH8a8nJARFzWfDi6oIMrCpCjkV1cFocrOTNrEct5tgKdR3hC-xYnjgUu5uQi1G02LA-7AAt8zu8KJ4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-XgpnxDHReHLZFEW3vfgHdbx1N_DmbuiI62Uh91NqXmqeT-7-pP5KQTPUKSYm17vYMnbha7ghgw9-8t63c5YwDvgxKyP_jlIhL8TMSWyEmIRLM","Q":"zuQ5U1c_X0rHQBx6q5WA9qOOqsmPjGyt2GBgrIH1Z2idRcej3tYSBLO8qVlZ3ZALiPYsZvpmkMTc122JNGSrPVojc6BFBuceKrbNcb4bAb9CMQwM1KfkAoEWot_ZpGQL29ytpYvNjtrKVE6BXrVRI3Unh4UOTOkISWe1ae9JY7M","QI":"ag6Ni_RT7ALf-BWUitrrquHX2jQ8D00EoWvmrUeGo9AEFuMOQVDOszfW547sFB1eqNSrshoTem5zpnHmnz60Ibms200mR5nH71xEE4V6t9ovUDO90twAEGi2otGi36hY58fJgVT2cxPGZxJ7rS00_maMQrwBhw-PvotGh5opvfQ","Use":null,"X":null,"X5t":null,"X5tS256":null,"X5u":null,"Y":null,"KeySize":2048,"HasPrivateKey":true,"CryptoProviderFactory":{"CryptoProviderCache":{},"CustomCryptoProvider":null,"CacheSignatureProviders":true,"SignatureProviderObjectPoolCacheSize":32}}
Loading