Jump to content

Admin State problem for Countries without States


Dirty Butter

Recommended Posts

We had an order from France that went through the order process correctly without forcing them to choose a "State". BUT when it was time to complete the order, the State blank changed to Red, and I had to put something there to proceed. If there are Provinces.Departmentes/States that should be in Zones for France - can someone tell me what codes need to be added to my Countries/zones setup? If not, how do I fix this?

Link to comment
Share on other sites

You said, "When it was time to complete the order, the State blank changed to Red, and I had to put something there to proceed."

Is this actually the admin Order Summary screen where, once the order has shipped, you change its status to Completed? If so, then this has no real connection to Shipping & Postage issues.

And, if an admin action, did you notice if both the Billing/Invoice and the Delivery State fields required an entry?

And which store (actually, which version of CC) are you bringing up this this observation?

Link to comment
Share on other sites

This was the 5.1.4 store. I haven't had an order from France to experiment with on the 5.1.5 store. In the Order Summary screen I had to put an X in the State box in order to Save the Delivery information. The Billing screen does NOT have the X I added to the Delivery screen - that is until I experimented just now and tried to Save the Billing info with the blank - now it's insisting on the State having an entry.

I had a similar issue previously with a different order from France where I was adding another item to their previously cancelled order manually. It would not let me move the changed order from Cancelled (I had cancelled it as it was unpaid) to Pending without putting something in the State box.

Link to comment
Share on other sites

Disclaimer: I am so not familiar with javascript. Luckily, jQuery makes understanding what is going on easier.

Disclaimer: I am so not familar with jQuery.

In the admin template file orders.index.php, at about line 212, find:


<select name="customer[country]" id="sum_country" class="textbox billing country-list required" rel="sum_state">





Add no-custom-zone to the existing line.



<select name="customer[country]" id="sum_country" class="textbox billing country-list no-custom-zone required" rel="sum_state">

Five lines down, find:

class="textbox billing state-list required"

and remove the word required.

There will be another pair of edits starting near line 249.

========= See Post #17 :rolly: -- EDIT: Ignore the rest of the instructions on this post. It actually causes problems. ==================

In the file /js/common.js, find at around line 253:

if ($(this).hasClass('no-custom-zone')) $(target).attr({'disabled': 'disabled'}).val($(this).attr('title'));

Add a new phrase to the end:

if ($(this).hasClass('no-custom-zone')) $(target).attr({'disabled': 'disabled'}).val($(this).attr('title')).addClass('option_template');

(I just noticed that the form processor does not properly handle a missing form element. More experiments needed.)

After these edits, I switched an existing order from USA to France. The State field disappeared. Switching back to USA, the State field re-appeared but lost it's original value -- as expected, and probably desired.

I wanted more than just disabling the field, even though disabling it means the value it holds will not be sent back to the form processor. (But that means the database record does not get updated completely -- need to find out why.) Even though disabled, the form still displayed the value given to it.

Generally, that is not a problem as the original value for the State field, paired with a Country field of France, should be blank or zero. If zero, the form would show a zero. I wanted to make sure anything to show was hidden. So I gave the field a CSS class of option_template (display:none;visibility:hidden;).

Link to comment
Share on other sites

Just so you know, although it does not seem to have caused any issues -

After making these edits - the State for international shipments that DO have a State now show on the Delivery and Billing screens of the Order Summary as the NUMBER ID of that state. The Overview page and Packing Slip DO have the correct word for the state written out. This is true for old International Orders as well as the most recent one I fulfilled after making the edits.

Link to comment
Share on other sites

Interesting.

For the State field to show a number, the field needs to be a textbox as opposed to a select type form element. That is, a select form element will show the friendly text associated with each option's value in the drop-down.

<input type="textbox" value="34" />

<select>

<option value="34">Hello!</option>

</select>

Do you see a drop-down or a text-entry field? And did you note this when you first reported your issue resolved?

I'll do some more experiments. But in the meantime, clear the cache and force your browser to reload the javascript and css files (differs by browser, usually CTRL-F5 or SHIFT while clicking on the reload icon).

Link to comment
Share on other sites

The drop down box shows up for the customer when THEY originally choose the State. But from the Admin screen for Delivery and Billing it was just an empty text-entry box that would not allow itself to be empty before you edited the files. After clearing all caches the number still shows for the Admin text-entry box. But it's still the word on the Overview screen.

But I'm just now noticing that there IS a drop down box on ALL the international order Delivery and Billing screens where the country should be showing. The drop-down is empty - no choices can be made. BUT the Overview screen still has the full address with country shown as it should be. This is true for all the international orders that are completed, not just the France orders.

Link to comment
Share on other sites

The Country drop-down selector on any admin screen should not have been affected. The Country drop-down selector and matching State (drop-down or empty) selector on any customer screen should not have been affected. The info on the Order Summary, Overview tab should not have been affected.

It's only the State field that should now be hidden if the Country field has no associated Zones, or a drop-down selector if it does.

So you are saying that the Country (USA, GB, France, etc) drop-down selector is empty as seen on your browser?

Please have your browser show you the HTML source of the admin's Order Summary, Billing tab screen. Find this:


<select name="customer[country]" ...

Following that, you should see a big block of options. If not, we need to explore why CubeCart is no longer showing the list.

Link to comment
Share on other sites

Ah... I think I see what I did wrong. Bear with me. I misunderstood your directions and kept the original line of code and added yours after each of the two edits. Once I fixed that the drop down box for country now shows on Admin Delivery and Billing as it should.

But the state is still a number in a text-edit box.

Link to comment
Share on other sites

Working on the theory that your browser still has not loaded the changed javascript file, load this directly into your browser:

www.your_store.com/js/common.js

Hopefully by doing so, the browser will replace the existing cached file with the version just fetched, and use it. Then the State field should disappear.

What browser are you using?

Link to comment
Share on other sites

I did as you suggested and loaded the new common.js directly. I use Chrome, as the latest version of FireFox makes all my FKeditor screens go blank. I've tried it in IE as well. Now, with the new common.js, both Chrome and IE will not load the France orders, although other international orders with states do load, so there's still something not quite right. The French orders just hang with the striped in process bar showing.

Link to comment
Share on other sites

Something is not right: Try the first part, but don't do anything to line 277.

===========================================

A throbber (yes, that's a highly technical term) that doesn't go away indicates the javascript failed to initialize due to a critical syntax error.

Let's review:

In the file /js/common.js, find at around line 253:

if ($(this).hasClass('no-custom-zone')) $(target).attr({'disabled': 'disabled'}).val($(this).attr('title'));

Hopefully you found this line. Note that the end of this line ends with these characters: a period, the letters attr, the letters title enclosed in apostrophes then enclosed in parentheses, another closing parenthesis, and finally a semi-colon.

We will be inserting some new characters after the second closing parenthesis, but before the final semi-colon.

Insert a period, the letters addClass, an opening parenthesis, an apostrophe, the letters option_template, another apostrophe, and a closing parenthesis. NOTE! There should still be the final semi-colon at the end of the line because we were inserting characters before that final semi-colon.

if ($(this).hasClass('no-custom-zone')) $(target).attr({'disabled': 'disabled'}).val($(this).attr('title')).addClass('option_template');

You may, if it is easier, simply copy the entire line above and paste over the existing line.

A thought just now came to me... Is there more than one of these lines in the file common.js that might be to our advantage to look for? It turns out there is, but since I had not edited that line, and the behavior was as I expected, I didn't go looking for another line.

====Changing this line throws a javascript exception, but I don't know why. It says addClass() is not a function. But I don't know why.=====

That other line is line 277. But that line has $(replacement) instead of $(target). So, insert the same as above, making sure the final semi-colon is still at the end of the line.

Link to comment
Share on other sites

OK let's see if I've kept all this straight. Sorry, but I'm not working with a full deck right now. Husband had emergency open heart surgery 2+ weeks ago and is in rehab right now. Been at the hospital until the last couple of days and very tired.

I took your edit off of the second instance in orders.index.php

I do have the common.js line just as you wrote it.

At this point I do have drop down boxes showing in Delivery and Billing for all addresses that have a state.

Still getting the throbber for the France ones.

So I added the last part to line 277 in common.js (is that what you meant for me to do?) and loaded it in my browser again, just in case, and cleared cache in Maintenance and browser.

Still getting the throbber for the France ones.

Link to comment
Share on other sites

Ok, try this:

Line 253:

if ($(this).hasClass('no-custom-zone')) $(target).addClass('option_template').attr({'disabled': 'disabled'}).val($(this).attr('title'));

Line 277:

if ($(this).hasClass('no-custom-zone')) $(replacement).addClass('option_template').attr('disabled', 'disabled').val($(this).attr('title'));

I learned that the order of the jQuery chaining of functions is important. The later parts of the chain sometimes 'belong' to the previous part of the chain.

So having addClass() at the end of the chain was the wrong place to put it.

Link to comment
Share on other sites

THAT DID IT!! Beautiful work, Bsmither!! Another piece of CC refined, thanks to you. I really appreciate all your efforts. Drop downs are now there for all orders with states and a blank text box for those without states in Billing and Delivery. And Saving the France Delivery or Billing does not cause the red box to appear any more. The Mantis site is back up at the moment, so hopefully you can share this with CC soon.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...