Jump to content

Checkout With Custom Field Part 2


CraigA

Recommended Posts

WRT: http://www.blesta.com/forums/index.php?/topic/807-checkout-with-custom-field/

 

After applying Cody's fix, I now get error:

CustomFieldName is in an invalid format.

 

My field asks for an IP address.  I've used these two regex's

 

/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/

and

/\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/

 

both of these work once a client is created manually, just not when they try and checkout and create an account.

 

Not sure if bug so I posted it here first.

 

Ideas?

Link to comment
Share on other sites

That does not work in either scenario (when the client is created manually and then updates their info, or trying to check out as a new customer)

 

The two regex's I posted work when a client is already created and updates their information.  It just generates and invalid message during checkout with new clients.

Link to comment
Share on other sites

That does not work in either scenario (when the client is created manually and then updates their info, or trying to check out as a new customer)

 

The two regex's I posted work when a client is already created and updates their information.  It just generates and invalid message during checkout with new clients.

Try this mate:

 

^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$

That one looks more like the one I use for the date of birth.

Link to comment
Share on other sites

I had to wrap that in // for it to work with existing clients, but still errors out on using the order form to create a new client account

 

What errors do you get? I keep getting errors on this one field it's winding me up, however the IP one works fine and my date of birth it's just this one field called "How did you hear about us?" It's the first one on the form. (Is yours first?)

 

I get this error:

 

How did you hear about us? is set to an invalid value.

How did you hear about us? is in an invalid format.

 

on: http://billing.licensecart.com/plugin/order/main/signup/register

 

But it's a dropdown box with values in it.

 

preview video: http://screencast.com/t/8XuBkxOvCjNN

Link to comment
Share on other sites

Sounds like a bug with how the order form passes custom field values for validation. I believe custom fields are validated one at a time, so even if all of them are erroneous, only the first error would show.

 

 

This could be true.  Just wanted to note that mine shouldn't be erroring at all.  It works fine when editing "My Info" once the account is already created. 

Link to comment
Share on other sites

Sounds like a bug with how the order form passes custom field values for validation. I believe custom fields are validated one at a time, so even if all of them are erroneous, only the first error would show.

 

What would be the best way to go about this until the 3.0.1 mate? make a blank field for the first or will it still show a error?

Or shall we just disable them all now haha.

Link to comment
Share on other sites

I think Cody's fix from the other thread should be

 

update /app/models/clients.php (line 89):

$this->setCustomField($field->name, $client_id, isset($vars['custom']) && array_key_exists($field->name, $vars['custom']) ? $vars['custom'][$field->name] : null);

to

$this->setCustomField($field->id, $client_id, isset($vars['custom']) && array_key_exists($field->id, $vars['custom']) ? $vars['custom'][$field->id] : null);
Link to comment
Share on other sites

I think Cody's fix from the other thread should be

 

update /app/models/clients.php (line 89):

$this->setCustomField($field->name, $client_id, isset($vars['custom']) && array_key_exists($field->name, $vars['custom']) ? $vars['custom'][$field->name] : null);

to

$this->setCustomField($field->id, $client_id, isset($vars['custom']) && array_key_exists($field->id, $vars['custom']) ? $vars['custom'][$field->id] : null);

 

I can confirm this has resolved my issue.

 

Thanks for the great support guys!

Link to comment
Share on other sites

I think Cody's fix from the other thread should be

 

update /app/models/clients.php (line 89):

$this->setCustomField($field->name, $client_id, isset($vars['custom']) && array_key_exists($field->name, $vars['custom']) ? $vars['custom'][$field->name] : null);

to

$this->setCustomField($field->id, $client_id, isset($vars['custom']) && array_key_exists($field->id, $vars['custom']) ? $vars['custom'][$field->id] : null);

 

That fixed it thank you mate,

 

Also this IP Address Regex I found that worked with my IP address:

/^(??:1\d?\d|[1-9]?\d|2[0-4]\d|25[0-5])\.){3}(?:1\d?\d|[1-9]?\d|2[0-4]\d|25[0-5])$/
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...