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 : Monday, November 15, 2021 3:30:57 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)
We're trying to track down a really unusual issue on the product page. It's probably self-inflicted. But we don't know how to locate the cause.

If a product page shows variants, and the shopper clicks add-to-cart without setting the variant selections first, the validation fires. Exactly like it should.

But the submit on the buyproductdialog form still got fired. And that throws an exception because the product ID wasn't included in the postback. So we wind up with a huge amount of this error in our error log:

Quote:

Controller: Product, Action: AddToCart, The parameters dictionary contains a null entry for parameter 'productId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult AddToCart(Int32)' in 'AbleCommerce.Controllers.ProductController'.


I'm trying to debug this in Chrome. And I'm terrible at it, this javascript stuff is all new to me. I can see in the Network tab where it -appears- to be TWO postbacks happening when I click the button. One to /AddToCart and one to the ID of product being viewed. I'm thinking there should only be one but I am not sure.

That's as far as I can get. I don't know how to tell where those postbacks get triggered in the page code. The initiator column just says 'main.js' which tells me nothing.

Any suggestions? Here's what it says in my Network tab after clicking the add-to-cart button:

Capture.JPG (30kb) downloaded 3 time(s).

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

shaharyar  
#2 Posted : Wednesday, November 17, 2021 2:08:11 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 704

Thanks: 5 times
Was thanked: 113 time(s) in 112 post(s)
I have tried to follow the exact scenario but I am not able to reproduce the issue locally on a 9.0.4 install.

There is only one call that is being sent by clicking the AddToCart button. Also, I can't see the main.js reference. In release mode, the file name is somewhat like the app?v=w...
Please see the screenshot.


Screenshot 2021-11-17 130648.png (27kb) downloaded 2 time(s).


Please make sure that there is no customization that is causing the issue. Or if you can share more details so that I can reproduce the issue.
Thanks
Joe Payne2  
#3 Posted : Wednesday, November 17, 2021 8:09:20 AM(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)
Were you testing on a variant product and making the validation fire i.e. not picking a required variant before clicking add-to-cart?

I'm fairly certain a customization somewhere has caused this.

I guess what I'm asking is if there's a way to tell exactly what javascript methods are fired when a button is clicked? Or is there a way to tell what routine made a specific <form> tag fire it's submit?

It has to be something attached to the button or the <form>. I just don't know how to track down stuff like this. There's so much js in the app I don't know where to begin to look.

Your screenshot does help a bit. At least it tells me which postback is the one that is SUPPOSED to be there. Now I just have to figure out why my 2nd postback is there.
judy at Web2Market  
#4 Posted : Thursday, November 18, 2021 5:54:10 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 289

Thanks: 21 times
Was thanked: 5 time(s) in 5 post(s)
Joe, I remember having and issue with custom code where it seemed like the page was posting back on its own and I had a time finding out why. I wish I could remember the solution, but I'm pretty sure it was in the app.js. I think most/all of the js for the buyproductdialog are in the same section and I think I might have put console logging in to figure it out. If I'm leading you astray, sorry. JS is my worst friend.
Joe Payne2  
#5 Posted : Thursday, November 18, 2021 9:16:45 AM(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)
Thanks Judy I'll give it a try
Users browsing this topic
Guest (2)
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.