Skip to content

Commit 7c95d87

Browse files
Added option to add products to cart in single positions
1 parent 6703f65 commit 7c95d87

File tree

6 files changed

+56
-19
lines changed

6 files changed

+56
-19
lines changed

src/Libraries/SmartStore.Core/Domain/Orders/ShoppingCartSettings.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ public ShoppingCartSettings()
2626
ShowBasePrice = true;
2727
DeliveryTimesInShoppingCart = DeliveryTimesPresentation.DateOnly;
2828
ShowShortDesc = true;
29-
AllowAnonymousUsersToEmailWishlist = false;
30-
}
31-
32-
/// <summary>
29+
AllowAnonymousUsersToEmailWishlist = false;
30+
AddProductsToBasketInSinglePositions = false;
31+
}
32+
33+
/// <summary>
3334
/// Gets or sets a value indicating whether a custoemr should be redirected to the shopping cart page after adding a product to the cart/wishlist
3435
/// </summary>
3536
public bool DisplayCartAfterAddingProduct { get; set; }
@@ -172,5 +173,10 @@ public ShoppingCartSettings()
172173
/// Gets or sets a value indicating whether to show the quantity of linked attribute value product
173174
/// </summary>
174175
public bool ShowLinkedAttributeValueQuantity { get; set; }
176+
177+
/// <summary>
178+
/// Gets or sets a value indicating whether to add products to the basket in single positions
179+
/// </summary>
180+
public bool AddProductsToBasketInSinglePositions { get; set; }
175181
}
176182
}

src/Libraries/SmartStore.Data/Migrations/MigrationsConfiguration.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
5858
builder.AddOrUpdate("Admin.Configuration.Settings.GeneralCommon.SocialSettings.TwitterSite.Error",
5959
"The Twitter username must begin with an '@'.",
6060
"Der Twitter-Benutzername muss mit einem '@' beginnen.");
61+
62+
builder.AddOrUpdate("Admin.Configuration.Settings.ShoppingCart.AddProductsToBasketInSinglePositions",
63+
"Add products to cart in single positions",
64+
"Produkte in einzelnen Positionen in den Warenkorb legen",
65+
"Enable this option if you want products with different quantities to be added to the shopping cart in single position.",
66+
"Aktivieren Sie diese Option, wenn Produkte mit verschiedenen Mengenangaben als Einzelpositionen in den Warenkorb gelegt werden sollen.");
6167
}
6268
}
6369
}

src/Libraries/SmartStore.Services/Orders/ShoppingCartService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ public virtual List<string> AddToCart(
10991099
existingCartItem = FindShoppingCartItemInTheCart(cart, cartType, product, selectedAttributes, customerEnteredPrice);
11001100
}
11011101

1102-
if (existingCartItem != null)
1102+
if (existingCartItem != null && !_shoppingCartSettings.AddProductsToBasketInSinglePositions)
11031103
{
11041104
// update existing shopping cart item
11051105
int newQuantity = existingCartItem.Item.Quantity + quantity;

src/Presentation/SmartStore.Web/Administration/Models/Settings/ShoppingCartSettingsModel.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ public ShoppingCartSettingsModel()
8585
[SmartResourceDisplayName("Admin.Configuration.Settings.ShoppingCart.ShowCommentBox")]
8686
public bool ShowCommentBox { get; set; }
8787

88-
[SmartResourceDisplayName("Admin.Configuration.Settings.ShoppingCart.ShowEsdRevocationWaiverBox")]
89-
public bool ShowEsdRevocationWaiverBox { get; set; }
88+
89+
[SmartResourceDisplayName("Admin.Configuration.Settings.ShoppingCart.ShowEsdRevocationWaiverBox")]
90+
public bool ShowEsdRevocationWaiverBox { get; set; }
9091

9192
[SmartResourceDisplayName("Admin.Configuration.Settings.ShoppingCart.NewsLetterSubscription")]
9293
public CheckoutNewsLetterSubscription NewsLetterSubscription { get; set; }
@@ -99,15 +100,19 @@ public ShoppingCartSettingsModel()
99100
[SmartResourceDisplayName("Admin.Configuration.Settings.ShoppingCart.ThirdPartyEmailHandOverLabel")]
100101
public string ThirdPartyEmailHandOverLabel { get; set; }
101102

102-
public IList<ShoppingCartSettingsLocalizedModel> Locales { get; set; }
103+
public IList<ShoppingCartSettingsLocalizedModel> Locales { get; set; }
104+
105+
106+
[SmartResourceDisplayName("Admin.Configuration.Settings.ShoppingCart.AddProductsToBasketInSinglePositions")]
107+
public bool AddProductsToBasketInSinglePositions { get; set; }
103108
}
104109

105110

106-
public class ShoppingCartSettingsLocalizedModel : ILocalizedModelLocal
107-
{
108-
public int LanguageId { get; set; }
111+
public class ShoppingCartSettingsLocalizedModel : ILocalizedModelLocal
112+
{
113+
public int LanguageId { get; set; }
109114

110115
[SmartResourceDisplayName("Admin.Configuration.Settings.ShoppingCart.ThirdPartyEmailHandOverLabel")]
111116
public string ThirdPartyEmailHandOverLabel { get; set; }
112117
}
113-
}
118+
}

src/Presentation/SmartStore.Web/Administration/Views/Setting/ShoppingCart.cshtml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,24 +294,44 @@
294294
@Html.ValidationMessageFor(model => model.ShowConfirmOrderLegalHint)
295295
</td>
296296
</tr>
297+
<tr>
298+
<td class="adminTitle">
299+
@Html.SmartLabelFor(model => model.ShowEsdRevocationWaiverBox)
300+
</td>
301+
<td class="adminData">
302+
@Html.SettingEditorFor(model => model.ShowEsdRevocationWaiverBox)
303+
@Html.ValidationMessageFor(model => model.ShowEsdRevocationWaiverBox)
304+
</td>
305+
</tr>
306+
307+
<tr>
308+
<td class="adminTitle">
309+
@Html.SmartLabelFor(model => model.ThirdPartyEmailHandOver)
310+
</td>
311+
<td class="adminData">
312+
@Html.SettingEditorFor(model => model.ThirdPartyEmailHandOver, Html.DropDownListFor(model => model.ThirdPartyEmailHandOver, Model.AvailableThirdPartyEmailHandOver))
313+
@Html.ValidationMessageFor(model => model.ThirdPartyEmailHandOver)
314+
</td>
315+
</tr>
297316
<tr>
298317
<td class="adminTitle">
299-
@Html.SmartLabelFor(model => model.ShowEsdRevocationWaiverBox)
318+
@Html.SmartLabelFor(model => model.ShowCommentBox)
300319
</td>
301320
<td class="adminData">
302-
@Html.SettingEditorFor(model => model.ShowEsdRevocationWaiverBox)
303-
@Html.ValidationMessageFor(model => model.ShowEsdRevocationWaiverBox)
321+
@Html.SettingEditorFor(model => model.ShowCommentBox)
322+
@Html.ValidationMessageFor(model => model.ShowCommentBox)
304323
</td>
305324
</tr>
306325
<tr>
307326
<td class="adminTitle">
308-
@Html.SmartLabelFor(model => model.ThirdPartyEmailHandOver)
327+
@Html.SmartLabelFor(model => model.AddProductsToBasketInSinglePositions)
309328
</td>
310329
<td class="adminData">
311-
@Html.SettingEditorFor(model => model.ThirdPartyEmailHandOver, Html.DropDownListFor(model => model.ThirdPartyEmailHandOver, Model.AvailableThirdPartyEmailHandOver))
312-
@Html.ValidationMessageFor(model => model.ThirdPartyEmailHandOver)
330+
@Html.SettingEditorFor(model => model.AddProductsToBasketInSinglePositions)
331+
@Html.ValidationMessageFor(model => model.AddProductsToBasketInSinglePositions)
313332
</td>
314333
</tr>
334+
315335
</table>
316336

317337
<div id="ThirdPartyEmailHandOverTextLocalized">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
this.createGallery(opts.galleryStartIndex);
2020

2121
// Update product data and gallery
22-
$(el).on('change', ':input', function (e) {
22+
$(el).on('change', ':input:not(.skip-update)', function (e) {
2323
var inputCtrl = $(this);
2424
var ctx = inputCtrl.closest('.update-container');
2525
var isTouchSpin = inputCtrl.parent(".bootstrap-touchspin").length > 0;

0 commit comments

Comments
 (0)