Product requires other product - quantity add/update problem

7 months ago
Not quite sure if this is a bug or the expectation is wrong. Maybe someone is able to clarify how this is working.

1. nopCommerce version 4.50.4 clean/fresh setup
2. Actual behavior
   One test product and one required product added to catalog.
   Test product set checked with "require other product" and "required product id's" entered the
   required product id and "automatically add this product to the cart" is checked too.

   When adding the test product to the basket from product detail page with any quantity the test
   product and the required product is added to the basket with the same quantity. That's ok so far.
   When adding more of the test product to the basket the message appears that the "required
   product" has to be in the basket with the current quantity plus the quantity added.
   When changing now first the quantity of the required product to the desired quantity, it's
   possible to increase the quantity of the test product too.
3. Expected behavior
  The expectation would be that no message appears and the required product's quantity gets
  increased automatically together with the quantity of the test product and you don't have to  
  first increase the required product's quantity and then the test product quantity can be increased.
4. Steps to reproduce the problem
   Add test sku to the basket with any quantity from test products detail page and then again
  add more of the test product to the basket. The same happens when updating the quantity in the
  basket directly.
5. No private modifications done

Thanks for your help and best regards

Andy
7 months ago
Additional:

Forgot to mention that when again adding quantity to the test product only the quantity of the test product gets increased and not the quantity of the required product. Instead  you have to change that quantity manually on the basket page stating:

test product: This product requires the following product is added to the cart in the quantity of X: required product name
required product: This product is required in the quantity of X
7 months ago
Thanks for the info. We'll check it.
5 months ago
Hi NopCommerce-Team
thanks for fixing this, but I have another issue with the same topic but different.

1. nopCommerce version 4.50.4 clean/fresh setup
2. Actual behavior and  steps to reproduce the problem
Setup a new product and adding one required product to that new product.
It is currently possible to add more than once the same required product to a product in the admin backend. There is no check if this product id has been already added to the main product.

For example we have one main product and set the same required product three times in the admin backend.
On basket first insert we have 1x main product and 3x required product. On second basket insert it should be 2x main product and 6x required product, but it is 2x main product and 3x required product. If you do more adds of the main product then when you have the same quantity of main products like the required product the next time it is then 4x main product and 6x required product.

3. Expected behavior
  The expectation of our customer is when then main product is added to the basket,
the required product is added so many times to the basket like it was set as required product in admin backend.
This works on first basket insert of the main product but should also work on any subsequent adds to the basket.

4. No private modifications done

Thank you very much!
4 months ago
We've fixed this issue. Find out more about it on our github (#6843)
4 months ago
Thank you very much NopCommerce team!
It now works as expected.
3 weeks ago
Hi NopCommerce-Team,

it looks like the issue still persists.

1. nopCommerce version 4.50.4 clean/fresh setup
2. Actual behavior and  steps to reproduce the problem

If you have a setup of three or more products that all have the same required product set (all with automatic add to basket option checked) and you put all three into the basket, error message is thrown when third item gets added.

The problem seems to occur in ShoppingCartService.cs within method
protected virtual async Task<IList<string>> GetRequiredProductWarningsAsync(Customer customer, ShoppingCartType shoppingCartType, Product product,
     int storeId, int quantity, bool addRequiredProducts, int shoppingCartItemId)

at lines
            if (passedProductRequiredQuantity > quantity)
                warnings.Add(string.Format(await _localizationService.GetResourceAsync("ShoppingCart.RequiredProductUpdateWarning"), passedProductRequiredQuantity));


It doesn't respect the quantity of the same required product from the other two main products that are already in the basket.

Another problem is that if you go to the basket and update the quantities of the main products in the quantity input boxes it doesn't add the required products (method UpdateShoppingCartItemAsync). If you delete a main product the quantity of the required product gets reduced, which is ok.

3. Expected behavior
No error message should appear when adding three or more products to the basket that have the same required product set plus option auto add to basket checked for required product.
It should be possible to be able to change the quantity of a main product in the basket and then the required products quantity is also updated.

4. No private modifications done

Thank you very much!
3 weeks ago
[email protected] wrote:
Hi NopCommerce-Team,

it looks like the issue still persists.

1. nopCommerce version 4.50.4 clean/fresh setup

Hi, I think the fix was released on 4.50.6 so can you try upgrading it to the latest version and see if the issue still persist?
3 weeks ago
I believe you mean fixed in n 4.60.6 .
(There is no .6 for 4.50, and the team does not apply fixes to old major versions.)

You can use GitHub to find the source code changes done in 4.60, and then apply the same to your 4.50 source code.
3 weeks ago
New York wrote:
I believe you mean fixed in n 4.60.6 .
(There is no .6 for 4.50, and the team does not apply fixes to old major versions.)

You can use GitHub to find the source code changes done in 4.60, and then apply the same to your 4.50 source code.


Yes, my bad. Thanks for correcting me