14 replies [Last post]
StephenGWills's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/07/2007
Juice: 414

When a customer makes an error on the checkout form such as, missing city in delivery panel, other data, notably the shipping quote and CC info are lost and the form repaints. Is there a central place I can look at in terms of preserving whatever info was supplied prior to an error?

Also, since the shipping quote is triggered on change of zone field, on the repainted form there is just teh passive recalculate button and no shipping method.

How are people dealing with this?

StephenGWills's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/07/2007
Juice: 414
Re: Losing cust checkout data on error.

As a follow up, in uc_quote.js, the function setQuoteCallbacks defines three condition under which a quote is generated.

1. The delivery_zone field changes
2. The quote reclaculation button is depressed
3. The known placed of user drop down changes.

Any suggestions on how to inplement a fourth condition:

An error has occurred and we are repainting the checkout page with data?

thanks.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Losing cust checkout data on error.

I'd say an onError event handler:

http://www.devguru.com/Technologies/ecmascript/QuickRef/evhan_onerror.html

http://www.w3schools.com/js/js_onerror.asp

But you might want to dig deeper to get the value of the error and include some helpful text (or reset whatever field happens to be the cause of the error, if any.) My .02.

--
Help directly fund development: Donate via PayPal!

StephenGWills's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/07/2007
Juice: 414
Re: Re: Re: Losing cust checkout data on error.

Maybe there are 5 conditions needed! Smiling

The one I am going after is not a javascript error but rather when a customer causes an error by not filling in a required field, for instance.

I fill out form, but leave required phone number blank. when the checkout page repaint with the error on top saying "phone number is required", I want the page to automatically trigger a quote recalc or.. ideally, display the old quote with the custmers choice from the previous screen still selected.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6841
Re: Re: Re: Losing cust checkout data on error.

onError refers to JavaScript errors, not Drupal form errors. I don't think that would be very useful because it's probably the quote fetching that causes the error, and just repeating it won't help.

I tried putting

<?php
 
if (form_get_errors()){
   
// get quotes
 
}
?>

but it didn't work. I think the form errors are reset by the time the page is displayed again.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15422
Re: Re: Re: Re: Losing cust checkout data on error.

This is a longstanding problem... sooo... I'm gonna add it to the beta fixin' post. It might be wise to turn this into an issue.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Re: Re: Re: Losing cust checkout data on error.

Ah, makes sense, I was figuring if the Ajax calls were throwing an error, but I see what you're doing now. My bad Smiling

--
Help directly fund development: Donate via PayPal!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15422
Re: Re: Re: Re: Re: Re: Losing cust checkout data on error.

Well, for quotes, Lyle should have nailed these with commits 742 and 744. For the payment details, that's a little more tricky... Those form fields are being generated by Drupal but not on the initial page load. They come from a separate request which knows naught of the data used to populate the rebuilt form w/ errors highlighted. Gonna look into it this afternoon...

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15422
Re: Re: Re: Re: Re: Re: Re: Losing cust checkout data on error.

Ok, I believe I resolved issues with the payment details on the Livetest. I'm struggling with Drupal's Forms API in a contest over who gets to validate what data when, and it wants to validate required fields first. That's unfortunate, because it will cause the payment pane not to expand when both the payment pane and a required field from somewhere else on the form fail validation. It's cool, though, because at least we're preserving the data... just a little bit annoying. And of course, this can be avoided by a site not using collapsible fields if they really don't want the hassle for their customers. Eye-wink

So, test it out and I'll be committing this for beta 5.

StephenGWills's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/07/2007
Juice: 414
Re: Re: Re: Re: Re: Re: Re: Re: Losing cust checkout data on err

Thanks, I'm looking forward to giving it a go! Smiling

GloryFish's picture
Offline
Joined: 04/11/2008
Juice: 10
Re: Losing cust checkout data on error.

Hello. I've just begun working on an existing install of Ubercart and I am experiencing this problem. I was wondering if this issue still exists in the latest stable release and also, how can one find the version number of an existing installation. That information isn't showing up in the Drupal modules list.

Thanks very much.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15422
Re: Re: Losing cust checkout data on error.

If the version number isn't showing up, it's probably a download from our Bazaar site. This issue has been fixed for a while, though. You might check to make sure they aren't using any incompatible contribs and then update the code to the latest version. We've posted some steps for that in this FAQ.

GloryFish's picture
Offline
Joined: 04/11/2008
Juice: 10
Re: Re: Re: Losing cust checkout data on error.

That's extremely helpful. Thank you very much.

GloryFish's picture
Offline
Joined: 04/11/2008
Juice: 10
Re: Losing cust checkout data on error.

I've updated to the latest version and I've narrowed down our issue to a contributed module. The module is uc_nodetype, referenced here: http://www.ubercart.org/forum/development/2121/uc_nodetype_module_purcha...

When credit card info on the checkout page fails validation the data contained in uc_nodetype's section of the form is lost. I've been looking through diffs of the uc_quote code to see what was done there to allow it to maintain it's state after a failed validation. I'm unfamiliar with the module so I'm a bit unsure of which code is core to storing that state.

I was hoping someone could point me towards a good starting point. Is it as simple as storing the form values in the sesssion during validation and retrieving them in form_alter()? Or, are there other gotchas i should be aware of?

Thanks for taking the time. Smiling

poppers's picture
Offline
Joined: 08/12/2008
Juice: 45
what code do i need

I only have flat rate shipping different on a per product basis, and I'd like to have the calculate shipping triggered on every paint of the form. How would I do this?