5

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?

Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39
Sharathsshetty
  • 599
  • 6
  • 12

2 Answers2

2

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.

AndyMcKenna
  • 2,607
  • 3
  • 26
  • 35
0

This has been tested with version 3.0. Hope it will give you the idea what you need to change to make it work with opcommerce2.2

http://www.nopcommerce.com/boards/t/24852/add-the-quantity-textbox-next-to-addtocart-button-when-you-are-exploring-the-products.aspx

arlen
  • 1,065
  • 1
  • 16
  • 31