I am new to nopcommerce development and running into little challenge and hope someone can help me in the right direction.
We have 2 products. 1 parent and 1 child. When user adds parent to cart the child is auto added as well. so far standard nop.
I need to change a few things on this:
- the child product should not be counted as product in the cart.
- when you go to cart and change the amount of the parent and update cart you now get a message that you also need to change the child amount. I need to automate this.
- the child amount should not be able to change by user in cart.
I would like to try not to change things in the nop source itself. I rather extend, or make plugin or something else?
Where to start? please point me in the right direction
Thank you all!!
Yes, thank you I will keep an eye on that one.
However my question is more if someone can help me in the right direction as I want to change these things in code without changing nopcommerce source.
(if it is a bug I believe that will be fixed)
Can I extend? or should I write a plugin? or something else?
So I want to change the shown product count as I do not want to count auto added products.
For your info. for this site we use this to add deposit to card when adding a product that has deposit.
( like beer bottles here in Netherlands).
This way we can have taxes on main product and not on the deposit product that is auto added.
but now when we add 12 bottles to cart it will show 24 products in cart....
Hello, thank you for your anwser.
We did look at this, however that causes the price for the child product will be added to the price of the main product and that is not allowed by law.
we need to show the price for main product and deposit both.
only when calculating the total cart cost we can add it up.
So still looking for the best solution but it seems we will need to develop some plugin that extends or overrides some code in NOP.
and 1 more problem with that solution might be a bug?
When main product has Tax and the related product attribute is exempted from Tax in the shopping cart you will see it calculates tax also for the related exempted product.
Thank you all for thinking along. Unfortunately checkout attr. is not the solution I think as different products will have different deposit values and there will be products without. I see no option to link checkout attr to specific products.
I think mandatory adding product via id to parent product comes closest to what we need.
But it will involve custom work.
so basicall the UpdateShoppingCartItemAsync should be changed/extended/??
if amount > 0 now gives warning but should update the amount for the auto added product as well just like it does when adding product to cart.
the else is strange btw. it doesn't return warnings but just deletes the product (amount 0) and leaves the auto added product in the cart. this might be just a bug but it is strange.
also we would need to try to fix the bug in adding products with these auto added child products as well. first time adding is oke. but if you add extra products things are screwed up.
it works perfectly. I've added maybe 10 lines of code to UpdateShoppingCartItemAsync and now autoadded required linked products now update along with the parent product and the warning there no longer appears.
So far so good. I did it not in the UpdateShoppingCartItemAsync itself but copied the code into own method and changed the code there. in UpdateShoppingCartItemAsync i added return mymethod.... and that works fine. this way after nop upgrade I only have to re-add the return line and check changes in the original function/method.
But I keep thinking this should not be the way to go. changing the core basically.
Anyone can point me in the right direction how to do this better in nopcommerce?