Skip to content

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.

ActionCart/Product/ShoppingCart/OutOfSubscription - remove IFormCollection

supportf9c9885bf65b
diff --git a/src/Web/Grand.Web/Controllers/ActionCartController.cs b/src/Web/Grand.Web/Controllers/ActionCartController.cs
index b8bcd89b8..9cb1fd409 100644
--- a/src/Web/Grand.Web/Controllers/ActionCartController.cs
+++ b/src/Web/Grand.Web/Controllers/ActionCartController.cs
@@ -13,9 +13,9 @@ using Grand.Web.Common.Filters;
using Grand.Web.Extensions;
using Grand.Web.Features.Models.Products;
using Grand.Web.Features.Models.ShoppingCart;
+using Grand.Web.Models.Catalog;
using Grand.Web.Models.ShoppingCart;
using MediatR;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System.Globalization;
@@ -337,36 +337,17 @@ namespace Grand.Web.Controllers
return null;
}
- private async Task<double?> GetCustomerEnteredPrice(IFormCollection form, string productId)
+ private async Task<double?> GetCustomerEnteredPrice(ProductModel model)
{
double? customerEnteredPriceConverted = null;
- foreach (string formKey in form.Keys)
- {
- if (formKey.Equals(string.Format("addtocart_{0}.CustomerEnteredPrice", productId), StringComparison.OrdinalIgnoreCase))
- {
- if (double.TryParse(form[formKey], out double customerEnteredPrice))
- customerEnteredPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(customerEnteredPrice, _workContext.WorkingCurrency);
- break;
- }
- }
- return customerEnteredPriceConverted;
- }
-
- private int GetQuantity(IFormCollection form, string productId)
- {
- int quantity = 1;
- foreach (string formKey in form.Keys)
- if (formKey.Equals(string.Format("addtocart_{0}.EnteredQuantity", productId), StringComparison.OrdinalIgnoreCase))
- {
- int.TryParse(form[formKey], out quantity);
- break;
- }
+ if (double.TryParse(model.CustomerEnteredPrice, out var customerEnteredPrice))
+ customerEnteredPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(customerEnteredPrice, _workContext.WorkingCurrency);
- return quantity;
+ return customerEnteredPriceConverted;
}
-
[HttpPost]
- public virtual async Task<IActionResult> AddProductDetails(string productId, int shoppingCartTypeId, IFormCollection form)
+ public virtual async Task<IActionResult> AddProductDetails(string productId, int shoppingCartTypeId,
+ ProductModel model)
{
var product = await _productService.GetProductById(productId);
if (product == null)
@@ -384,87 +365,63 @@ namespace Grand.Web.Controllers
double? customerEnteredPriceConverted = null;
if (product.EnteredPrice)
{
- customerEnteredPriceConverted = await GetCustomerEnteredPrice(form, productId);
+ customerEnteredPriceConverted = await GetCustomerEnteredPrice(model);
}
-
- var quantity = GetQuantity(form, productId);
-
+
//product and gift voucher attributes
- var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Form = form });
+ var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Model = model });
//rental attributes
DateTime? rentalStartDate = null;
DateTime? rentalEndDate = null;
if (product.ProductTypeId == ProductType.Reservation)
{
- product.ParseReservationDates(form, out rentalStartDate, out rentalEndDate);
+ product.ParseReservationDates(model, out rentalStartDate, out rentalEndDate);
}
//product reservation
- string reservationId = "";
- string parameter = "";
- string duration = "";
+ var parameter = "";
+ var duration = "";
if (product.ProductTypeId == ProductType.Reservation)
{
- foreach (string formKey in form.Keys)
- {
- if (formKey.Contains("Reservation"))
- {
- reservationId = form["Reservation"].ToString();
- break;
- }
- }
-
- if (product.IntervalUnitId == IntervalUnit.Hour || product.IntervalUnitId == IntervalUnit.Minute)
+ switch (product.IntervalUnitId)
{
- if (string.IsNullOrEmpty(reservationId))
- {
+ case IntervalUnit.Hour or IntervalUnit.Minute when string.IsNullOrEmpty(model.Reservation):
return Json(new
{
success = false,
message = _translationService.GetResource("Product.Addtocart.Reservation.Required")
});
- }
- var productReservationService = HttpContext.RequestServices.GetRequiredService<IProductReservationService>();
- var reservation = await productReservationService.GetProductReservation(reservationId);
- if (reservation == null)
+ case IntervalUnit.Hour or IntervalUnit.Minute:
{
- return Json(new
+ var productReservationService = HttpContext.RequestServices.GetRequiredService<IProductReservationService>();
+ var reservation = await productReservationService.GetProductReservation(model.Reservation);
+ if (reservation == null)
{
- success = false,
- message = "No reservation found"
- });
+ return Json(new
+ {
+ success = false,
+ message = "No reservation found"
+ });
+ }
+ duration = reservation.Duration;
+ rentalStartDate = reservation.Date;
+ parameter = reservation.Parameter;
+ break;
}
- duration = reservation.Duration;
- rentalStartDate = reservation.Date;
- parameter = reservation.Parameter;
- }
- else if (product.IntervalUnitId == IntervalUnit.Day)
- {
- string datefrom = "";
- string dateto = "";
- foreach (var item in form)
+ case IntervalUnit.Day:
{
- if (item.Key == "reservationDatepickerFrom")
+ const string datePickerFormat = "MM/dd/yyyy";
+ if (!string.IsNullOrEmpty(model.ReservationDatepickerFrom))
{
- datefrom = item.Value;
+ rentalStartDate = DateTime.ParseExact(model.ReservationDatepickerFrom, datePickerFormat, CultureInfo.InvariantCulture);
}
-
- if (item.Key == "reservationDatepickerTo")
+ if (!string.IsNullOrEmpty(model.ReservationDatepickerTo))
{
- dateto = item.Value;
+ rentalEndDate = DateTime.ParseExact(model.ReservationDatepickerTo, datePickerFormat, CultureInfo.InvariantCulture);
}
- }
-
- string datePickerFormat = "MM/dd/yyyy";
- if (!string.IsNullOrEmpty(datefrom))
- {
- rentalStartDate = DateTime.ParseExact(datefrom, datePickerFormat, CultureInfo.InvariantCulture);
- }
- if (!string.IsNullOrEmpty(dateto))
- {
- rentalEndDate = DateTime.ParseExact(dateto, datePickerFormat, CultureInfo.InvariantCulture);
+ break;
}
}
}
@@ -473,10 +430,8 @@ namespace Grand.Web.Controllers
//save item
var addToCartWarnings = new List<string>();
-
-
- string warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
- form["WarehouseId"].ToString() :
+ var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
+ model.WarehouseId:
product.UseMultipleWarehouses ? _workContext.CurrentStore.DefaultWarehouseId :
(string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId);
@@ -485,7 +440,7 @@ namespace Grand.Web.Controllers
var (warnings, shoppingCartItem) = await _shoppingCartService.AddToCart(_workContext.CurrentCustomer,
productId, cartType, _workContext.CurrentStore.Id, warehouseId,
attributes, customerEnteredPriceConverted,
- rentalStartDate, rentalEndDate, quantity, true, reservationId, parameter, duration,
+ rentalStartDate, rentalEndDate, model.EnteredQuantity, true, model.Reservation, parameter, duration,
new ShoppingCartValidatorOptions() {
GetRequiredProductWarnings = false,
GetInventoryWarnings = (cartType == ShoppingCartType.ShoppingCart || !_shoppingCartSettings.AllowOutOfStockItemsToBeAddedToWishlist),
@@ -510,7 +465,7 @@ namespace Grand.Web.Controllers
Product = product,
Customer = _workContext.CurrentCustomer,
ShoppingCartItem = shoppingCartItem,
- Quantity = quantity,
+ Quantity = model.EnteredQuantity,
CartType = cartType,
CustomerEnteredPrice = customerEnteredPriceConverted,
Attributes = attributes,
@@ -520,7 +475,7 @@ namespace Grand.Web.Controllers
TaxDisplayType = _workContext.TaxDisplayType,
Duration = duration,
Parameter = parameter,
- ReservationId = reservationId,
+ ReservationId = model.Reservation,
StartDate = rentalStartDate,
EndDate = rentalEndDate
});
@@ -728,7 +683,7 @@ namespace Grand.Web.Controllers
//availability dates
- if (!product.IsAvailable() && !(product.ProductTypeId == ProductType.Auction))
+ if (!product.IsAvailable() && product.ProductTypeId != ProductType.Auction)
return Json(new
{
success = false,
@@ -768,7 +723,7 @@ namespace Grand.Web.Controllers
}
[HttpPost]
- public virtual async Task<IActionResult> UpdateItemCart(string shoppingCartItemId, IFormCollection form)
+ public virtual async Task<IActionResult> UpdateItemCart(string shoppingCartItemId, ProductModel model)
{
var cart = _workContext.CurrentCustomer.ShoppingCartItems.FirstOrDefault(sci => sci.Id == shoppingCartItemId);
if (cart == null)
@@ -830,59 +785,30 @@ namespace Grand.Web.Controllers
double? customerEnteredPriceConverted = null;
if (product.EnteredPrice)
{
- foreach (string formKey in form.Keys)
- {
- if (formKey.Equals(string.Format("addtocart_{0}.CustomerEnteredPrice", cart.ProductId), StringComparison.OrdinalIgnoreCase))
- {
- if (double.TryParse(form[formKey], out double customerEnteredPrice))
- customerEnteredPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(customerEnteredPrice, _workContext.WorkingCurrency);
- break;
- }
- }
+ if (double.TryParse(model.CustomerEnteredPrice, out double customerEnteredPrice))
+ customerEnteredPriceConverted = await _currencyService.ConvertToPrimaryStoreCurrency(customerEnteredPrice, _workContext.WorkingCurrency);
}
#endregion
- #region Quantity
-
- var quantity = cart.Quantity;
- foreach (string formKey in form.Keys)
- if (formKey.Equals(string.Format("addtocart_{0}.EnteredQuantity", cart.ProductId), StringComparison.OrdinalIgnoreCase))
- {
- int.TryParse(form[formKey], out quantity);
- break;
- }
-
- #endregion
-
//product and gift voucher attributes
- var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Form = form });
+ var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Model = model });
//rental attributes
DateTime? rentalStartDate = cart.RentalStartDateUtc;
DateTime? rentalEndDate = cart.RentalEndDateUtc;
if (product.ProductTypeId == ProductType.Reservation)
{
- product.ParseReservationDates(form, out rentalStartDate, out rentalEndDate);
+ product.ParseReservationDates(model, out rentalStartDate, out rentalEndDate);
}
//product reservation
- string reservationId = cart.ReservationId;
- string parameter = cart.Parameter;
- string duration = cart.Duration;
+ var parameter = cart.Parameter;
+ var duration = cart.Duration;
if (product.ProductTypeId == ProductType.Reservation)
{
- foreach (string formKey in form.Keys)
- {
- if (formKey.Contains("Reservation"))
- {
- reservationId = form["Reservation"].ToString();
- break;
- }
- }
-
if (product.IntervalUnitId == IntervalUnit.Hour || product.IntervalUnitId == IntervalUnit.Minute)
{
- if (string.IsNullOrEmpty(reservationId))
+ if (string.IsNullOrEmpty(model.Reservation))
{
return Json(new
{
@@ -891,7 +817,7 @@ namespace Grand.Web.Controllers
});
}
var productReservationService = HttpContext.RequestServices.GetRequiredService<IProductReservationService>();
- var reservation = await productReservationService.GetProductReservation(reservationId);
+ var reservation = await productReservationService.GetProductReservation(model.Reservation);
if (reservation == null)
{
return Json(new
@@ -906,44 +832,27 @@ namespace Grand.Web.Controllers
}
else if (product.IntervalUnitId == IntervalUnit.Day)
{
- string datefrom = "";
- string dateto = "";
- foreach (var item in form)
+ const string datePickerFormat = "MM/dd/yyyy";
+ if (!string.IsNullOrEmpty(model.ReservationDatepickerFrom))
{
- if (item.Key == "reservationDatepickerFrom")
- {
- datefrom = item.Value;
- }
-
- if (item.Key == "reservationDatepickerTo")
- {
- dateto = item.Value;
- }
+ rentalStartDate = DateTime.ParseExact(model.ReservationDatepickerFrom, datePickerFormat, CultureInfo.InvariantCulture);
}
-
- string datePickerFormat = "MM/dd/yyyy";
- if (!string.IsNullOrEmpty(datefrom))
+ if (!string.IsNullOrEmpty(model.ReservationDatepickerTo))
{
- rentalStartDate = DateTime.ParseExact(datefrom, datePickerFormat, CultureInfo.InvariantCulture);
- }
-
- if (!string.IsNullOrEmpty(dateto))
- {
- rentalEndDate = DateTime.ParseExact(dateto, datePickerFormat, CultureInfo.InvariantCulture);
+ rentalEndDate = DateTime.ParseExact(model.ReservationDatepickerTo, datePickerFormat, CultureInfo.InvariantCulture);
}
}
}
-
//save item
var addToCartWarnings = new List<string>();
var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
- form["WarehouseId"].ToString() : cart.WarehouseId;
+ model.WarehouseId : cart.WarehouseId;
//update existing item
addToCartWarnings.AddRange(await _shoppingCartService.UpdateShoppingCartItem(_workContext.CurrentCustomer,
cart.Id, warehouseId, attributes, customerEnteredPriceConverted,
- rentalStartDate, rentalEndDate, quantity, true));
+ rentalStartDate, rentalEndDate, model.EnteredQuantity, true));
if (addToCartWarnings.Any())
{
diff --git a/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs b/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
index accbeda49..0ba5ec5ae 100644
--- a/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
+++ b/src/Web/Grand.Web/Controllers/OutOfStockSubscriptionController.cs
@@ -92,16 +92,15 @@ namespace Grand.Web.Controllers
}
[HttpPost, ActionName("SubscribePopup")]
- public virtual async Task<IActionResult> SubscribePopup(string productId, IFormCollection form)
+ public virtual async Task<IActionResult> SubscribePopup(ProductModel model)
{
- var product = await _productService.GetProductById(productId);
+ var product = await _productService.GetProductById(model.ProductId);
if (product == null)
throw new ArgumentException("No product found with the specified id");
var customer = _workContext.CurrentCustomer;
-
- string warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
- form["WarehouseId"].ToString() :
+ var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
+ model.WarehouseId :
product.UseMultipleWarehouses ? _workContext.CurrentStore.DefaultWarehouseId :
(string.IsNullOrEmpty(_workContext.CurrentStore.DefaultWarehouseId) ? product.WarehouseId : _workContext.CurrentStore.DefaultWarehouseId);
@@ -156,7 +155,7 @@ namespace Grand.Web.Controllers
product.BackorderModeId == BackorderMode.NoBackorders &&
product.AllowOutOfStockSubscriptions)
{
- var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Form = form });
+ var attributes = await _mediator.Send(new GetParseProductAttributes() { Product = product, Model = model });
var subscription = await _outOfStockSubscriptionService
.FindSubscription(customer.Id, product.Id, attributes, _workContext.CurrentStore.Id, warehouseId);
@@ -245,23 +244,18 @@ namespace Grand.Web.Controllers
return View(model);
}
[HttpPost, ActionName("CustomerSubscriptions")]
- public virtual async Task<IActionResult> CustomerSubscriptionsPOST(IFormCollection formCollection)
+ public virtual async Task<IActionResult> CustomerSubscriptions(string[] subscriptions)
{
- foreach (var key in formCollection.Keys)
+ foreach (var id in subscriptions)
{
- var value = formCollection[key];
-
- if (value.Equals("on") && key.StartsWith("biss", StringComparison.OrdinalIgnoreCase))
+ var subscription = await _outOfStockSubscriptionService.GetSubscriptionById(id);
+ if (subscription != null && subscription.CustomerId == _workContext.CurrentCustomer.Id)
{
- var id = key.Replace("biss", "").Trim();
- var subscription = await _outOfStockSubscriptionService.GetSubscriptionById(id);
- if (subscription != null && subscription.CustomerId == _workContext.CurrentCustomer.Id)
- {
- await _outOfStockSubscriptionService.DeleteSubscription(subscription);
- }
+ await _outOfStockSubscriptionService.DeleteSubscription(subscription);
}
+
}
-
+
return RedirectToRoute("CustomerOutOfStockSubscriptions");
}
diff --git a/src/Web/Grand.Web/Controllers/ProductController.cs b/src/Web/Grand.Web/Controllers/ProductController.cs
index 56136c81a..b8e14af1a 100644
--- a/src/Web/Grand.Web/Controllers/ProductController.cs
+++ b/src/Web/Grand.Web/Controllers/ProductController.cs
@@ -176,35 +176,35 @@ namespace Grand.Web.Controllers
//handle product attribute selection event. this way we return new price, overridden gtin/sku/mpn
//currently we use this method on the product details pages
[HttpPost]
- public virtual async Task<IActionResult> ProductDetails_AttributeChange(string productId, bool loadPicture, IFormCollection form)
+ public virtual async Task<IActionResult> ProductDetails_AttributeChange(ProductModel model, bool loadPicture)
{
- var product = await _productService.GetProductById(productId);
+ var product = await _productService.GetProductById(model.ProductId);
if (product == null)
return new JsonResult("");
- var model = await _mediator.Send(new GetProductDetailsAttributeChange() {
+ var modelProduct = await _mediator.Send(new GetProductDetailsAttributeChange() {
Currency = _workContext.WorkingCurrency,
Customer = _workContext.CurrentCustomer,
Store = _workContext.CurrentStore,
- Form = form,
+ Model = model,
LoadPicture = loadPicture,
Product = product,
});
return Json(new
{
- gtin = model.Gtin,
- mpn = model.Mpn,
- sku = model.Sku,
- price = model.Price,
- stockAvailability = model.StockAvailability,
- outOfStockSubscription = model.DisplayOutOfStockSubscription,
- buttonTextOutOfStockSubscription = model.ButtonTextOutOfStockSubscription,
- enabledattributemappingids = model.EnabledAttributeMappingIds.ToArray(),
- disabledattributemappingids = model.DisabledAttributeMappingids.ToArray(),
- notAvailableAttributeMappingids = model.NotAvailableAttributeMappingids.ToArray(),
- pictureFullSizeUrl = model.PictureFullSizeUrl,
- pictureDefaultSizeUrl = model.PictureDefaultSizeUrl,
+ gtin = modelProduct.Gtin,
+ mpn = modelProduct.Mpn,
+ sku = modelProduct.Sku,
+ price = modelProduct.Price,
+ stockAvailability = modelProduct.StockAvailability,
+ outOfStockSubscription = modelProduct.DisplayOutOfStockSubscription,
+ buttonTextOutOfStockSubscription = modelProduct.ButtonTextOutOfStockSubscription,
+ enabledattributemappingids = modelProduct.EnabledAttributeMappingIds.ToArray(),
+ disabledattributemappingids = modelProduct.DisabledAttributeMappingids.ToArray(),
+ notAvailableAttributeMappingids = modelProduct.NotAvailableAttributeMappingids.ToArray(),
+ pictureFullSizeUrl = modelProduct.PictureFullSizeUrl,
+ pictureDefaultSizeUrl = modelProduct.PictureDefaultSizeUrl,
});
}
diff --git a/src/Web/Grand.Web/Extensions/MappingExtensions.cs b/src/Web/Grand.Web/Extensions/MappingExtensions.cs
index e5ebd9f81..64d93155d 100644
--- a/src/Web/Grand.Web/Extensions/MappingExtensions.cs
+++ b/src/Web/Grand.Web/Extensions/MappingExtensions.cs
@@ -249,25 +249,22 @@ namespace Grand.Web.Extensions
return destination;
}
- public static void ParseReservationDates(this Product product, IFormCollection form,
+ public static void ParseReservationDates(this Product product, ProductModel model,
out DateTime? startDate, out DateTime? endDate)
{
startDate = null;
endDate = null;
- string startControlId = string.Format("reservationDatepickerFrom_{0}", product.Id);
- string endControlId = string.Format("reservationDatepickerTo_{0}", product.Id);
- var ctrlStartDate = form[startControlId];
- var ctrlEndDate = form[endControlId];
try
{
- //currenly we support only this format (as in the \Views\Product\_RentalInfo.cshtml file)
+ //currently we support only this format (as in the \Views\Product\_RentalInfo.cshtml file)
const string datePickerFormat = "MM/dd/yyyy";
- startDate = DateTime.ParseExact(ctrlStartDate, datePickerFormat, CultureInfo.InvariantCulture);
- endDate = DateTime.ParseExact(ctrlEndDate, datePickerFormat, CultureInfo.InvariantCulture);
+ startDate = DateTime.ParseExact(model.ReservationDatepickerFrom, datePickerFormat, CultureInfo.InvariantCulture);
+ endDate = DateTime.ParseExact(model.ReservationDatepickerTo, datePickerFormat, CultureInfo.InvariantCulture);
}
catch
{
+ // ignored
}
}
}
diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
index e3b258247..f2f908e92 100644
--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs
@@ -63,10 +63,10 @@ namespace Grand.Web.Features.Handlers.Products
{
var model = new ProductDetailsAttributeChangeModel();
- var customAttributes = await _mediator.Send(new GetParseProductAttributes() { Product = request.Product, Form = request.Form });
+ var customAttributes = await _mediator.Send(new GetParseProductAttributes() { Product = request.Product, Model = request.Model }, cancellationToken);
- string warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
- request.Form["WarehouseId"].ToString() :
+ var warehouseId = _shoppingCartSettings.AllowToSelectWarehouse ?
+ request.Model.WarehouseId :
request.Product.UseMultipleWarehouses ? request.Store.DefaultWarehouseId :
(string.IsNullOrEmpty(request.Store.DefaultWarehouseId) ? request.Product.WarehouseId : request.Store.DefaultWarehouseId);
@@ -75,7 +75,7 @@ namespace Grand.Web.Features.Handlers.Products
DateTime? rentalEndDate = null;
if (request.Product.ProductTypeId == ProductType.Reservation)
{
- request.Product.ParseReservationDates(request.Form, out rentalStartDate, out rentalEndDate);
+ request.Product.ParseReservationDates(request.Model, out rentalStartDate, out rentalEndDate);
}
model.Sku = request.Product.FormatSku(customAttributes);
diff --git a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetParseProductAttributesHandler.cs b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetParseProductAttributesHandler.cs
index ff4cd4da4..ace8fa006 100644
--- a/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetParseProductAttributesHandler.cs
+++ b/src/Web/Grand.Web/Features/Handlers/ShoppingCart/GetParseProductAttributesHandler.cs
@@ -40,7 +40,6 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
foreach (var attribute in productAttributes)
{
- string controlId = string.Format("product_attribute_{0}", attribute.Id);
switch (attribute.AttributeControlTypeId)
{
case AttributeControlType.DropdownList:
@@ -48,7 +47,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
case AttributeControlType.ColorSquares:
case AttributeControlType.ImageSquares:
{
- request.Form.TryGetValue(controlId, out var ctrlAttributes);
+ var ctrlAttributes = request.Model.Attributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(ctrlAttributes))
{
customAttributes = ProductExtensions.AddProductAttribute(customAttributes,
@@ -58,10 +57,10 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
break;
case AttributeControlType.Checkboxes:
{
- request.Form.TryGetValue(controlId, out var cblAttributes);
+ var cblAttributes = request.Model.Attributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(cblAttributes))
{
- foreach (var item in cblAttributes)
+ foreach (var item in cblAttributes.Split(','))
{
if (!string.IsNullOrEmpty(item))
customAttributes = ProductExtensions.AddProductAttribute(customAttributes,
@@ -88,7 +87,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
case AttributeControlType.MultilineTextbox:
case AttributeControlType.Datepicker:
{
- request.Form.TryGetValue(controlId, out var ctrlAttributes);
+ var ctrlAttributes = request.Model.Attributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
if (!string.IsNullOrEmpty(ctrlAttributes))
{
var enteredText = ctrlAttributes.ToString().Trim();
@@ -99,7 +98,7 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
break;
case AttributeControlType.FileUpload:
{
- request.Form.TryGetValue(controlId, out var guid);
+ var guid = request.Model.Attributes.FirstOrDefault(x => x.Key == attribute.Id)?.Value;
Guid.TryParse(guid, out Guid downloadGuid);
var download = await _downloadService.GetDownloadByGuid(downloadGuid);
if (download != null)
@@ -122,49 +121,17 @@ namespace Grand.Web.Features.Handlers.ShoppingCart
customAttributes = ProductExtensions.RemoveProductAttribute(customAttributes, attribute).ToList();
}
}
-
#endregion
-
#region Gift vouchers
if (request.Product.IsGiftVoucher)
{
- string recipientName = "";
- string recipientEmail = "";
- string senderName = "";
- string senderEmail = "";
- string giftVoucherMessage = "";
- foreach (string formKey in request.Form.Keys)
- {
- if (formKey.Equals(string.Format("giftvoucher_{0}.RecipientName", request.Product.Id), StringComparison.OrdinalIgnoreCase))
- {
- recipientName = request.Form[formKey];
- continue;
- }
- if (formKey.Equals(string.Format("giftvoucher_{0}.RecipientEmail", request.Product.Id), StringComparison.OrdinalIgnoreCase))
- {
- recipientEmail = request.Form[formKey];
- continue;
- }
- if (formKey.Equals(string.Format("giftvoucher_{0}.SenderName", request.Product.Id), StringComparison.OrdinalIgnoreCase))
- {
- senderName = request.Form[formKey];
- continue;
- }
- if (formKey.Equals(string.Format("giftvoucher_{0}.SenderEmail", request.Product.Id), StringComparison.OrdinalIgnoreCase))
- {
- senderEmail = request.Form[formKey];
- continue;
- }
- if (formKey.Equals(string.Format("giftvoucher_{0}.Message", request.Product.Id), StringComparison.OrdinalIgnoreCase))
- {
- giftVoucherMessage = request.Form[formKey];
- continue;
- }
- }
-
customAttributes = GiftVoucherExtensions.AddGiftVoucherAttribute(customAttributes,
- recipientName, recipientEmail, senderName, senderEmail, giftVoucherMessage).ToList();
+ request.Model.RecipientName,
+ request.Model.RecipientEmail,
+ request.Model.SenderName,
+ request.Model.SenderEmail,
+ request.Model.Message).ToList();
}
#endregion
diff --git a/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsAttributeChange.cs b/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsAttributeChange.cs
index c02daec2e..718931d21 100644
--- a/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsAttributeChange.cs
+++ b/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsAttributeChange.cs
@@ -4,7 +4,6 @@ using Grand.Domain.Directory;
using Grand.Domain.Stores;
using Grand.Web.Models.Catalog;
using MediatR;
-using Microsoft.AspNetCore.Http;
namespace Grand.Web.Features.Models.Products
{
@@ -15,6 +14,6 @@ namespace Grand.Web.Features.Models.Products
public Store Store { get; set; }
public Product Product { get; set; }
public bool LoadPicture { get; set; }
- public IFormCollection Form { get; set; }
+ public ProductModel Model { get; set; }
}
}
diff --git a/src/Web/Grand.Web/Features/Models/ShoppingCart/GetParseProductAttributes.cs b/src/Web/Grand.Web/Features/Models/ShoppingCart/GetParseProductAttributes.cs
index fd02411ad..31be39ca8 100644
--- a/src/Web/Grand.Web/Features/Models/ShoppingCart/GetParseProductAttributes.cs
+++ b/src/Web/Grand.Web/Features/Models/ShoppingCart/GetParseProductAttributes.cs
@@ -1,13 +1,13 @@
using Grand.Domain.Catalog;
using Grand.Domain.Common;
+using Grand.Web.Models.Catalog;
using MediatR;
-using Microsoft.AspNetCore.Http;
namespace Grand.Web.Features.Models.ShoppingCart
{
public class GetParseProductAttributes : IRequest<IList<CustomAttribute>>
{
public Product Product { get; set; }
- public IFormCollection Form { get; set; }
+ public ProductModel Model { get; set; }
}
}
diff --git a/src/Web/Grand.Web/Models/Catalog/ProductModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductModel.cs
new file mode 100644
index 000000000..fd647e966
--- /dev/null
+++ b/src/Web/Grand.Web/Models/Catalog/ProductModel.cs
@@ -0,0 +1,24 @@
+using Grand.Web.Common.Binders;
+using Grand.Web.Common.Models;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Grand.Web.Models.Catalog;
+
+public class ProductModel
+{
+ public string ProductId { get; set; }
+ public string WarehouseId { get; set; }
+ public string ReservationDatepickerFrom { get; set; }
+ public string ReservationDatepickerTo { get; set; }
+ public string RecipientName{ get; set; }
+ public string RecipientEmail{ get; set; }
+ public string SenderName{ get; set; }
+ public string SenderEmail{ get; set; }
+ public string Message{ get; set; }
+
+ [ModelBinder(BinderType = typeof(CustomAttributesBinder))]
+ public IList<CustomAttributeModel> Attributes { get; set; }
+ public string Reservation { get; set; }
+ public string CustomerEnteredPrice { get; set; }
+ public int EnteredQuantity { get; set; }
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/OutOfStockSubscription/CustomerSubscriptions.cshtml b/src/Web/Grand.Web/Views/OutOfStockSubscription/CustomerSubscriptions.cshtml
index 38168044c..b5495263b 100644
--- a/src/Web/Grand.Web/Views/OutOfStockSubscription/CustomerSubscriptions.cshtml
+++ b/src/Web/Grand.Web/Views/OutOfStockSubscription/CustomerSubscriptions.cshtml
@@ -57,7 +57,7 @@
<tr @(i % 2 == 0 ? Html.Raw(" class=\"odd\"") : Html.Raw(" class=\"even\""))>
<td class="select-boxes">
<label class="custom-control custom-checkbox">
- <input id="selectall" type="checkbox" name="biss@(item.Id)" class="rowcheckbox custom-control-input">
+ <input id="selectall" type="checkbox" name="subscriptions" value="@(item.Id)" class="rowcheckbox custom-control-input">
<span class="custom-control-label"></span>
<span class="custom-control-description">&nbsp;</span>
</label>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/AddToCart.cshtml b/src/Web/Grand.Web/Views/Product/Partials/AddToCart.cshtml
index 6a5fb6c7e..1285bd3f8 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/AddToCart.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/AddToCart.cshtml
@@ -1,17 +1,17 @@
@model ProductDetailsModel.AddToCartModel
@{
- var shoppingCartType = Model.UpdateShoppingCartItemType.HasValue ? Model.UpdateShoppingCartItemType.Value : ShoppingCartType.ShoppingCart;
+ var shoppingCartType = Model.UpdateShoppingCartItemType ?? ShoppingCartType.ShoppingCart;
}
-@if (!String.IsNullOrEmpty(Model.UpdatedShoppingCartItemId))
+@if (!string.IsNullOrEmpty(Model.UpdatedShoppingCartItemId))
{
- <input asp-for="UpdatedShoppingCartItemId" type="hidden" />
+ <input asp-for="UpdatedShoppingCartItemId" type="hidden"/>
}
@if (Model.EnteredPrice)
{
<div class="customer-entered-price mb-3 d-flex w-100 flex-column">
<div class="price-input">
- <label asp-for="CustomerEnteredPrice" class="enter-price-label">@Loc["Products.EnterProductPrice"]</label>
- <input asp-for="CustomerEnteredPrice" value="@Convert.ToInt32(Math.Ceiling(Model.CustomerEnteredPrice))" class="form-control enter-price-input" />
+ <label for=@($"CustomerEnteredPrice_{Model.ProductId}") class="enter-price-label">@Loc["Products.EnterProductPrice"]</label>
+ <input type="text" id=@($"CustomerEnteredPrice_{Model.ProductId}") name="CustomerEnteredPrice" value="@Convert.ToInt32(Math.Ceiling(Model.CustomerEnteredPrice))" class="form-control enter-price-input"/>
</div>
<div class="price-range pt-1">
@Model.CustomerEnteredPriceRange
@@ -20,7 +20,7 @@
}
@if (!Model.DisableBuyButton || Model.EnteredPrice)
{
- if (!String.IsNullOrEmpty(Model.MinimumQuantityNotification))
+ if (!string.IsNullOrEmpty(Model.MinimumQuantityNotification))
{
<div class="min-qty-notification text-danger w-100 mb-2">@Model.MinimumQuantityNotification</div>
}
@@ -28,78 +28,55 @@
@if (!Model.DisableBuyButton)
{
- @if (Model.AllowedQuantities.Any())
- {
- <select asp-for="EnteredQuantity" asp-items="Model.AllowedQuantities" class="custom-select form-control qty-dropdown mr-2"></select>
- if (!String.IsNullOrEmpty(Model.MeasureUnit))
+ @if (Model.AllowedQuantities.Any())
{
- <span class="qty-unit d-flex align-items-center mr-2">
- @Model.MeasureUnit
- </span>
+ <select name="EnteredQuantity" id=@($"EnteredQuantity_{Model.ProductId}") asp-items="Model.AllowedQuantities" class="custom-select form-control qty-dropdown mr-2"></select>
+ if (!string.IsNullOrEmpty(Model.MeasureUnit))
+ {
+ <span class="qty-unit d-flex align-items-center mr-2">
+ @Model.MeasureUnit
+ </span>
+ }
}
- }
- else
- {
-
- var addId = "addtocart_" + @Model.ProductId + "_EnteredQuantity";
- <label for="@addId" class="sr-only">@Loc["ShoppingCart.AddToCart"]</label>
- <input asp-for="EnteredQuantity" class="qty-input form-control text-center" type="number" inputmode="numeric" />
- if (!String.IsNullOrEmpty(Model.MeasureUnit))
+ else
{
- <span class="qty-unit d-flex align-items-center mr-2">
- @Model.MeasureUnit
- </span>
+ <label for=@($"EnteredQuantity_{Model.ProductId}") class="sr-only">@Loc["ShoppingCart.AddToCart"]</label>
+ <input type="number" inputmode="numeric" id=@($"EnteredQuantity_{Model.ProductId}") name="EnteredQuantity" value="1" class="qty-input form-control text-center">
+ if (!string.IsNullOrEmpty(Model.MeasureUnit))
+ {
+ <span class="qty-unit d-flex align-items-center mr-2">
+ @Model.MeasureUnit
+ </span>
+ }
}
- }
- {
- var addToCartText = "";
- if (!String.IsNullOrEmpty(Model.UpdatedShoppingCartItemId) && Model.UpdateShoppingCartItemType.HasValue && (Model.UpdateShoppingCartItemType.Value == ShoppingCartType.ShoppingCart || Model.UpdateShoppingCartItemType.Value == ShoppingCartType.OnHoldCart))
- {
- addToCartText = Loc["ShoppingCart.AddToCart.Update"];
- }
- else
- {
- addToCartText = Loc["ShoppingCart.AddToCart"];
- if (Model.IsReservation)
- {
- addToCartText = Loc["ShoppingCart.Reservation"];
- }
- if (Model.AvailableForPreOrder)
- {
- addToCartText = Loc["ShoppingCart.PreOrder"];
- }
- if (Model.IsAuction)
- {
- addToCartText = Loc["ShoppingCart.BuyNow"];
- }
- }
-
- <script asp-location="Footer" asp-order="300">
- if (document.getElementById("@Html.IdFor(model => model.EnteredQuantity)")) {
- document.getElementById("@Html.IdFor(model => model.EnteredQuantity)").addEventListener("keyup", function (event) {
- if (event.keyCode == 13) {
- document.getElementById("[email protected]").click();
- return false;
- }
- });
- }
- if (document.getElementById("@Html.IdFor(model => model.CustomerEnteredPrice)")) {
- document.getElementById("@Html.IdFor(model => model.CustomerEnteredPrice)").addEventListener("keyup", function (event) {
- if (event.keyCode == 13) {
- document.getElementById("[email protected]").click();
- return false;
- }
- });
- }
-
- </script>
- <div class="input-group-append">
- <button type="button" id="[email protected]" class="btn btn-info w-100 add-to-cart-button d-inline-flex" data-productid="@Model.ProductId" onclick="AxiosCart.addproducttocart_details('@Url.RouteUrl("AddProductDetails", new { productId = Model.ProductId, shoppingCartTypeId = (int)shoppingCartType })', '#product-details-form');return false;">
- <span>@addToCartText</span>
- </button>
- </div>
- }
+ var addToCartText = "";
+ if (!string.IsNullOrEmpty(Model.UpdatedShoppingCartItemId) && Model.UpdateShoppingCartItemType.HasValue && (Model.UpdateShoppingCartItemType.Value == ShoppingCartType.ShoppingCart || Model.UpdateShoppingCartItemType.Value == ShoppingCartType.OnHoldCart))
+ {
+ addToCartText = Loc["ShoppingCart.AddToCart.Update"];
+ }
+ else
+ {
+ addToCartText = Loc["ShoppingCart.AddToCart"];
+ }
+ if (Model.IsReservation)
+ {
+ addToCartText = Loc["ShoppingCart.Reservation"];
+ }
+ if (Model.AvailableForPreOrder)
+ {
+ addToCartText = Loc["ShoppingCart.PreOrder"];
+ }
+ if (Model.IsAuction)
+ {
+ addToCartText = Loc["ShoppingCart.BuyNow"];
+ }
+
+ <div class="input-group-append">
+ <button type="button" id="[email protected]" class="btn btn-info w-100 add-to-cart-button d-inline-flex" data-productid="@Model.ProductId" onclick="AxiosCart.addproducttocart_details('@Url.RouteUrl("AddProductDetails", new { productId = Model.ProductId, shoppingCartTypeId = (int)shoppingCartType })', @($"'#product-details-form-{Model.ProductId}'"));return false;">
+ <span>@addToCartText</span>
+ </button>
+ </div>
}
</div>
-}
+}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/Partials/AddToWishlist.cshtml b/src/Web/Grand.Web/Views/Product/Partials/AddToWishlist.cshtml
index 8e61e121a..f2c52d25a 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/AddToWishlist.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/AddToWishlist.cshtml
@@ -11,7 +11,7 @@
addToWishlistText = Loc["ShoppingCart.AddToWishlist"];
}
- <a id="[email protected]" class="btn btn-secondary add-to-wishlist-button mr-1" data-productid="@Model.ProductId" onclick="AxiosCart.addproducttocart_details('@Url.RouteUrl("AddProductDetails", new { productId = Model.ProductId, shoppingCartTypeId = (int)ShoppingCartType.Wishlist })', '#product-details-form');return false;" v-b-tooltip.hover.bottom title="@addToWishlistText">
+ <a id="[email protected]" class="btn btn-secondary add-to-wishlist-button mr-1" data-productid="@Model.ProductId" onclick="AxiosCart.addproducttocart_details('@Url.RouteUrl("AddProductDetails", new { productId = Model.ProductId, shoppingCartTypeId = (int)ShoppingCartType.Wishlist })', @($"'#product-details-form-{Model.ProductId}'"));return false;" v-b-tooltip.hover.bottom title="@addToWishlistText">
<span class="sr-only">@addToWishlistText</span>
<b-icon icon="heart"></b-icon>
</a>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml b/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml
index 434a487fa..3112cd492 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/AuctionInfo.cshtml
@@ -31,7 +31,7 @@
@if (Model.EndTime > DateTime.UtcNow)
{
<div class="btn-group w-100 mt-3">
- <input asp-for="HighestBidValue" type="number" class="form-control" value="@(Model.HighestBidValue > 0 ? (Model.HighestBidValue + 1).ToString(System.Globalization.CultureInfo.InvariantCulture) : (Model.StartPrice + 1).ToString(System.Globalization.CultureInfo.InvariantCulture))" />
+ <input name="HighestBidValue" type="number" class="form-control" value="@(Model.HighestBidValue > 0 ? (Model.HighestBidValue + 1).ToString(System.Globalization.CultureInfo.InvariantCulture) : (Model.StartPrice + 1).ToString(System.Globalization.CultureInfo.InvariantCulture))" />
<button id="[email protected]" class="btn btn-info add-to-cart-button d-inline-flex align-items-center" data-productid="@Model.Id" onclick="AxiosCart.addbid('@Url.RouteUrl("AddBid", new { productId = Model.Id })', '#product-details-form'); return false;">
<b-icon icon="hammer" class="mx-1"></b-icon><span>@Loc["ShoppingCart.Bid"]</span>
</button>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/GiftVoucherInfo.cshtml b/src/Web/Grand.Web/Views/Product/Partials/GiftVoucherInfo.cshtml
index 479ad6466..ec5a90b36 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/GiftVoucherInfo.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/GiftVoucherInfo.cshtml
@@ -1,34 +1,34 @@
-@model ProductDetailsModel.GiftVoucherModel
+@model ProductDetailsModel
<div class="giftvoucher generalMarginSupporter">
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.RecipientName"]</legend>
- <label asp-for="RecipientName" class="col-form-label">@Loc["Products.GiftVoucher.RecipientName"]:</label>
- <input asp-for="RecipientName" class="form-control recipient-name" />
+ <label for=@($"RecipientName_{Model.Id}") class="col-form-label">@Loc["Products.GiftVoucher.RecipientName"]:</label>
+ <input type="text" id=@($"RecipientName_{Model.Id}") name="RecipientName" value="@Model.GiftVoucher.RecipientName" class="form-control recipient-name" />
</fieldset>
- @if (Model.GiftVoucherType == Grand.Domain.Catalog.GiftVoucherType.Virtual)
+ @if (Model.GiftVoucher.GiftVoucherType == GiftVoucherType.Virtual)
{
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.RecipientEmail"]</legend>
- <label asp-for="RecipientEmail" class="col-form-label">@Loc["Products.GiftVoucher.RecipientEmail"]:</label>
- <input asp-for="RecipientEmail" class="form-control recipient-email" />
+ <label for=@($"RecipientEmail_{Model.Id}") class="col-form-label">@Loc["Products.GiftVoucher.RecipientEmail"]:</label>
+ <input type="email" id=@($"RecipientEmail_{Model.Id}") name="RecipientEmail" value="@Model.GiftVoucher.RecipientEmail" class="form-control recipient-email" />
</fieldset>
}
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.SenderName"]</legend>
- <label asp-for="SenderName" class="col-form-label">@Loc["Products.GiftVoucher.SenderName"]:</label>
- <input asp-for="SenderName" class="form-control sender-name" />
+ <label for=@($"SenderName_{Model.Id}") class="col-form-label">@Loc["Products.GiftVoucher.SenderName"]:</label>
+ <input type="text" id=@($"SenderName_{Model.Id}") name="SenderName" value="@Model.GiftVoucher.SenderName" class="form-control sender-name" />
</fieldset>
- @if (Model.GiftVoucherType == Grand.Domain.Catalog.GiftVoucherType.Virtual)
+ @if (Model.GiftVoucher.GiftVoucherType == GiftVoucherType.Virtual)
{
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.SenderEmail"]</legend>
- <label asp-for="SenderEmail" class="col-form-label">@Loc["Products.GiftVoucher.SenderEmail"]:</label>
- <input asp-for="SenderEmail" class="form-control sender-email" />
+ <label for=@($"SenderEmail_{Model.Id}") class="col-form-label">@Loc["Products.GiftVoucher.SenderEmail"]:</label>
+ <input type="email" id=@($"SenderEmail_{Model.Id}") name="SenderEmail" value="@Model.GiftVoucher.SenderEmail" class="form-control sender-email" />
</fieldset>
}
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.Message"]</legend>
- <label asp-for="Message" class="col-form-label">@Loc["Products.GiftVoucher.Message"]:</label>
- <textarea asp-for="Message" class="form-control message"></textarea>
+ <label for=@($"Message_{Model.Id}") class="col-form-label">@Loc["Products.GiftVoucher.Message"]:</label>
+ <textarea id=@($"Message_{Model.Id}") name="Message" value="@Model.GiftVoucher.Message" class="form-control message"></textarea>
</fieldset>
</div>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/OutOfStockSubscription.cshtml b/src/Web/Grand.Web/Views/Product/Partials/OutOfStockSubscription.cshtml
index cf06cb518..e2bc56fd4 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/OutOfStockSubscription.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/OutOfStockSubscription.cshtml
@@ -5,7 +5,7 @@
<script asp-location="Footer" asp-order="300">
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("[email protected]").addEventListener('click', function (event) {
- var form = document.querySelector('#product-details-form');
+ var form = document.querySelector('@($"#product-details-form-{Model.Id}")');
var data = new FormData(form);
axios({
url: '@Url.RouteUrl("OutOfStockSubscribePopup", new { productId = Model.Id })',
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
index 164e36163..568540510 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributes.cshtml
@@ -1,4 +1,4 @@
-@model IList<ProductDetailsModel.ProductAttributeModel>
+@model ProductDetailsModel
@using System.Text;
<div id="product-attributes"></div>
@@ -6,13 +6,12 @@
//dynamic update support
var attributesHaveAssociatedPictures = true;
var attributeChangeScriptsBuilder = new StringBuilder();
- var productId = Model.First().ProductId;
- var attributeChangeHandlerFuncName = string.Format("attribute_change_handler_{0}", productId);
+ var attributeChangeHandlerFuncName = $"attribute_change_handler_{Model.Id}";
var fileLink = @Url.RouteUrl("UploadFileProductAttribute");
//generate change event script
- foreach (var attribute in Model)
+ foreach (var attribute in Model.ProductAttributes)
{
- string controlId = string.Format("product_attribute_{0}", attribute.Id);
+ string controlId = $"product_attribute_{attribute.Id}";
switch (attribute.AttributeControlType)
{
case AttributeControlType.DropdownList:
@@ -45,10 +44,10 @@
}
//render scripts
<div id="product-attributes">
- <template v-if="standardProductAttributes.ProductAttributes !== 'undefined'">
+ <template v-if="standardProductAttributes_@(Model.Id).ProductAttributes !== 'undefined'">
<div class="attributes">
<table class="table">
- <tr v-for="attribute in standardProductAttributes.ProductAttributes">
+ <tr v-for="attribute in standardProductAttributes_@(Model.Id).ProductAttributes">
<td :id="'product_attribute_label_' + attribute.Id">
<span class="attribute-name">{{attribute.Name}}</span> <span v-if="attribute.IsRequired" class="required">*</span>
<template v-if="attribute.TextPrompt !==null">
@@ -61,11 +60,11 @@
<td :id="'product_attribute_input_' + attribute.Id">
<template v-if="attribute.AttributeControlType==4">
<label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>
- <input :name="'product_attribute_' + attribute.Id" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="standardProductAttributes.attrchange" />
+ <input :name="'attributes[' + attribute.Id+']'" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="standardProductAttributes_@(Model.Id).attrchange" />
</template>
<template v-if="attribute.AttributeControlType==1">
<label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>
- <select :id="'product_attribute_' + attribute.Id" class="form-control custom-select" :name="'product_attribute_' + attribute.Id" @@change="standardProductAttributes.attrchange">
+ <select :id="'product_attribute_' + attribute.Id" class="form-control custom-select" :name="'attributes[' + attribute.Id+']'" @@change="standardProductAttributes_@(Model.Id).attrchange">
<template v-if="attribute.IsRequired==false">
<option value="">---</option>
</template>
@@ -88,11 +87,11 @@
<input class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="radio"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected"
:data-disable="attributeValue.Id"
- @@change="standardProductAttributes.attrchange" />
+ @@change="standardProductAttributes_@(Model.Id).attrchange" />
<span class="custom-control-label"></span>
<span class="custom-control-description" :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id">
<template v-if="attributeValue.PriceAdjustment==null">
@@ -117,20 +116,20 @@
class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="checkbox"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected"
- @@change="standardProductAttributes.attrchange"
+ @@change="standardProductAttributes_@(Model.Id).attrchange"
disabled="disabled" />
<input v-else
class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="checkbox"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected"
:data-disable="attributeValue.Id"
- @@change="standardProductAttributes.attrchange" />
+ @@change="standardProductAttributes_@(Model.Id).attrchange" />
<span class="custom-control-label"></span>
<span class="custom-control-description" :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id">
<template v-if="attributeValue.PriceAdjustment==null">
@@ -146,7 +145,7 @@
</fieldset>
</template>
<template v-if="attribute.AttributeControlType==10">
- <textarea :id="'product_attribute_' + attribute.Id" :name="'product_attribute_' + attribute.Id">{{attribute.DefaultValue}}</textarea>
+ <textarea :id="'product_attribute_' + attribute.Id" :name="'attributes[' + attribute.Id+']'">{{attribute.DefaultValue}}</textarea>
</template>
<template v-if="attribute.AttributeControlType==30">
<template>
@@ -162,7 +161,7 @@
<input class="hidden-upload-input"
type="hidden"
:id="'product_attribute_' + attribute.Id"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
v-model="attribute.DefaultValue"
:value="attribute.DefaultValue" />
<div id="download-message" class="alert my-2" style="display: none;"></div>
@@ -172,7 +171,7 @@
<ul class="option-list color-squares w-100 d-inline-flex flex-wrap px-0 mb-0" :id="'color-squares-' + attribute.Id">
<li v-for="attributeValue in attribute.Values" class="mr-1 p-0">
<label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes.attrchange" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange" />
<template v-if="attributeValue.PriceAdjustment==null">
<span class="color-container" :title="attributeValue.Name"> <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span> </span>
</template>
@@ -188,7 +187,7 @@
<li v-for="attributeValue in attribute.Values" class="mr-1 p-0">
<label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">
<template v-if="attributeValue.PriceAdjustment==null">
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes.attrchange" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange" />
<span :id="'imgSqr_' + attributeValue.Id" class="color-container">
<span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span>
</span>
@@ -197,7 +196,7 @@
</b-tooltip>
</template>
<template v-else>
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes.attrchange" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange" />
<span :id="'imgSqr_' + attributeValue.Id" class="color-container"> <span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span> </span>
<b-tooltip :target="'imgSqr_' + attributeValue.Id" placement="bottom">
<div class="image-square-tooltip">
@@ -217,7 +216,7 @@
</template>
</div>
<script asp-location="Footer" asp-order="300">
- var standardProductAttributes = new Vue({
+ var standardProductAttributes_@(Model.Id) = new Vue({
data: function () {
return {
ProductAttributes: null
@@ -225,46 +224,46 @@
},
methods: {
attrchange: function @(attributeChangeHandlerFuncName)() {
- var form = document.getElementById('product-details-form');
+ var form = document.getElementById('@($"product-details-form-{Model.Id}")');
var data = new FormData(form);
axios({
- url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = productId, loadPicture = attributesHaveAssociatedPictures }))',
+ url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = Model.Id, loadPicture = attributesHaveAssociatedPictures }))',
data: data,
method: 'post',
- params: { product: '@productId' },
+ params: { product: '@Model.Id' },
}).then(function (response) {
if (response.data.price) {
- document.querySelector('.price-value-@productId').innerText = response.data.price;
+ document.querySelector('[email protected]').innerText = response.data.price;
}
if (response.data.sku) {
- if(document.querySelector('#sku-@productId'))
- document.querySelector('#sku-@productId').innerText = response.data.sku;
+ if(document.querySelector('#[email protected]'))
+ document.querySelector('#[email protected]').innerText = response.data.sku;
}
if (response.data.mpn) {
- if(document.querySelector('#mpn-@productId'))
- document.querySelector('#mpn-@productId').innerText = response.data.mpn;
+ if(document.querySelector('#[email protected]'))
+ document.querySelector('#[email protected]').innerText = response.data.mpn;
}
if (response.data.gtin) {
- if(document.querySelector('#gtin-@productId'))
- document.querySelector('#gtin-@productId').innerText = response.data.gtin;
+ if(document.querySelector('#[email protected]'))
+ document.querySelector('#[email protected]').innerText = response.data.gtin;
}
if (response.data.stockAvailability) {
- if(document.querySelector('#stock-availability-value-@productId'))
- document.querySelector('#stock-availability-value-@productId').innerText = response.data.stockAvailability;
+ if(document.querySelector('#[email protected]'))
+ document.querySelector('#[email protected]').innerText = response.data.stockAvailability;
}
if (response.data.outOfStockSubscription) {
- var element = document.querySelector('#out-of-stock-subscribe-@productId');
+ var element = document.querySelector('#[email protected]');
if (element)
element.style.display = "block";
}
if (response.data.outOfStockSubscription == false) {
- var element = document.querySelector('#out-of-stock-subscribe-@productId');
+ var element = document.querySelector('#[email protected]');
if (element) {
element.style.display = "none";
}
}
if (response.data.buttonTextOutOfStockSubscription) {
- var element = document.querySelector('#out-of-stock-subscribe-@productId');
+ var element = document.querySelector('#[email protected]');
if (element)
element.value = response.data.buttonTextOutOfStockSubscription;
}
@@ -280,35 +279,29 @@
document.querySelector('#product_attribute_input_' + response.data.disabledattributemappingids[i]).style.display = "none";
}
}
- if (response.data.notAvailableAttributeMappingids) {
+ @*if (response.data.notAvailableAttributeMappingids) {
document.querySelectorAll('[data-disable]').forEach((element) => element.disabled = false);
for (var i = 0; i < response.data.notAvailableAttributeMappingids.length; i++) {
if (document.querySelectorAll("[data-disable='" + response.data.notAvailableAttributeMappingids[i] + "']").length > 0) {
document.querySelectorAll("[data-disable='" + response.data.notAvailableAttributeMappingids[i] + "']")[0].disabled = true;
}
}
- }
- var product = this.product;
+ }*@
setTimeout(function () {
if (response.data.pictureDefaultSizeUrl) {
- if (document.querySelector(".product-grouped")) {
- document.getElementById('main-product-img-' + product).setAttribute("src", response.data.pictureDefaultSizeUrl);
- }
- else {
- document.getElementById('main-product-img-@productId').setAttribute("src", response.data.pictureDefaultSizeUrl);
- }
+ document.getElementById('[email protected]').setAttribute("src", response.data.pictureDefaultSizeUrl);
}
}, 100);
});
},
},
created() {
- this.ProductAttributes = @Json.Serialize(Model);
+ this.ProductAttributes = @Json.Serialize(Model.ProductAttributes);
}
});
document.addEventListener("DOMContentLoaded", function () {
- standardProductAttributes.attrchange();
+ standardProductAttributes_@(Model.Id).attrchange();
});
</script>
}
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributesBundle.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributesBundle.cshtml
index 53ef20dcf..8da0a6079 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductAttributesBundle.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductAttributesBundle.cshtml
@@ -11,7 +11,7 @@
//generate change event script
foreach (var attribute in Model)
{
- string controlId = string.Format("product_attribute_{0}", attribute.Id);
+ string controlId = $"product_attribute_{attribute.Id}";
switch (attribute.AttributeControlType)
{
case AttributeControlType.DropdownList:
@@ -75,8 +75,6 @@
}
-
-
<div id="product-attributes">
<product-attributes-bundle-@(productId)></product-attributes-bundle-@(productId)>
</div>
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ProductBundles.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ProductBundles.cshtml
index 4035ebe5a..ca61c5706 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ProductBundles.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ProductBundles.cshtml
@@ -45,11 +45,11 @@
<td :id="'product_attribute_input_' + attribute.Id">
<template v-if="attribute.AttributeControlType==4">
<label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>
- <input :name="'product_attribute_' + attribute.Id" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" />
+ <input :name="'attributes[' + attribute.Id+']'" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" />
</template>
<template v-if="attribute.AttributeControlType==1">
<label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>
- <select :id="'product_attribute_' + attribute.Id" class="form-control custom-select" :name="'product_attribute_' + attribute.Id">
+ <select :id="'product_attribute_' + attribute.Id" class="form-control custom-select" :name="'attributes[' + attribute.Id+']'">
<template v-if="attribute.IsRequired==false">
<option value="">---</option>
</template>
@@ -72,7 +72,7 @@
<input class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="radio"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected" />
<span class="custom-control-label"></span>
@@ -99,7 +99,7 @@
class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="checkbox"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected"
disabled="disabled" />
@@ -107,7 +107,7 @@
class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="checkbox"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected" />
<span class="custom-control-label"></span>
@@ -125,13 +125,13 @@
</fieldset>
</template>
<template v-if="attribute.AttributeControlType==10">
- <textarea :id="'product_attribute_' + attribute.Id" :name="'product_attribute_' + attribute.Id">{{attribute.DefaultValue}}</textarea>
+ <textarea :id="'product_attribute_' + attribute.Id" :name="'attributes[' + attribute.Id+']'">{{attribute.DefaultValue}}</textarea>
</template>
<template v-if="attribute.AttributeControlType==40">
<ul class="option-list color-squares w-100 d-inline-flex flex-wrap px-0 mb-0" :id="'color-squares-' + attribute.Id">
<li v-for="attributeValue in attribute.Values" class="mr-1 p-0">
<label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" />
<template v-if="attributeValue.PriceAdjustment==null">
<span class="color-container" :title="attributeValue.Name"> <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span> </span>
</template>
@@ -147,7 +147,7 @@
<li v-for="attributeValue in attribute.Values" class="mr-1 p-0">
<label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">
<template v-if="attributeValue.PriceAdjustment==null">
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" />
<span :id="'imgSqr_' + attributeValue.Id" class="color-container">
<span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span>
</span>
@@ -156,7 +156,7 @@
</b-tooltip>
</template>
<template v-else>
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" />
<span class="color-container"> <span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span> </span>
<b-tooltip :target="'imgSqr_' + attributeValue.Id" placement="bottom">
<div class="image-square-tooltip">
diff --git a/src/Web/Grand.Web/Views/Product/Partials/ReservationInfo.cshtml b/src/Web/Grand.Web/Views/Product/Partials/ReservationInfo.cshtml
index c005ae406..06ca1e260 100644
--- a/src/Web/Grand.Web/Views/Product/Partials/ReservationInfo.cshtml
+++ b/src/Web/Grand.Web/Views/Product/Partials/ReservationInfo.cshtml
@@ -19,11 +19,11 @@
{
<div>
<h5>@Loc["Products.Reservation.DateFrom"]:</h5>
- <input name="[email protected]" id="reservationDatepickerFrom" class="form-control datepicker" />
+ <input name="reservationDatepickerFrom" id="reservationDatepickerFrom" class="form-control datepicker" />
</div>
<div>
<h5>@Loc["Products.Reservation.DateTo"]:</h5>
- <input name="[email protected]" id="reservationDatepickerTo" class="form-control datepicker" />
+ <input name="reservationDatepickerTo" id="reservationDatepickerTo" class="form-control datepicker" />
</div>
}
else
diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
index d8793cc58..32ee42c36 100644
--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml
@@ -17,138 +17,146 @@
pagebuilder.AddCanonicalUrlParts(productUrl);
}
}
+
@section meta{
@if (seoSettings.OpenGraphMetaTags)
{
- <meta property="og:type" content="product" />
- <meta property="og:title" content="@Html.Encode(Model.Name)" />
- <meta property="og:description" content="@Html.Encode(Model.MetaDescription)" />
- <meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl" />
- <meta property="og:image:url" content="@Model.DefaultPictureModel.ImageUrl" />
- <meta property="og:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
- <meta property="og:site_name" content="@Html.Encode(Model.CurrentStoreName)" />
+ <meta property="og:type" content="product"/>
+ <meta property="og:title" content="@Html.Encode(Model.Name)"/>
+ <meta property="og:description" content="@Html.Encode(Model.MetaDescription)"/>
+ <meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl"/>
+ <meta property="og:image:url" content="@Model.DefaultPictureModel.ImageUrl"/>
+ <meta property="og:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>
+ <meta property="og:site_name" content="@Html.Encode(Model.CurrentStoreName)"/>
}
@if (seoSettings.TwitterMetaTags)
{
- <meta property="twitter:card" content="summary" />
- <meta property="twitter:site" content="@Html.Encode(Model.CurrentStoreName)" />
- <meta property="twitter:title" content="@Html.Encode(Model.Name)" />
- <meta property="twitter:description" content="@Html.Encode(Model.MetaDescription)" />
- <meta property="twitter:image" content="@Model.DefaultPictureModel.ImageUrl" />
- <meta property="twitter:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />
+ <meta property="twitter:card" content="summary"/>
+ <meta property="twitter:site" content="@Html.Encode(Model.CurrentStoreName)"/>
+ <meta property="twitter:title" content="@Html.Encode(Model.Name)"/>
+ <meta property="twitter:description" content="@Html.Encode(Model.MetaDescription)"/>
+ <meta property="twitter:image" content="@Model.DefaultPictureModel.ImageUrl"/>
+ <meta property="twitter:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>
}
}
+
<!--product breadcrumb-->
+
@section Breadcrumb
{
- <partial name="Partials/Breadcrumbs" model="Model.Breadcrumb" />
+ <partial name="Partials/Breadcrumbs" model="Model.Breadcrumb"/>
}
+
@await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_after_breadcrumb", additionalData = Model.Id })
<div class="page product-details-page product-standard product-grouped">
@await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_top", additionalData = Model.Id })
<validation-observer ref="ProductFormObserver">
- <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id="product-details-form" ref="form" v-on:submit.prevent="formSubmitParam($event, vm.$refs.ProductFormObserver)">
- <div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">
- <div class="product-essential">
- <div class="container">
- <div class="row">
- <vc:widget widget-zone="productdetails_before_pictures" additional-data="@Model.Id"></vc:widget>
- <!--product pictures-->
- <partial name="Partials/Pictures" model="Model" />
- <vc:widget widget-zone="productdetails_after_pictures" additional-data="@Model.Id"></vc:widget>
- <div class="col-xl-6 col-lg-6 col-md-7 col-12 overview pl-md-3 pl-0 pr-0">
- @if (!string.IsNullOrEmpty(Model.Flag))
- {
- <div class="product-label">
- <div class="badge badge-info">@Model.Flag</div>
- </div>
- }
- <partial name="Partials/Unavailable" model="Model" />
- <div class="product-name">
- <h1 class="generalTitle mb-3" itemprop="name">
- @Model.Name
- </h1>
+ <div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">
+ <div class="product-essential">
+ <div class="container">
+ <div class="row">
+ <vc:widget widget-zone="productdetails_before_pictures" additional-data="@Model.Id"></vc:widget>
+ <!--product pictures-->
+ <partial name="Partials/Pictures" model="Model"/>
+ <vc:widget widget-zone="productdetails_after_pictures" additional-data="@Model.Id"></vc:widget>
+ <div class="col-xl-6 col-lg-6 col-md-7 col-12 overview pl-md-3 pl-0 pr-0">
+ @if (!string.IsNullOrEmpty(Model.Flag))
+ {
+ <div class="product-label">
+ <div class="badge badge-info">@Model.Flag</div>
</div>
- @if (!String.IsNullOrEmpty(Model.ShortDescription))
- {
- <div class="short-description mb-3">
- @Html.Raw(Model.ShortDescription)
- </div>
- }
- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_overview_top", additionalData = Model.Id })
- <!--product reviews-->
- @if (Model.ProductReviewOverview.AllowCustomerReviews)
- {
- <partial name="Partials/ProductReviewOverview" model="Model.ProductReviewOverview" />
- }
- <!--product collections-->
- @if (Model.ProductCollections.Any())
- {
- <partial name="Partials/Collections" model="Model.ProductCollections" />
- }
- <!--warehouses-->
- @if (Model.AllowToSelectWarehouse)
- {
- <partial name="Partials/Warehouses" model="Model" />
- }
- <!--compare, email a friend-->
- <b-btn-group class="mt-2 mb-3 w-100">
- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_before", additionalData = Model.Id })
- <partial name="Partials/ProductsComparison" model="Model" />
- <partial name="Partials/SendFriend" model="Model" />
- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_after", additionalData = Model.Id })
- </b-btn-group>
- <partial name="Partials/ShareButton" model="Model" />
- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_overview_bottom", additionalData = Model.Id })
+ }
+ <partial name="Partials/Unavailable" model="Model"/>
+ <div class="product-name">
+ <h1 class="generalTitle mb-3" itemprop="name">
+ @Model.Name
+ </h1>
</div>
- </div>
- </div>
- </div>
-
- <div class="col-12 px-0 my-3">
- <div>
- <b-tabs content-class="mt-3" align="center">
- <b-tab title="@Loc["Products.Description"]" active>
- @Html.Raw(Model.FullDescription)
- </b-tab>
- @if (Model.ProductTags.Any())
+ @if (!String.IsNullOrEmpty(Model.ShortDescription))
{
- <b-tab title="@Loc["Products.Tags"]">
- <partial name="Partials/ProductTags" model="Model.ProductTags" />
- </b-tab>
+ <div class="short-description mb-3">
+ @Html.Raw(Model.ShortDescription)
+ </div>
}
- @if (Model.ProductSpecifications.Any())
+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_overview_top", additionalData = Model.Id })
+ <!--product reviews-->
+ @if (Model.ProductReviewOverview.AllowCustomerReviews)
{
- <b-tab title="@Loc["Products.Specs"]">
- <partial name="Partials/ProductSpecifications" model="Model.ProductSpecifications" />
- </b-tab>
+ <partial name="Partials/ProductReviewOverview" model="Model.ProductReviewOverview"/>
}
- @if (Model.ProductReviewOverview.AllowCustomerReviews)
+ <!--product collections-->
+ @if (Model.ProductCollections.Any())
{
- <b-tab id="review-tab" title="@Loc["Products.Reviews"]" :active="active ? true : false">
- @await Component.InvokeAsync("ProductReviews", new { productId = Model.Id })
- </b-tab>
+ <partial name="Partials/Collections" model="Model.ProductCollections"/>
}
- @if (Model.AskQuestionOnProduct)
+ <!--warehouses-->
+ @if (Model.AllowToSelectWarehouse)
{
- <b-tab title="@Loc["Products.ContactUs"]" @if (Model.ProductAskQuestion.DisplayCaptcha) { <text> @@click="askquestion.getCaptcha()" </text> }>
- <partial name="Partials/AskQuestionOnProduct" model="Model.ProductAskQuestion" />
- </b-tab>
+ <partial name="Partials/Warehouses" model="Model"/>
}
- </b-tabs>
+ <!--compare, email a friend-->
+ <b-btn-group class="mt-2 mb-3 w-100">
+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_before", additionalData = Model.Id })
+ <partial name="Partials/ProductsComparison" model="Model"/>
+ <partial name="Partials/SendFriend" model="Model"/>
+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_after", additionalData = Model.Id })
+ </b-btn-group>
+ <partial name="Partials/ShareButton" model="Model"/>
+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_overview_bottom", additionalData = Model.Id })
+ </div>
</div>
</div>
- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_before_collateral", additionalData = Model.Id })
- <div class="product-collateral">
- <div>
- <!--associated products-->
- @foreach (var variant in Model.AssociatedProducts)
+ </div>
+
+ <div class="col-12 px-0 my-3">
+ <div>
+ <b-tabs content-class="mt-3" align="center">
+ <b-tab title="@Loc["Products.Description"]" active>
+ @Html.Raw(Model.FullDescription)
+ </b-tab>
+ @if (Model.ProductTags.Any())
{
+ <b-tab title="@Loc["Products.Tags"]">
+ <partial name="Partials/ProductTags" model="Model.ProductTags"/>
+ </b-tab>
+ }
+ @if (Model.ProductSpecifications.Any())
+ {
+ <b-tab title="@Loc["Products.Specs"]">
+ <partial name="Partials/ProductSpecifications" model="Model.ProductSpecifications"/>
+ </b-tab>
+ }
+ @if (Model.ProductReviewOverview.AllowCustomerReviews)
+ {
+ <b-tab id="review-tab" title="@Loc["Products.Reviews"]" :active="active ? true : false">
+ @await Component.InvokeAsync("ProductReviews", new { productId = Model.Id })
+ </b-tab>
+ }
+ @if (Model.AskQuestionOnProduct)
+ {
+ <b-tab title="@Loc["Products.ContactUs"]"
+ @if (Model.ProductAskQuestion.DisplayCaptcha)
+ {
+ <text> @@click="askquestion.getCaptcha()" </text>
+ }>
+ <partial name="Partials/AskQuestionOnProduct" model="Model.ProductAskQuestion"/>
+ </b-tab>
+ }
+ </b-tabs>
+ </div>
+ </div>
+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_before_collateral", additionalData = Model.Id })
+ <div class="product-collateral">
+ <div>
+ <!--associated products-->
+ @foreach (var variant in Model.AssociatedProducts)
+ {
+ <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id=@($"product-details-form-{variant.Id}") ref="form" v-on:submit.prevent="formSubmitParam($event, vm.$refs.ProductFormObserver)">
<di class="card overflow-hidden associatedItem mb-3">
<div class="row no-gutters">
<div class="col-lg-3 col-md-4">
- <img class="img-fluid" id="[email protected]" alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl" class="rounded-0" />
+ <img class="img-fluid rounded-0" id="[email protected]" alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl" />
</div>
<div class="col-lg-9 col-md-8">
<div class="card-body overview" title="@variant.Name">
@@ -156,86 +164,67 @@
@Html.Raw(variant.ShortDescription)
</div>
<!--availability-->
- <partial name="Partials/Availability" model="variant" />
+ <partial name="Partials/Availability" model="variant"/>
<!--Code products - SKU, MAN, GTIN, Vendor info -->
- <partial name="Partials/Codes" model="variant" />
+ <partial name="Partials/Codes" model="variant"/>
<!--delivery-->
@if ((variant.FreeShippingNotificationEnabled && Model.IsFreeShipping) || !string.IsNullOrWhiteSpace(variant.DeliveryDate)
- || variant.NotReturnable || variant.AdditionalShippingCharge > 0)
+ || variant.NotReturnable || variant.AdditionalShippingCharge > 0)
{
- <partial name="Partials/DeliveryInfo" model="variant" />
+ <partial name="Partials/DeliveryInfo" model="variant"/>
}
<!--sample download-->
@if (variant.HasSampleDownload)
{
- <partial name="Partials/DownloadSample" model="variant" />
+ <partial name="Partials/DownloadSample" model="variant"/>
}
<!--attributes-->
- @{
- if (variant.ProductAttributes.Any())
- {
- var dataDictAttributes = new ViewDataDictionary(ViewData);
- dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", variant.Id);
- <partial name="Partials/ProductAttributes" model="variant.ProductAttributes" view-data="dataDictAttributes" />
- }
+ @if (variant.ProductAttributes.Any())
+ {
+ <partial name="Partials/ProductAttributes" model="variant" />
}
<!--gift voucher-->
- @{
- if (variant.GiftVoucher.IsGiftVoucher)
- {
- var dataDictGiftVoucher = new ViewDataDictionary(ViewData);
- dataDictGiftVoucher.TemplateInfo.HtmlFieldPrefix = string.Format("giftvoucher_{0}", variant.Id);
- <partial name="Partials/GiftVoucherInfo" model="variant.GiftVoucher" view-data="dataDictGiftVoucher" />
- }
+ @if (variant.GiftVoucher.IsGiftVoucher)
+ {
+ <partial name="Partials/GiftVoucherInfo" model="variant.GiftVoucher" />
}
<!--price breaks-->
@if (variant.TierPrices.Any())
{
- <partial name="Partials/TierPrices" model="variant.TierPrices" />
- }
- @{
- var dataDictAddToCart = new ViewDataDictionary(ViewData);
- dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", variant.Id);
+ <partial name="Partials/TierPrices" model="variant.TierPrices"/>
}
+
<!--price & add to cart-->
- @{
- var dataDictPrice = new ViewDataDictionary(ViewData);
- dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", variant.Id);
- <partial name="Partials/Prices" model="variant.ProductPrice" view-data="dataDictPrice" />
- }
- @{
- <partial name="Partials/AddToCart" model="variant.AddToCart" view-data="dataDictAddToCart" />
- var dataDictAddToWishlist = new ViewDataDictionary(ViewData);
- dataDictAddToWishlist.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", variant.Id);
- <div class="mt-2">
- <partial name="Partials/AddToWishlist" model="variant.AddToCart" view-data="dataDictAddToWishlist" />
- </div>
- }
+ <partial name="Partials/Prices" model="variant.ProductPrice"/>
+ <partial name="Partials/AddToCart" model="variant.AddToCart"/>
+ <div class="mt-2">
+ <partial name="Partials/AddToWishlist" model="variant.AddToCart"/>
+ </div>
</div>
</div>
</div>
</di>
- }
+ </form>
+ }
- @if (Model.AssociatedProducts.Count == 0)
- {
- <div class="no-associated-products">
- @Loc["Products.NoAssociatedProducts"]
- </div>
- }
- </div>
+ @if (Model.AssociatedProducts.Count == 0)
+ {
+ <div class="no-associated-products">
+ @Loc["Products.NoAssociatedProducts"]
+ </div>
+ }
</div>
- @if (Model.RenderCaptcha)
- {
- <partial name="Partials/Captcha" />
- }
</div>
- @await Component.InvokeAsync("RelatedProducts", new { productId = Model.Id })
- </form>
+ @if (Model.RenderCaptcha)
+ {
+ <partial name="Partials/Captcha"/>
+ }
+ </div>
+ @await Component.InvokeAsync("RelatedProducts", new { productId = Model.Id })
</validation-observer>
@if (Model.EmailAFriendEnabled)
{
@await Component.InvokeAsync("ProductEmailAFriend", new { productId = Model.Id })
}
@await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_bottom", additionalData = Model.Id })
-</div>
+</div>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
index c9487e6e4..51ff089c1 100644
--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml
@@ -51,7 +51,7 @@
<div class="page product-details-page product-standard">
<vc:widget widget-zone="productdetails_top" additional-data="@Model.Id"></vc:widget>
<validation-observer ref="ProductFormObserver">
- <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id="product-details-form" ref="form" v-on:submit.prevent="formSubmitParam($event, vm.$refs.ProductFormObserver)">
+ <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id=@($"product-details-form-{Model.Id}") ref="form" v-on:submit.prevent="formSubmitParam($event, vm.$refs.ProductFormObserver)">
<div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">
<div class="container position-relative">
<div class="row">
@@ -111,13 +111,9 @@
<partial name="Partials/ProductBundles" model="Model" />
}
<!--attributes-->
- @{
- if (Model.ProductAttributes.Any())
- {
- var dataDictAttributes = new ViewDataDictionary(ViewData);
- dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", Model.Id);
- <partial name="Partials/ProductAttributes" model="Model.ProductAttributes" view-data="dataDictAttributes" />
- }
+ @if (Model.ProductAttributes.Any())
+ {
+ <partial name="Partials/ProductAttributes" model="Model" />
}
<!--warehouses-->
@if (Model.AllowToSelectWarehouse)
@@ -125,20 +121,14 @@
<partial name="Partials/Warehouses" model="Model" />
}
<!--gift voucher-->
- @{
- if (Model.GiftVoucher.IsGiftVoucher)
- {
- var dataDictGiftVoucher = new ViewDataDictionary(ViewData);
- dataDictGiftVoucher.TemplateInfo.HtmlFieldPrefix = string.Format("giftvoucher_{0}", Model.Id);
- <partial name="Partials/GiftVoucherInfo" model="Model.GiftVoucher" view-data="dataDictGiftVoucher" />
- }
+ @if (Model.GiftVoucher.IsGiftVoucher)
+ {
+ <partial name="Partials/GiftVoucherInfo" model="Model" />
}
<!--reservation info-->
@if (Model.ProductType == ProductType.Reservation)
{
- var dataDictReservation = new ViewDataDictionary(ViewData);
- dataDictReservation.TemplateInfo.HtmlFieldPrefix = string.Format("reservation_{0}", Model.Id);
- <partial name="Partials/ReservationInfo" model="Model" view-data="dataDictReservation" />
+ <partial name="Partials/ReservationInfo" model="Model" />
}
<!--price & add to cart-->
<div class="overview-buttons generalMarginSupporter">
@@ -150,9 +140,7 @@
}
<div class="col-lg-12 px-0">
@{
- var dataDictPrice = new ViewDataDictionary(ViewData);
- dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", Model.Id);
- <partial name="Partials/Prices" model="Model.ProductPrice" view-data="dataDictPrice" />
+ <partial name="Partials/Prices" model="Model.ProductPrice"/>
}
</div>
<div class="generalMarginSupporter">
@@ -161,17 +149,11 @@
{
<partial name="Partials/AuctionInfo" model="Model" />
}
- @{
- var dataDictAddToWishlist = new ViewDataDictionary(ViewData);
- dataDictAddToWishlist.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", Model.Id);
- var dataDictAddToCart = new ViewDataDictionary(ViewData);
- dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", Model.Id);
- }
- <partial name="Partials/AddToCart" model="Model.AddToCart" view-data="dataDictAddToCart" />
+ <partial name="Partials/AddToCart" model="Model.AddToCart" />
<div class="btn-group mt-2 mb-3 w-100">
- @if (Model.ProductType == ProductType.SimpleProduct || Model.ProductType == ProductType.BundledProduct)
+ @if (Model.ProductType is ProductType.SimpleProduct or ProductType.BundledProduct)
{
- <partial name="Partials/AddToWishlist" model="Model.AddToCart" view-data="dataDictAddToWishlist" />
+ <partial name="Partials/AddToWishlist" model="Model.AddToCart" />
<partial name="Partials/ProductsComparison" model="Model" />
}
@if (Model.EmailAFriendEnabled)
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCart.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCart.cshtml
index a045f993e..70e5e9a26 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCart.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCart.cshtml
@@ -9,7 +9,7 @@
<div class="customer-entered-price mb-3 d-flex w-100 flex-column">
<div class="price-input">
<label :for="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_CustomerEnteredPrice'" class="enter-price-label">@Loc["Products.EnterProductPrice"]</label>
- <input :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_CustomerEnteredPrice'" :name="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '.CustomerEnteredPrice'" type="text" :value="PopupQuickViewVueModal.AddToCart.CustomerEnteredPrice" class="form-control enter-price-input" />
+ <input :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_CustomerEnteredPrice'" :name="'CustomerEnteredPrice'" type="text" :value="PopupQuickViewVueModal.AddToCart.CustomerEnteredPrice" class="form-control enter-price-input" />
</div>
<div class="price-range pt-1">
{{PopupQuickViewVueModal.AddToCart.CustomerEnteredPriceRange}}
@@ -24,7 +24,7 @@
<div role="group" class="input-group product-add-to-cart flex-nowrap">
<template v-if="!PopupQuickViewVueModal.AddToCart.DisableBuyButton">
<template v-if="PopupQuickViewVueModal.AddToCart.AllowedQuantities.length > 0">
- <select :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_EnteredQuantity'" :name="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '.EnteredQuantity'" class="custom-select form-control qty-dropdown mr-2">
+ <select :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_EnteredQuantity'" :name="'EnteredQuantity'" class="custom-select form-control qty-dropdown mr-2">
<template v-for="option in PopupQuickViewVueModal.AddToCart.AllowedQuantities">
<option :value="option.Value" :disabled="option.Disabled" :selected="option.Selected">{{option.Text}}</option>
</template>
@@ -32,7 +32,7 @@
</template>
<template v-else>
<label :for="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_EnteredQuantity'" class="sr-only">@Loc["ShoppingCart.AddToCart"]</label>
- <input v-model.number="PopupQuickViewVueModal.AddToCart.EnteredQuantity" :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_EnteredQuantity'" :name="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '.EnteredQuantity'" class="qty-input form-control text-center" type="number" inputmode="numeric" />
+ <input v-model.number="PopupQuickViewVueModal.AddToCart.EnteredQuantity" :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_EnteredQuantity'" :name="'EnteredQuantity'" class="qty-input form-control text-center" type="number" inputmode="numeric" />
<template v-if="PopupQuickViewVueModal.AddToCart.MeasureUnit !== ''">
<span class="qty-unit d-flex align-items-center mr-2">
{{PopupQuickViewVueModal.AddToCart.MeasureUnit}}
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCartGroup.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCartGroup.cshtml
index da953c984..2122cffcb 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCartGroup.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/AddToCartGroup.cshtml
@@ -2,7 +2,7 @@
<div class="customer-entered-price mb-3 d-flex w-100 flex-column">
<div class="price-input">
<label :for="'addtocart_' + variant.AddToCart.ProductId + '_CustomerEnteredPrice'" class="enter-price-label">@Loc["Products.EnterProductPrice"]</label>
- <input :id="'addtocart_' + variant.AddToCart.ProductId + '_CustomerEnteredPrice'" :name="'addtocart_' + variant.AddToCart.ProductId + '.CustomerEnteredPrice'" type="text" :value="variant.AddToCart.CustomerEnteredPrice" class="form-control enter-price-input" />
+ <input :id="'addtocart_' + variant.AddToCart.ProductId + '_CustomerEnteredPrice'" :name="'CustomerEnteredPrice'" type="text" :value="variant.AddToCart.CustomerEnteredPrice" class="form-control enter-price-input" />
</div>
<div class="price-range pt-1">
{{variant.AddToCart.CustomerEnteredPriceRange}}
@@ -17,7 +17,7 @@
<div role="group" class="input-group product-add-to-cart flex-nowrap">
<template v-if="!variant.AddToCart.DisableBuyButton">
<template v-if="variant.AddToCart.AllowedQuantities.length > 0">
- <select :id="'addtocart_' + variant.AddToCart.ProductId + '_EnteredQuantity'" :name="'addtocart_' + variant.AddToCart.ProductId + '.EnteredQuantity'" class="custom-select form-control qty-dropdown mr-2">
+ <select :id="'addtocart_' + variant.AddToCart.ProductId + '_EnteredQuantity'" :name="'EnteredQuantity'" class="custom-select form-control qty-dropdown mr-2">
<template v-for="option in variant.AddToCart.AllowedQuantities">
<option :value="option.Value" :disabled="option.Disabled" :selected="option.Selected">{{option.Text}}</option>
</template>
@@ -25,7 +25,7 @@
</template>
<template v-else>
<label :for="'addtocart_' + variant.AddToCart.ProductId + '_EnteredQuantity'" class="sr-only">@Loc["ShoppingCart.AddToCart"]</label>
- <input :value="variant.AddToCart.EnteredQuantity" :id="'addtocart_' + variant.AddToCart.ProductId + '_EnteredQuantity'" :name="'addtocart_' + variant.AddToCart.ProductId + '.EnteredQuantity'" value="" class="qty-input form-control text-center" type="number" inputmode="numeric" />
+ <input :value="variant.AddToCart.EnteredQuantity" :id="'addtocart_' + variant.AddToCart.ProductId + '_EnteredQuantity'" :name="'EnteredQuantity'" value="" class="qty-input form-control text-center" type="number" inputmode="numeric" />
<template v-if="variant.AddToCart.MeasureUnit !== null">
<span class="qty-unit d-flex align-items-center mr-2">
{{variant.AddToCart.MeasureUnit}}
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Attributes.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Attributes.cshtml
index 88e5c2a78..10fb1ad8c 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Attributes.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/Attributes.cshtml
@@ -15,11 +15,11 @@
<td :id="'product_attribute_input_' + attribute.Id">
<template v-if="attribute.AttributeControlType==4">
<label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>
- <input :name="'product_attribute_' + attribute.Id" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="vm.attrchange(attribute.ProductId, true)" />
+ <input :name="'attributes[' + attribute.Id+']'" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="vm.attrchange(attribute.ProductId, true)" />
</template>
<template v-if="attribute.AttributeControlType==1">
<label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>
- <select :id="'product_attribute_' + attribute.Id" class="form-control custom-select" :name="'product_attribute_' + attribute.Id" @@change="vm.attrchange(attribute.ProductId, true)">
+ <select :id="'product_attribute_' + attribute.Id" class="form-control custom-select" :name="'attributes[' + attribute.Id+']'" @@change="vm.attrchange(attribute.ProductId, true)">
<template v-if="attribute.IsRequired==false">
<option value="">---</option>
</template>
@@ -42,7 +42,7 @@
<input class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="radio"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected"
:data-disable="attributeValue.Id"
@@ -71,7 +71,7 @@
class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="checkbox"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected"
@@change="vm.attrchange(attribute.ProductId, true)"
@@ -80,7 +80,7 @@
class="custom-control-input"
:id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"
type="checkbox"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
:value="attributeValue.Id"
:checked="attributeValue.IsPreSelected"
:data-disable="attributeValue.Id"
@@ -100,7 +100,7 @@
</fieldset>
</template>
<template v-if="attribute.AttributeControlType==10">
- <textarea :id="'product_attribute_' + attribute.Id" :name="'product_attribute_' + attribute.Id">{{attribute.DefaultValue}}</textarea>
+ <textarea :id="'product_attribute_' + attribute.Id" :name="'attributes[' + attribute.Id+']'">{{attribute.DefaultValue}}</textarea>
</template>
<template v-if="attribute.AttributeControlType==30">
<template>
@@ -116,7 +116,7 @@
<input class="hidden-upload-input"
type="hidden"
:id="'product_attribute_' + attribute.Id"
- :name="'product_attribute_' + attribute.Id"
+ :name="'attributes[' + attribute.Id+']'"
v-model="attribute.DefaultValue"
:value="attribute.DefaultValue" />
<div id="download-message" class="alert my-2" style="display: none;"></div>
@@ -126,7 +126,7 @@
<ul class="option-list color-squares w-100 d-inline-flex flex-wrap px-0 mb-0" :id="'color-squares-' + attribute.Id">
<li v-for="attributeValue in attribute.Values" class="mr-1 p-0">
<label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :data-disable="attributeValue.Id" :checked="attributeValue.IsPreSelected" @@change="vm.attrchange(attribute.ProductId, true)" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :data-disable="attributeValue.Id" :checked="attributeValue.IsPreSelected" @@change="vm.attrchange(attribute.ProductId, true)" />
<template v-if="attributeValue.PriceAdjustment==null">
<span class="color-container" :title="attributeValue.Name"> <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span> </span>
</template>
@@ -142,7 +142,7 @@
<li v-for="attributeValue in attribute.Values" class="mr-1 p-0">
<label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">
<template v-if="attributeValue.PriceAdjustment==null">
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)" />
<span :id="'imgSqr_' + attributeValue.Id" class="color-container">
<span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span>
</span>
@@ -151,7 +151,7 @@
</b-tooltip>
</template>
<template v-else>
- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)" />
+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)" />
<span class="color-container"> <span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span> </span>
<b-tooltip :target="'imgSqr_' + attributeValue.Id" placement="bottom">
<div class="image-square-tooltip">
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/GiftVoucherInfo.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/GiftVoucherInfo.cshtml
index 88cfa17a3..aa9a24f65 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/GiftVoucherInfo.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/GiftVoucherInfo.cshtml
@@ -3,31 +3,31 @@
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.RecipientName"]</legend>
<label :for="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_RecipientName'" class="col-form-label">@Loc["Products.GiftVoucher.RecipientName"]:</label>
- <input :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_RecipientName'" v-model="PopupQuickViewVueModal.GiftVoucher.RecipientName" :name="'giftvoucher_'+ PopupQuickViewVueModal.Id +'.RecipientName'" class="form-control recipient-name" />
+ <input :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_RecipientName'" v-model="PopupQuickViewVueModal.GiftVoucher.RecipientName" :name="'RecipientName'" class="form-control recipient-name" />
</fieldset>
<template v-if="PopupQuickViewVueModal.GiftVoucher.GiftVoucherType == 0">
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.RecipientEmail"]</legend>
<label :for="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_RecipientEmail'" class="col-form-label">@Loc["Products.GiftVoucher.RecipientEmail"]:</label>
- <input :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_RecipientEmail'" v-model="PopupQuickViewVueModal.GiftVoucher.RecipientEmail" :name="'giftvoucher_'+ PopupQuickViewVueModal.Id +'.RecipientEmail'" class="form-control recipient-email" />
+ <input :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_RecipientEmail'" v-model="PopupQuickViewVueModal.GiftVoucher.RecipientEmail" :name="'RecipientEmail'" class="form-control recipient-email" />
</fieldset>
</template>
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.SenderName"]</legend>
<label :for="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_SenderName'" class="col-form-label">@Loc["Products.GiftVoucher.SenderName"]:</label>
- <input :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_SenderName'" v-model="PopupQuickViewVueModal.GiftVoucher.SenderName" :name="'giftvoucher_'+ PopupQuickViewVueModal.Id +'.SenderName'" class="form-control seder-name" />
+ <input :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_SenderName'" v-model="PopupQuickViewVueModal.GiftVoucher.SenderName" :name="'SenderName'" class="form-control seder-name" />
</fieldset>
<template v-if="PopupQuickViewVueModal.GiftVoucher.GiftVoucherType == 0">
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.SenderEmail"]</legend>
<label :for="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_SenderEmail'" class="col-form-label">@Loc["Products.GiftVoucher.SenderEmail"]:</label>
- <input :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_SenderEmail'" v-model="PopupQuickViewVueModal.GiftVoucher.SenderEmail" :name="'giftvoucher_'+ PopupQuickViewVueModal.Id +'.SenderEmail'" class="form-control seder-email" />
+ <input :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_SenderEmail'" v-model="PopupQuickViewVueModal.GiftVoucher.SenderEmail" :name="'SenderEmail'" class="form-control seder-email" />
</fieldset>
</template>
<fieldset>
<legend class="sr-only">@Loc["Products.GiftVoucher.Message"]</legend>
<label :for="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_Message'" class="col-form-label">@Loc["Products.GiftVoucher.Message"]:</label>
- <textarea :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_Message'" v-model="PopupQuickViewVueModal.GiftVoucher.Message" :name="'giftvoucher_'+ PopupQuickViewVueModal.Id +'.Message'" class="form-control seder-message"></textarea>
+ <textarea :id="'giftvoucher_'+ PopupQuickViewVueModal.Id +'_Message'" v-model="PopupQuickViewVueModal.GiftVoucher.Message" :name="'Message'" class="form-control seder-message"></textarea>
</fieldset>
</div>
</template>
diff --git a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/ReservationInfo.cshtml b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/ReservationInfo.cshtml
index 9ce235d0b..c26065abf 100644
--- a/src/Web/Grand.Web/Views/Shared/Partials/QuickView/ReservationInfo.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/Partials/QuickView/ReservationInfo.cshtml
@@ -13,11 +13,11 @@
<template v-if="PopupQuickViewVueModal.IntervalUnit == 10">
<div>
<h5>@Loc["Products.Reservation.DateFrom"]:</h5>
- <input :name="'reservationDatepickerFrom_' + PopupQuickViewVueModal.Id" id="reservationDatepickerFrom" class="form-control datepicker" v-model="PopupQuickViewVueModal.RentalStartDateUtc" />
+ <input :name="'reservationDatepickerFrom'" id="reservationDatepickerFrom" class="form-control datepicker" v-model="PopupQuickViewVueModal.RentalStartDateUtc" />
</div>
<div>
<h5>@Loc["Products.Reservation.DateTo"]:</h5>
- <input :name="'reservationDatepickerTo_' + PopupQuickViewVueModal.Id" id="reservationDatepickerTo" class="form-control datepicker" v-model="PopupQuickViewVueModal.RentalEndDateUtc" />
+ <input :name="'reservationDatepickerTo'" id="reservationDatepickerTo" class="form-control datepicker" v-model="PopupQuickViewVueModal.RentalEndDateUtc" />
</div>
</template>
<template v-else>
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.js
index e1312c3de..fcf2a687a 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js
@@ -429,14 +429,14 @@ var vm = new Vue({
document.querySelector('#product_attribute_input_' + response.data.disabledattributemappingids[i]).style.display = "none";
}
}
- if (response.data.notAvailableAttributeMappingids) {
+ /*if (response.data.notAvailableAttributeMappingids) {
document.querySelectorAll('[data-disable]').forEach((element) => element.disabled = false);
for (var i = 0; i < response.data.notAvailableAttributeMappingids.length; i++) {
if (document.querySelectorAll("[data-disable='" + response.data.notAvailableAttributeMappingids[i] + "']").length > 0) {
document.querySelectorAll("[data-disable='" + response.data.notAvailableAttributeMappingids[i] + "']")[0].disabled = true;
}
}
- }
+ }*/
if (response.data.pictureDefaultSizeUrl !== null) {
vm.PopupQuickViewVueModal.DefaultPictureModel.ImageUrl = response.data.pictureDefaultSizeUrl;
}
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js b/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
index 67e72abe1..01779ed6e 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.axios.js
@@ -62,7 +62,7 @@ var AxiosCart = {
if (document.querySelector("#ModalQuickView")) {
var form = document.querySelector('#ModalQuickView #product-details-form');
} else {
- var form = document.querySelector('.product-standard #product-details-form');
+ var form = document.querySelector(formselector);
}
var data = new FormData(form);
axios({
diff --git a/src/Web/Grand.Web/wwwroot/theme/script/public.common.js b/src/Web/Grand.Web/wwwroot/theme/script/public.common.js
index e40bc9a07..cc5e8f3a9 100644
--- a/src/Web/Grand.Web/wwwroot/theme/script/public.common.js
+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.common.js
@@ -537,7 +537,7 @@ var Reservation = {
},
onDatePickerSelect: function onDatePickerSelect() {
- var form = document.querySelector('#product-details-form');
+ var form = document.querySelector('#product-details-form-'+Reservation.productId);
var data = new FormData(form);
axios({
url: Reservation.ajaxUrl2,