Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding the quantity part to the _ProductBox.cshtml in the views/Catalog in nopcommerce2.2

Tags:

nopcommerce

In nopcommerce2.2,which uses mvc framework, how can I add the quantity part to the product in the multiple products i.e _ProductBox.cshtml? Actually when I go to the single product page,I will get the quantity part.But I cannot transfer the quantity part to the multiple products page.How can I do this?

like image 690
Sharathsshetty Avatar asked Nov 05 '22 07:11

Sharathsshetty


1 Answers

I'm on 2.3 so this could be different from your version.

You would need to change a few things about _ProductBox.cshtml.

When you go to a single product page, it looks like it is using _ProductVariantAddToCart.cshtml as the view. This view has an input for the desired quantity

@if (!Model.DisableBuyButton || !Model.DisableWishlistButton)
{
    @Html.LabelFor(model => model.EnteredQuantity)<text>:</text> 
    @Html.TextBoxFor(model => model.EnteredQuantity, new { style = "Width: 40px;" })
}

You can't simply add that field, though, because _ProductBox.cshtml is using JS to do a GET to the ShoppingCart controllers AddProductToCard action. On the other hand, _ProductVariantAddToCart.cshtml is POSTing back to the Catalog controller's AddToCartProduct action. There is some logic there to take in your quantity field plus a bunch of other stuff.

If I were you, I would just overload the AddProductToCart action on the ShoppingCartController to add a quantity parameter and use JS in the view to capture that and pass it along.

like image 127
AndyMcKenna Avatar answered Dec 13 '22 10:12

AndyMcKenna