Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2008
    Location
    Osprey, Florida
    Posts
    151
    Plugin Contributions
    14

    Default Getting/Displaying the Customer's Country

    Is there a way to display the customer's country on the checkout success page. The ideal would be for something simple such as

    PHP Code:
    <?php echo CUSTOMER_COUNTRY_SOMETING;?>
    but I have found that to be a little much more difficult to do.

    To give an idea of what I'm doing. I'm trying to integrate a Survey/Rating script which as options have the customer's email, name and country.

    The email and name are easy to get...

    PHP Code:
        if($_SESSION['customer_id']) {
          
    $sql "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id
                  FROM " 
    TABLE_CUSTOMERS "
                  WHERE customers_id = :customersID"
    ;

          
    $sql $db->bindVars($sql':customersID'$_SESSION['customer_id'], 'integer');
          
    $check_customer $db->Execute($sql);
          
    $customer_email$check_customer->fields['customers_email_address'];
          
    $customer_name$check_customer->fields['customers_firstname'] . ' ' $check_customer->fields['customers_lastname'];
        } 
    Any idea how to get the country. The best I can do is get a country ID.

    Thanks

  2. #2
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Getting/Displaying the Customer's Country

    If you know the customer id you can do a query on the address book table to get the customers country

  3. #3
    Join Date
    Jun 2008
    Location
    Osprey, Florida
    Posts
    151
    Plugin Contributions
    14

    Default Re: Getting/Displaying the Customer's Country

    Hi, thanks. Can you give me an example? Or tell me a module that may have a code similar to what I'm looking for?

  4. #4
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Getting/Displaying the Customer's Country

    I have not tested it, but it should be something like this I think
    PHP Code:
    <?php
        
    if($_SESSION['customer_id']) {
          
    $sql "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id
                  FROM " 
    TABLE_CUSTOMERS "
                  WHERE customers_id = :customersID"
    ;

          
    $sql $db->bindVars($sql':customersID'$_SESSION['customer_id'], 'integer');
          
    $check_customer $db->Execute($sql);
          
    $customer_email$check_customer->fields['customers_email_address'];
          
    $customer_name$check_customer->fields['customers_firstname'] . ' ' $check_customer->fields['customers_lastname'];

          
    $CountryId $db->Execute("SELECT entry_country_id FROM address_book WHERE address_book_id = '" $check_customer->fields['customers_default_address_id'] . "' ");

          
    $Country $db->Execute("SELECT countries_name FROM countries WHERE countries_id = '" $CountryId->fields['entry_country_id'] . "'");
        }

      echo 
    $Country;

  5. #5
    Join Date
    Jun 2008
    Location
    Osprey, Florida
    Posts
    151
    Plugin Contributions
    14

    Default Re: Getting/Displaying the Customer's Country

    Thanks,

    I got it working with this:
    PHP Code:
            $country_query "SELECT entry_country_id FROM " TABLE_ADDRESS_BOOK " WHERE customers_id = :customersID";
            
    $country_query $db->bindVars($country_query':customersID'$_SESSION['customer_id'], 'integer');
            
    $check_customer $db->Execute($country_query);
            
    $customer_country$check_customer->fields['entry_country_id'];
            
    $country zen_get_country_name($customer_country); 

  6. #6
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Getting/Displaying the Customer's Country

    Quote Originally Posted by ultimate_zc View Post
    Thanks,

    I got it working with this:
    PHP Code:
            $country_query "SELECT entry_country_id FROM " TABLE_ADDRESS_BOOK " WHERE customers_id = :customersID";
            
    $country_query $db->bindVars($country_query':customersID'$_SESSION['customer_id'], 'integer');
            
    $check_customer $db->Execute($country_query);
            
    $customer_country$check_customer->fields['entry_country_id'];
            
    $country zen_get_country_name($customer_country); 
    What happens if the customer has multiple countries in his address book ?

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Getting/Displaying the Customer's Country

    When a customer logs in, the country id is set to:
    $_SESSION['customer_country_id']

    You could use that to look up the country name in the countries table ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  8. #8
    Join Date
    Jun 2008
    Location
    Osprey, Florida
    Posts
    151
    Plugin Contributions
    14

    Default Re: Getting/Displaying the Customer's Country

    Thanks to you both.

 

 

Similar Threads

  1. v151 NOT Displaying Country on Customer Address(es)
    By CyberGuyBL in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 30 Jul 2014, 03:51 PM
  2. Getting/Displaying the Customer's State
    By ultimate_zc in forum General Questions
    Replies: 15
    Last Post: 11 Feb 2014, 07:14 PM
  3. 10474 - The shipping country is not allowed by the buyer's country of residence
    By tmeister in forum PayPal Express Checkout support
    Replies: 4
    Last Post: 6 Mar 2013, 02:52 AM
  4. v151 How to get the customer country value from checkout_shipping page?
    By kapsolas in forum General Questions
    Replies: 7
    Last Post: 11 Jan 2013, 07:06 PM
  5. Customer Reviews - displaying the name
    By ginginca in forum General Questions
    Replies: 1
    Last Post: 18 Feb 2007, 11:52 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR