Announcement

Collapse
No announcement yet.

Display order of States/Provinces

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Display order of States/Provinces

    Forgive me if this has already been covered - tried searching and didn't come up with much.

    I'd like to have control over the display order of US states and Canadian provinces. The default is alphabetical, meaning states/provinces are mixed together.

    Ideally I'd like to list Canadian provinces first, since the majority of our business is in Canada - and then list American states after.

    I've done this manually on the checkout page, but of course it's not user friendly in the event that the customer signs in with their account as the state field will be unselected, and if they forgot to fill in information, it'll also revert to "select from below" given it's not a standard Miva variable.
    Dylan Buchfink
    The Mattress & Sleep Company
    http://www.tmasc.ca/

    #2
    Re: Display order of States/Provinces

    Hi Dylan -- I've written modules for this. You can drop me a line by email if you want to discuss that option.

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Re: Display order of States/Provinces

      There is also a way to do this with toolkit where it keeps the selected state value (You can use this same logic for countries)

      You essentially build your own array of the states and display them yourself. First we create a array using toolkit's sacreate function which takes a comma separated listed of each state (or province) code and name and will turn it into an array.

      Code:
      <mvt:item name="toolkit" param="sacreate|usStates|AL-Alabama, AK-Alaska, AZ-Arizona, AR-Arkansas, AA-Armed Forces Americas, AE-Armed Forces Europe, AP-Armed Forces Pacific, CA-California, CO-Colorado, CT-Connecticut, DE-Delaware, DC-District of Columbia, FL-Florida, GA-Georgia, HI-Hawaii, ID-Idaho, IL-Illinois, IN-Indiana, IA-Iowa, KS-Kansas, KY-Kentucky, LA-Louisiana, ME-Maine, MD-Maryland, MA-Massachusetts, MI-Michigan, MN-Minnesota, MS-Mississippi, MO-Missouri, MT-Montana, NE-Nebraska, NV-Nevada, NH-New Hampshire, NJ-New Jersey, NM-New Mexico, NY-New York, NC-North Carolina, ND-North Dakota, OH-Ohio, OK-Oklahoma, OR-Oregon, PA-Pennsylvania, PR-Puerto Rico, RI-Rhode Island, SC-South Carolina, SD-South Dakota, TN-Tennessee, TX-Texas, UT-Utah, VT-Vermont, VA-Virginia, WA-Washington, WV-West Virginia, WI-Wisconsin, WY-Wyoming|," />
      Then we split the array values by the dash to get the code and name as separate values

      Code:
      <select name="BillStateSelect" id="BillStateSelect">
          <option value="">Select State</option>
          <mvt:foreach iterator="usState" array="usStates">
              <mvt:item name="toolkit" param="gettoken|l.all_settings:usState,-,1|stateValue" />
              <mvt:item name="toolkit" param="gettoken|l.all_settings:usState,-,2|stateName" />
              <mvt:if expr="g.BillState EQ g.stateValue OR g.BillStateSelect EQ g.stateValue">
                  <option value="&mvt:global:stateValue;" selected>&mvt:global:stateName;</option>
              <mvt:else>
                  <option value="&mvt:global:stateValue;">&mvt:global:stateName;</option>
              </mvt:if>
          </mvt:foreach>
      </select>
      Because of the if statement above, it maintains the selection in case there is a validation error. Long term the ability to change the order of the states and countries will be built into Miva.
      Last edited by Brennan; 12-22-14, 08:45 AM.
      Brennan Heyde
      VP Product
      Miva, Inc.
      [email protected]
      https://www.miva.com

      Comment


        #4
        Re: Display order of States/Provinces

        Thank you Brennan and Kent. If I can't get this figured out with the toolkit method I will contact you Kent!
        Dylan Buchfink
        The Mattress & Sleep Company
        http://www.tmasc.ca/

        Comment

        Working...
        X