Skip to content

Commit a947a44

Browse files
committed
smartstore#971 Product is added to cart automatically if it has a non-required file upload attribute
1 parent 3326cec commit a947a44

4 files changed

Lines changed: 28 additions & 7 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* Download nor sample download were removable when editing product
4747
* Copied product must not share sample download of source product. Could produce "The DELETE statement conflicted with the REFERENCE constraint 'FK_dbo.Product_dbo.Download_SampleDownloadId'".
4848
* #921 Specification attribute options with single quotation marks are causing a Javascript error
49+
* #971 Product is added to cart automatically if it has a non-required file upload attribute
4950

5051

5152
## SmartStore.NET 2.5

src/Presentation/SmartStore.Web/Scripts/public.product-detail.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,25 @@
2525

2626
// update product data and gallery
2727
$(el).find(':input').change(function () {
28+
var inputType = $(this).attr('type');
29+
if (inputType && (inputType === 'file' || inputType === 'submit'))
30+
return this;
31+
2832
var context = $(this).closest('.update-container');
2933

30-
if (context[0]) { // associated or bundled item
34+
if (context[0]) {
3135
}
3236
else {
3337
context = el;
3438
}
3539

36-
context.doAjax({
40+
var url = context.attr('data-url');
41+
if (!url) {
42+
return this;
43+
}
44+
45+
$({}).doAjax({
46+
url: url,
3747
data: context.find(':input').serialize(),
3848
callbackSuccess: function (response) {
3949
self.updateDetailData(response, context);

src/Presentation/SmartStore.Web/Scripts/public.product-detail.mobile.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,27 @@
1616

1717
var opts = this.options;
1818

19-
// update product data and gallery
20-
$(el).find(':input').change(function () {
19+
// update product data. grouped product not supported because associated product has no mobile view.
20+
$(el).find(':input').change(function () {
21+
var inputType = $(this).attr('type');
22+
if (inputType && (inputType === 'file' || inputType === 'submit'))
23+
return this;
24+
2125
var context = $(this).closest('.update-container');
2226

23-
if (context[0]) { // associated or bundled item
27+
if (context[0]) {
2428
}
2529
else {
2630
context = el;
2731
}
2832

29-
context.doAjax({
33+
var url = context.attr('data-url');
34+
if (!url) {
35+
return this;
36+
}
37+
38+
$({}).doAjax({
39+
url: url,
3040
data: context.find(':input').serialize(),
3141
callbackSuccess: function (response) {
3242
self.updateDetailData(response, context);

src/Presentation/SmartStore.Web/Views/Product/ProductTemplate.Simple.Mobile.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
}
6161
}
6262

63-
<div class="page product-details-page update-container">
63+
<div class="page product-details-page update-container" data-url="@Html.Raw(Model.UpdateProductDetailsUrl())">
6464
<div class="page-body">
6565
@Html.Widget("mobile_productdetails_top")
6666
@*we add enctype = "multipart/form-data" because "File upload" attribute control type requries it*@

0 commit comments

Comments
 (0)