Results 1 to 10 of 16

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,949
    Plugin Contributions
    96

    Default Re: City value of States

    When you look at a customer's record in the admin, does it show the "City" as empty?

    Perhaps you need a small change to the "create_account" page's processing, where you use the zone_id value to look up the associated "City" and just copy that value into the customer's "City" field.

  2. #2
    Join Date
    Aug 2010
    Location
    Israel
    Posts
    285
    Plugin Contributions
    0

    Default Re: City value of States

    Quote Originally Posted by lat9 View Post
    When you look at a customer's record in the admin, does it show the "City" as empty?

    Perhaps you need a small change to the "create_account" page's processing, where you use the zone_id value to look up the associated "City" and just copy that value into the customer's "City" field.
    Yes. The city is empty in the customer's record.

    Tried some changes in the "create account" without success. The city field in the customer's record still empty.
    Even tried city=state but I'm not a PHP expert...
    That's why I put in the beginning of this thread the "create_account" relevant code of the city and the state so you could advice
    what value should I put where...

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,949
    Plugin Contributions
    96

    Default Re: City value of States

    You should keep the changes you made to the tpl_modules_create_account.php (especially the renaming of the "State" field to "City").

    If you don't have a file named /includes/modules/responsive_sheffield_blue/create_account.php, create a template override by copying the like-named file from the /includes/modules directory into the responsive_sheffield_blue subdirectory.

    You'll need to edit that template-override file, looking for the following block (for zc1.5.5a, around line 200) that deals with the country/state values:
    Code:
      if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
        $error = true;
        $messageStack->add('create_account', ENTRY_CITY_ERROR);
      }
    
      if (ACCOUNT_STATE == 'true') {
        $check_query = "SELECT count(*) AS total
                        FROM " . TABLE_ZONES . "
                        WHERE zone_country_id = :zoneCountryID";
        $check_query = $db->bindVars($check_query, ':zoneCountryID', $country, 'integer');
        $check = $db->Execute($check_query);
        $entry_state_has_zones = ($check->fields['total'] > 0);
        if ($entry_state_has_zones == true) {
          $zone_query = "SELECT distinct zone_id, zone_name, zone_code
                         FROM " . TABLE_ZONES . "
                         WHERE zone_country_id = :zoneCountryID
                         AND " .
                         ((trim($state) != '' && $zone_id == 0) ? "(upper(zone_name) like ':zoneState%' OR upper(zone_code) like '%:zoneState%') OR " : "") .
                        "zone_id = :zoneID
                         ORDER BY zone_code ASC, zone_name";
    
          $zone_query = $db->bindVars($zone_query, ':zoneCountryID', $country, 'integer');
          $zone_query = $db->bindVars($zone_query, ':zoneState', strtoupper($state), 'noquotestring');
          $zone_query = $db->bindVars($zone_query, ':zoneID', $zone_id, 'integer');
          $zone = $db->Execute($zone_query);
    
          //look for an exact match on zone ISO code
          $found_exact_iso_match = ($zone->RecordCount() == 1);
          if ($zone->RecordCount() > 1) {
            while (!$zone->EOF && !$found_exact_iso_match) {
              if (strtoupper($zone->fields['zone_code']) == strtoupper($state) ) {
                $found_exact_iso_match = true;
                continue;
              }
              $zone->MoveNext();
            }
          }
    
          if ($found_exact_iso_match) {
            $zone_id = $zone->fields['zone_id'];
            $zone_name = $zone->fields['zone_name'];
          } else {
            $error = true;
            $error_state_input = true;
            $messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
          }
        } else {
          if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
            $error = true;
            $error_state_input = true;
            $messageStack->add('create_account', ENTRY_STATE_ERROR);
          }
        }
      }
    ... and make the highlighted changes, copying the matching zone's name into the city value.
    Code:
    /*-bof --- City will be copied from the matching state ---
      if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
        $error = true;
        $messageStack->add('create_account', ENTRY_CITY_ERROR);
      }
    -eof --- City will be copied from the matching state --- */
    
      if (ACCOUNT_STATE == 'true') {
        $check_query = "SELECT count(*) AS total
                        FROM " . TABLE_ZONES . "
                        WHERE zone_country_id = :zoneCountryID";
        $check_query = $db->bindVars($check_query, ':zoneCountryID', $country, 'integer');
        $check = $db->Execute($check_query);
        $entry_state_has_zones = ($check->fields['total'] > 0);
        if ($entry_state_has_zones == true) {
          $zone_query = "SELECT distinct zone_id, zone_name, zone_code
                         FROM " . TABLE_ZONES . "
                         WHERE zone_country_id = :zoneCountryID
                         AND " .
                         ((trim($state) != '' && $zone_id == 0) ? "(upper(zone_name) like ':zoneState%' OR upper(zone_code) like '%:zoneState%') OR " : "") .
                        "zone_id = :zoneID
                         ORDER BY zone_code ASC, zone_name";
    
          $zone_query = $db->bindVars($zone_query, ':zoneCountryID', $country, 'integer');
          $zone_query = $db->bindVars($zone_query, ':zoneState', strtoupper($state), 'noquotestring');
          $zone_query = $db->bindVars($zone_query, ':zoneID', $zone_id, 'integer');
          $zone = $db->Execute($zone_query);
    
          //look for an exact match on zone ISO code
          $found_exact_iso_match = ($zone->RecordCount() == 1);
          if ($zone->RecordCount() > 1) {
            while (!$zone->EOF && !$found_exact_iso_match) {
              if (strtoupper($zone->fields['zone_code']) == strtoupper($state) ) {
                $found_exact_iso_match = true;
                continue;
              }
              $zone->MoveNext();
            }
          }
    
          if ($found_exact_iso_match) {
            $zone_id = $zone->fields['zone_id'];
            $zone_name = $zone->fields['zone_name'];
            $city = $zone_name;  // Copy the city from the selected zone's name
          } else {
            $error = true;
            $error_state_input = true;
            $messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
          }
        } else {
          if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
            $error = true;
            $error_state_input = true;
            $messageStack->add('create_account', ENTRY_STATE_ERROR);
          }
        }
      }
    That should do it for the coding part (please note that I haven't tested this, so be sure to attempt the changes on a test site!). You'll also need to change the wording of the two (currently state-related) messages that I highlighted above.

    You'll also want to apply these changes to the address-gathering forms and processing for the checkout_payment_address, checkout_shipping_address and address_book_process page.

  4. #4
    Join Date
    Aug 2010
    Location
    Israel
    Posts
    285
    Plugin Contributions
    0

    Default Re: City value of States

    Thank you lat9 !
    First process for the account create looks good.
    I put the code $city = $zone_name and after a new customer create, I look in the admin and the customer record
    city apears good !
    Now, need to work on the other 3 address-payment related files.
    Hope no problems there....

  5. #5
    Join Date
    Aug 2010
    Location
    Israel
    Posts
    285
    Plugin Contributions
    0

    Default Re: City value of States

    Quote Originally Posted by lat9 View Post
    You'll also want to apply these changes to the address-gathering forms and processing for the checkout_payment_address, checkout_shipping_address and address_book_process page.
    @lat9
    regarding those 3 files that you mentioned, I thought that I need to put in them the code "$city = $zone_name"
    but they have mainly 'defines' in them.
    Did you mean to change the defines?

    On the other hand, there is checkout_new_address.php file and there I add the "$city = $zone_name".

    So...just want to be sure that "$city = $zone_name" was needed to be put in 2 files only.

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,949
    Plugin Contributions
    96

    Default Re: City value of States

    @gunni, for the checkout_payment_address and checkout_shipping_address pages' update you'll need to start with a template-override version of /includes/modules/checkout_new_address.php and apply the same changes as you did with the template-override of /includes/modules/create_account.php.

    That will provide the "city" recording for both pages and you'll need also to update your template-override version of tpl_checkout_payment_address_default.php and tpl_checkout_shipping_address_default.php like you did to tpl_modules_create_account.php.

    Then, for the address_book_process page you'll edit the core-file /includes/modules/pages/address_book_process/header_php.php like you did for /includes/modules/create_account.php and update your template-override version of tpl_address_book_process_default.php to make the template change.

    I think that should "do it"!

  7. #7
    Join Date
    Aug 2010
    Location
    Israel
    Posts
    285
    Plugin Contributions
    0

    Default Re: City value of States

    @lat9 Big thanks again but not all clear....

    Quote Originally Posted by lat9 View Post
    @gunni, for the checkout_payment_address and checkout_shipping_address pages' update you'll need to start with a template-override version of /includes/modules/checkout_new_address.php and apply the same changes as you did with the template-override of /includes/modules/create_account.php.

    That will provide the "city" recording for both pages
    This is clear (after 6 times or reading...:).

    Quote Originally Posted by lat9 View Post
    and you'll need also to update your template-override version of tpl_checkout_payment_address_default.php and tpl_checkout_shipping_address_default.php like you did to tpl_modules_create_account.php.
    I opened thoese two files and they do not have "city" nor "state" like I changed the tpl_modules_create_account.php file
    so what do I need to change in these files ? Not clear.


    Quote Originally Posted by lat9 View Post
    Then, for the address_book_process page you'll edit the core-file /includes/modules/pages/address_book_process/header_php.php like you did for /includes/modules/create_account.php
    Did it :)

    Quote Originally Posted by lat9 View Post
    and update your template-override version of tpl_address_book_process_default.php to make the template change.
    What to update ? Opened this file and do not understand what to update...where ? Or should I put this file in my template dir ?

    Thanks again...

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,949
    Plugin Contributions
    96

    Default Re: City value of States

    Quote Originally Posted by gunni View Post
    I opened thoese two files and they do not have "city" nor "state" like I changed the tpl_modules_create_account.php file
    so what do I need to change in these files ? Not clear.
    My bad; those two files (tpl_checkout_payment_address_default.php and tpl_checkout_shipping_address_default.php) both include /tpl_modules_checkout_new_address.php; it's that common file that you might need to update to change the "State" to "City" ... although, I'm thinking now that those values are in your primary language file (hebrew.php?).

    Quote Originally Posted by gunni View Post
    What to update ? Opened this file and do not understand what to update...where ? Or should I put this file in my template dir ?

    Thanks again...
    Dang it! That one, too. The form is displayed via tpl_modules_address_book_details.php

    For both the tpl_modules_address_book_details.php and tpl_modules_checkout_new_address.php, you'll need to copy the files from the /includes/templates/template_default/templates directory to /includes/templates/responsive_sheffield_blue/templates ... unless the file is already in that directory.

    In either case, you'll apply any edits like you previously made to tpl_modules_create_account.php.

 

 

Similar Threads

  1. Replies: 2
    Last Post: 24 Nov 2012, 02:48 AM
  2. Shipping by percentage of retail value vs sale or discounted value
    By giftsandwhatnot in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 8 Aug 2011, 05:16 PM
  3. Replies: 2
    Last Post: 10 Jan 2011, 01:18 AM
  4. Replies: 4
    Last Post: 14 Jan 2009, 11:45 AM
  5. Using Value GV-mod.. entering value doesn't work
    By pixelarcher in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 6 Oct 2008, 04:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg