logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joe Payne2  
#1 Posted : Tuesday, July 20, 2021 2:05:20 PM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
I'm studying how you guys render product variant choices on the product page.

I notice in the _ProductQuickView view that you have a single reference to BuyProductDialog:

Code:
@Html.Action("BuyProductDialog", new { ProductId = Model })


My first question: Is that all I really need if I want to render the variant dropdowns for a given product id? I need to build a page that offers the variant choices for a product so I can add-to-cart based on the shopper choices.

I'm not complaining at how easy it looks. I'm more worried my inexperience with this area of the code is making it look easier than it really is. It just looks really easy lol

My second question: The BuyProductDialog methods in the ProductController class don't have an overload with just a ProductId as the parameter. When I hit F12 on the action name, I get two choices both of which involve BuyProductDialogParams but not 'ProductId'.

So how does MVC know which action method to call since neither one has a parameter for ProductId? I thought actions could only call a method with a matching signature? Shouldn't there be a public BuyProductDialog(int ProductId) somewhere in the controller??

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

sweeperqb  
#2 Posted : Wednesday, July 21, 2021 12:47:02 PM(UTC)
sweeperqb

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 5/30/2020(UTC)
Posts: 125

Thanks: 14 times
Was thanked: 3 time(s) in 3 post(s)
BuyProductDialogParams is found in /Models/ProductModels.cs. It includes a property for the ProductId, so I'm pretty sure it is being bound to that. It also has a property for ShowAllOptions that defaults to false. I may be mistaken, but you may be able to set that property to true to get the behavior you are looking for.
Joe Payne2  
#3 Posted : Wednesday, July 21, 2021 3:30:13 PM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
Originally Posted by: sweeperq1766875 Go to Quoted Post
BuyProductDialogParams is found in /Models/ProductModels.cs. It includes a property for the ProductId, so I'm pretty sure it is being bound to that. It also has a property for ShowAllOptions that defaults to false. I may be mistaken, but you may be able to set that property to true to get the behavior you are looking for.


Ok thanks. So that answers Q2. So when I call an Action method, I don't necessarily have to specify the exact method signature. As long as a signature includes a property matching the parameters that I did supply, MVC will wire it up for me. Good to know, I didn't realize that.

Hey I just learned yesterday you can pass custom properties as ViewBag data when calling @Html.Partial() - cool stuff!
Users browsing this topic
Guest (3)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.