Post by jimmywb » Fri Jul 25, 2008 3:55 am

Is there a way to only accept orders from within the United States and display a message to everyone else to contact us?

Newbie

Posts

Joined
Tue Jan 15, 2008 11:41 pm

Post by Luvz2drv » Fri Jul 25, 2008 8:58 am

sure - setup your zones for payment and shipping
they will not be able to check out period

then in your cart/check logic toss a check in to make sure that the zone they are in by your pick of billing/shipping address check or both as to weather they can move forward

Jonathon

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by fido-x » Fri Jul 25, 2008 9:35 am

Since placing an order requires registration, a logical place to put this kind of thing would be in the account creation stage.

This can be done by adding the following to your "catalog/controller/account_create.php" file:-

Code: Select all

if ($request->get('country_id', 'post') != 223) {
	$this->error['country_id'] = $language->get('error_country');
}

before

Code: Select all

if (!$this->error) {
  return TRUE;
} else {
  return FALSE;
}
Then add the following to your "catalog/language/english/account_create.php" file:-

Code: Select all

$_['error_country'] = 'Since you are from outside the USA, you must place your order through the contact page. Apologies for any inconvenience this may cause.';
And then alter your "catalog/template/default/content/account_create.tpl" as follows:-
Find the section

Code: Select all

<td><select name="country_id" onchange="$('#zone').load('index.php?controller=account_create&action=zone&country_id='+this.value+'&zone_id=<?php echo $zone_id; ?>');">
  <?php foreach ($countries as $country) { ?>
  <?php if ($country['country_id'] == $country_id) { ?>
  <option value="<?php echo $country['country_id']; ?>" SELECTED><?php echo $country['name']; ?></option>
  <?php } else { ?>
  <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
  <?php } ?>
  <?php } ?>
  </select></td>
and change the last line to read:-

Code: Select all

</select><?php if ($error_country) { ?><span class="error"><?php echo $error_country; ?></span><?php } ?></td>
If your customer is not from the USA, this would then display an error message under the entry for "Country".

Regards, Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by jimmywb » Tue Jul 29, 2008 1:17 am

Excellent!  Thanks for the replies!

Newbie

Posts

Joined
Tue Jan 15, 2008 11:41 pm

Post by Luvz2drv » Tue Jul 29, 2008 10:00 pm

yes that works

but if smarty customers get in with fake USA address

you will also want a check on your billing/shipping in the check out as a failsafe

Jonathon

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by fido-x » Thu Jul 31, 2008 7:25 pm

Good point. But unless the fake address belongs to someone that they know, how would they get anything shipped to them?

Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Geek » Fri Aug 22, 2008 9:00 am

fido-x wrote: This can be done by adding the following to your "catalog/controller/account_create.php" file:-

Code: Select all

if ($request->get('country_id', 'post') != 223) {
	$this->error['country_id'] = $language->get('error_country');
}

before

Code: Select all

if (!$this->error) {
  return TRUE;
} else {
  return FALSE;
}
This might sound like a stupid question or even a really simple one. But, if I wanted to include more than one country, would I do either

Code: Select all

if ($request->get('country_id', 'post') != 38 or 223 ) {
	$this->error['country_id'] = $language->get('error_country');
}
or

Code: Select all

if ($request->get('country_id', 'post') != 38 || 223) {
	$this->error['country_id'] = $language->get('error_country');
}
or

Code: Select all

if ($request->get('country_id', 'post') != 38 xor 223) {
	$this->error['country_id'] = $language->get('error_country');
}
Just trying to find out which is the best and/or proper way of doing this.

~Simplygeek.net


New member

Posts

Joined
Sat May 17, 2008 1:00 pm
Location - Cyberspace, the final frontier...

Post by Qphoria » Fri Aug 22, 2008 9:04 am

Couldn't you just delete all countries from the db except for the ones you want. Then the drop down would limit u

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by fido-x » Fri Aug 22, 2008 9:08 am

Hi TekRaj,

You could do it using the "if" method as you suggested, the correct code would be-

Code: Select all

if ($request->get('country_id') != 38 || $request->get('country_id') != 223) {
  $this->error['country_id'] = $language->get('error_country');
}
Regards, Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Geek » Fri Aug 22, 2008 10:33 am

Qphoria wrote: Couldn't you just delete all countries from the db except for the ones you want. Then the drop down would limit u
Yes, but I plan to implement as many countries into my store as possible, once I work out the international shipping costs and everything.
That might be something that jimmywb might be wanting to do eventually as well. As long as they are all there, why delete them when if
you plan and idea is like what I would like to do or that you plan to eventually use them in some way.
fido-x wrote: Hi TekRaj,

You could do it using the "if" method as you suggested, the correct code would be-

Code: Select all

if ($request->get('country_id') != 38 || $request->get('country_id') != 223) {
  $this->error['country_id'] = $language->get('error_country');
}
Regards, Fido-X.
Thanks for the correction for me. I appreciate the help.

:)

~Simplygeek.net


New member

Posts

Joined
Sat May 17, 2008 1:00 pm
Location - Cyberspace, the final frontier...

Post by Qphoria » Fri Aug 22, 2008 10:44 am

Well the thread is titled "United states only" :P
Still, perhaps a way of disable/enable would be useful or something. Ah whatever works :)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Geek » Sat Aug 23, 2008 5:38 am

I implemented this 'hack' and everything seems fine. But I keep getting an error code on the
account creation page. The error that I receive is "
Notice: Undefined variable: error_country in .../catalog/template/default/content/account_create.tpl on line 87"
right under the country select box.

My code looks like this:

Code: Select all

          
          ');">
              
              
              " SELECTED>
              
              ">
              
              
            
Line 87->     
              
              

Code: Select all

    	if ($request->get('country_id') != 38 || $request->get('country_id') != 223) {
          $this->error['country_id'] = $language->get('error_country');
      }

Code: Select all

    	$_['error_country']        = 'Since you are from outside the USA, you must place your order through the contact page. Apologies for any inconvenience this may cause.';
The error does not go away when United States or Canada is selected. Any input would be appreciated.

~Simplygeek.net


New member

Posts

Joined
Sat May 17, 2008 1:00 pm
Location - Cyberspace, the final frontier...

Post by fido-x » Sat Aug 23, 2008 8:46 am

You could try changing your line 87 from

Code: Select all

<?php if ($error_country) { ?>
to

Code: Select all

<?php if (isset($error_country) { ?>
Regards, Fido-X.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Geek » Sat Aug 23, 2008 3:09 pm

fido-x wrote: You could try changing your line 87 from

Code: Select all

<?php if ($error_country) { ?>
to

Code: Select all

<?php if (isset($error_country) { ?>
Regards, Fido-X.
Well, that cleared up the undefined variable error, but the country error does not show if 38 or 223 is not selected.

Edit:
Problem solved.

In order to fix the error, you have to add:

Code: Select all

$view->set('error_city', @$this->error['city']);
after:

Code: Select all

$view->set('error_country', @$this->error['country']);
The problem was is that the variable, '$error_country' was not being viewed by the '../catalog/controller/account_create.php' file from the '../catalog/language/english/controller/account_create.php' file. Thanks Fido-X for telling me about 'isset', even though it didn't fix my problem, it lead to to understand why I was having the problem. Haha, I bet that you were just trying to lead me in the right direction instead of telling me the answer straight up. Thanks again.

Then you have to change your code further on down the page. So, instead of

Code: Select all

    	if ($request->get('country_id') != 38 || $request->get('country_id') != 223) {
          $this->error['country_id'] = $language->get('error_country');
      }
You need to replace it with:

Code: Select all

    	if ($request->get('country') != 38 || $request->get('country') != 223) {
          $this->error['country'] = $language->get('error_country');
      }
Now, I just have to get it to accept just the 38 and 223. Whenever I select Canada or United States and click the submit button, it stays on the page and leaves the error message up there.
Last edited by Anonymous on Sat Aug 23, 2008 5:06 pm, edited 1 time in total.

~Simplygeek.net


New member

Posts

Joined
Sat May 17, 2008 1:00 pm
Location - Cyberspace, the final frontier...
Who is online

Users browsing this forum: No registered users and 2 guests