Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 02-24-2015 09:33:20

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Checkout State/County Field Not Suitable for all Customers

I have realised that the dropdown list of States/Counties is not going to work for all customers.

We cannot put every state/county for every country in the world in there and "Not Applicable" is going to put people off ordering as they might need to include one that is not listed.

The way PayPal approach this issue is...

For some countries (like the USA and UK) they provide a dropdown list of predefined States/Counties applicable to that country. This keeps the list short and manageable.

For other countries the field is editable so the user can add their own state/county/province text if need be.

If you want to see it in action login to your PayPal account using the express button, click the change address link and then the Add a new address link

This seems like the best solution to me but the problem is I cannot work out how they do it. Any suggestion on how to achieve this?

Last edited by sdn (02-25-2015 06:28:45)


Simon

Offline

 

#2 03-03-2015 08:39:19

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Checkout State/County Field Not Suitable for all Customers

In theory, you could edit the proper columns (ids will all end in '.stateprov') in the core_formfields table via Raw DB Admin.  In the 'fieldinclude' column, for each of those '*.stateprov' ids, enter 'core:formfield_stateprov.php'.  Next, copy the file {private}/core/CORE/includes/formfield_select.php and save the copy as {private}/core/CORE/includes/core:formfield_stateprov.php.  Now you have a file you can edit that is directly tied to the display of the stateprovince form fields.

The next step would be to add JavaScript (see the bottom of the file for info on how to do that) that recognizes a change to the '*--country' field in the same form and adjust the display of the '*--stateprov' formfield based on that.  It would probably be best to set up the stateprov form field as a text field and then emulate a select (when you need it) that updates it when the text field is hidden.


Nick Hendler

Offline

 

#3 12-04-2015 04:23:54

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Re: Checkout State/County Field Not Suitable for all Customers

Assuming this is not addressed in V9 I would like to give this a try but would like some clarification so I don't get into a big mess.

Do you mean every line id (330 of them) in core_formfields table  should end in .stateprov e.g. core.skinupdupload.upfile becomes core.skinupdupload.upfile.stateprov, etc?

Initially I propose to make a copy of core_formfields table called core_formfields_state_test to play with. I assume that will not affect the carts operation??

Last edited by sdn (12-04-2015 04:28:09)


Simon

Offline

 

#4 12-04-2015 08:11:11

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Checkout State/County Field Not Suitable for all Customers

No, that's not what I meant at all.  I meant to just do that for the fields in there that currently end with 'stateprov'.  You're basically setting just those fields up so that instead of using the global select field coding for presentation, they'll use a custom include that you have control over.  From that point, you can use JS in your include to do whatever you like based on choices made elsewhere in the form, specifically with any *country fields.


Nick Hendler

Offline

 

#5 12-10-2015 03:02:33

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Re: Checkout State/County Field Not Suitable for all Customers

Doh, I really did misunderstand your meaning. Can I assume that by"'fieldinclude' column" you meant the 'custominclude' column?


Simon

Offline

 

#6 12-10-2015 08:28:09

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Checkout State/County Field Not Suitable for all Customers

Yes.  I apologize for not being clear here.  I want to see you succeed with this.  The fieldinclude column.  Use a value like 'ecom:myinclude.php' and then save your file to /private/apps/ecom/ECOM/includes/myinclude.php.  Start out by making myinclude.php with the same content as /private/core/CORE/includes/formfield_select.php.  That's your starting point.


Nick Hendler

Offline

 

#7 12-11-2015 06:42:11

sdn
Member
From: UK
Registered: 05-29-2007
Posts: 882

Re: Checkout State/County Field Not Suitable for all Customers

No problem - my bad really.

I have made a copy of formfield_select.php called formfield_stateprov.php in /private/core/CORE/includes/

For testing purposes / damage limitation, I will add "core:formfield_stateprov.php" via Raw Database Admin to custominclude field of only core.accountmaint.stateprov.

Not written any Java before so could do with some (read as "a lot of") help on that part...

Last edited by sdn (12-11-2015 06:43:12)


Simon

Offline

 

#8 12-11-2015 07:49:26

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Checkout State/County Field Not Suitable for all Customers

On thinking about this a bit more, you will want your controls in the country field, as that's the selection that will alter the stateprov field.  Sorry about that.  Change up a bit and do the same thing you just did with the country field, and back out your stateprov changes.

You're off to a good start otherwise.  Here are a few more tips.  When doing JS in CCP, we use jQuery specifically.  You can see at the bottom of your include how an auto-update is handled via JS.  Basically the jQuery code is written and then appended to the core.js_docready global array:

Code:

$js_docready  = 'jQuery(\'#some-id\').change(function(){';
$js_docready .= 'some js code here';
$js_docready .= '});';
$this->append_global_array('core.js_docready',$js_docready);

Nick Hendler

Offline

 

Board footer