Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with AutomaticallyAddRequiredProducts when RequireOtherProducts is disabled #7206

Closed
RomanovM opened this issue May 27, 2024 · 1 comment
Assignees
Labels

Comments

@RomanovM
Copy link
Contributor

RomanovM commented May 27, 2024

nopCommerce version: 4.70

Example
You configured
RequireOtherProducts - True
RequiredProductIds - the list of products
AutomaticallyAddRequiredProducts - True
Save.

After it you disabled
RequireOtherProducts - False

Nopcommerce will try to add the required products in the shopping cart. It doesn't check the RequireOtherProducts

The fix is to add the checking RequireOtherProducts
The File ShoppingCartService.cs

 async Task addRequiredProductsToCartAsync(int qty = 0)
 {
     if (!product.RequireOtherProducts)
         return;
     //get these required products
     var requiredProducts = await _productService.GetProductsByIdsAsync(_productService.ParseRequiredProductIds(product));
     if (!requiredProducts.Any())
         return; 
     var finalRequiredProducts = requiredProducts.GroupBy(p => p.Id)
         .Select(g => new { Product = g.First(), Count = g.Count() });

Source: https://www.nopcommerce.com/boards/topic/99131/bug-with-adding-required-products

@exileDev
Copy link
Contributor

Closed #7206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants