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
cdmorgan10542616  
#1 Posted : Wednesday, May 20, 2020 7:31:20 AM(UTC)
cdmorgan10542616

Rank: Newbie

Groups: Authorized User
Joined: 5/20/2020(UTC)
Posts: 0

I'm adding some custom required fields to the ShipMethod view during the checkout process. When "Continue Checkout" is clicked, there's already logic in place in the HttpPost ShipMethod action to fall through if something isn't valid and "return ShipMethod()" instead of continuing on with the checkout process. I tied my custom validation in this method and tried to "return ShipMethod()" as well when my validation failed. After troubleshooting, pulling my logic back out, and manually triggering the default validation errors, I'm unable to get the page to load correctly when there's a validation failure. The page loads and displays the appropriate error, but it's only the ShipMethod widget that loads, there's no frame or styling (no header, footer, menu, etc.). Has anyone seen this? Any idea what I'm doing wrong? Not sure if it has something to do with it or not, but the url changes from "/Checkout/ShipMethod" to "/Checkout/ShipMethod/44" so maybe the extra url segment is causing the widget to load by itself?

-chad

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

mazhar  
#2 Posted : Thursday, May 21, 2020 9:47:12 AM(UTC)
mazhar

Rank: Administration

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

Thanks: 8 times
Was thanked: 17 time(s) in 15 post(s)
Its hard to say without looking at code but I think instead of loading content dynamically using ajax it is directly navigating to the shipmethod action.
cdmorgan10542616  
#3 Posted : Thursday, May 21, 2020 7:30:12 PM(UTC)
cdmorgan10542616

Rank: Newbie

Groups: Authorized User
Joined: 5/20/2020(UTC)
Posts: 0

I believe I've worked around the issue. For anyone else who may have the same problem, I resolved it by forcing the id segment of the url to be an empty string. The original code in ShipMethod.cshtml for the form is:

@using (Html.BeginForm("ShipMethod", "Checkout", FormMethod.Post, new { id = "ship-method-form" }))

I replaced it with:

@using (Html.BeginForm("ShipMethod", "Checkout", new { @id = string.Empty }, FormMethod.Post, new { id = "ship-method-form" }))

I'm not sure what ID was being inserted as an additional url segment, but this changes the url for the post from /Checkout/ShipMethod/44 to /Checkout/ShipMethod, which loads the ShipMethod widget correctly within the context of the entire site rather than just the widget.

-chad
cdmorgan10542616  
#4 Posted : Friday, May 22, 2020 10:23:06 AM(UTC)
cdmorgan10542616

Rank: Newbie

Groups: Authorized User
Joined: 5/20/2020(UTC)
Posts: 0

Actually, that approach didn't work because the subsequent redirect to the Payment action failed due to being redirected from a child action. So I've instead resolved this by simply adding custom error messages to TempData when my custom validation fails, redirecting back to ShipMethod, checking the existence of my TempData field, and adding the error to ModelState at that point. Seems like a roundabout way of doing it but it appears to be working.
Users browsing this topic
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.