Forums / General Questions / Registration only in local area only.

Registration only in local area only.

Results 1 to 6 of 6
24 Jan 2015, 16:37
#1
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Posts:
1,674
Plugin Contributions:
0

Registration only in local area only.

At this time I am only want customer that is in my local area. How can I set up when customers can register only in my area/town? Until further notice.

Thanks
24 Jan 2015, 17:55
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: Registration only in local area only.

How will you determine if the customer is "local"? Using their postcode and/or city?
24 Jan 2015, 18:21
#3
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Posts:
1,674
Plugin Contributions:
0

Re: Registration only in local area only.

Yes, that is what I want to do. But right now. I just want to sell my items only in my local area for right now.
24 Jan 2015, 18:39
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: Registration only in local area only.

Since you're using Zen Cart v1.5.4, you can start by going to your admin's Tools->Install SQL Patches and run this script which will disable all countries except the USA:
UPDATE countries SET status = 0 WHERE countries_id != 223;

That will disallow accounts from being created and purchases being made for countries other than the United States.
25 Jan 2015, 03:39
#5
wmorris avatar

wmorris

Totally Zenned

Join Date:
Aug 2007
Posts:
1,674
Plugin Contributions:
0

Re: Registration only in local area only.

Yes, I know that part. I will be doing is in Texas and my Town is Amarillo and Canyon. So what is the best way to do this?
25 Jan 2015, 13:26
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Posts:
13,980
Plugin Contributions:
46

Re: Registration only in local area only.

You'll need to make a template-override version of the create_account.php module. If you don't already have the file /includes/modules/YOUR_TEMPLATE/create_account.php, copy /includes/modules/create_account.php to /includes/modules/YOUR_TEMPLATE/create_account.php.

Look for this section (towards the middle of the file) and add the code in red to check for the state being Texas and the city being either Amarillo or Canyon:
  if ( !($zone_name == 'Texas' && (strtolower ($city) == 'amarillo' || strtolower ($city) == 'canyon') ) ) {
    $error = true;
    $messageStack->add('create_account', "We're sorry, but we are only accepting accounts in Amarillo and Canyon at the moment.");
  }
  if ($error == true) {
    // hook notifier class
    $zco_notifier->notify('NOTIFY_FAILURE_DURING_CREATE_ACCOUNT');
  } elseif ($antiSpam != '') {
    $zco_notifier->notify('NOTIFY_SPAM_DETECTED_DURING_CREATE_ACCOUNT');
    $messageStack->add_session('header', (defined('ERROR_CREATE_ACCOUNT_SPAM_DETECTED') ? ERROR_CREATE_ACCOUNT_SPAM_DETECTED : 'Thank you, your account request has been submitted for review.'), 'success');
    zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
  } else {
    $sql_data_array = array('customers_firstname' => $firstname,
                            'customers_lastname' => $lastname,
                            'customers_email_address' => $email_address,
                            'customers_nick' => $nick,
                            'customers_telephone' => $telephone,
                            'customers_fax' => $fax,
                            'customers_newsletter' => (int)$newsletter,
                            'customers_email_format' => $email_format,
                            'customers_default_address_id' => 0,
                            'customers_password' => zen_encrypt_password($password),
                            'customers_authorization' => (int)CUSTOMERS_APPROVAL_AUTHORIZATION
    );