AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
ShipMethod validation in CheckoutController
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
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
ShipMethod validation in CheckoutController
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.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close