United States Only
Posted: 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?
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Code: Select all
if ($request->get('country_id', 'post') != 223) {
$this->error['country_id'] = $language->get('error_country');
}
Code: Select all
if (!$this->error) {
return TRUE;
} else {
return FALSE;
}
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.';
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>
Code: Select all
</select><?php if ($error_country) { ?><span class="error"><?php echo $error_country; ?></span><?php } ?></td>
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 eitherfido-x wrote: This can be done by adding the following to your "catalog/controller/account_create.php" file:-beforeCode: Select all
if ($request->get('country_id', 'post') != 223) { $this->error['country_id'] = $language->get('error_country'); }
Code: Select all
if (!$this->error) { return TRUE; } else { return FALSE; }
Code: Select all
if ($request->get('country_id', 'post') != 38 or 223 ) {
$this->error['country_id'] = $language->get('error_country');
}
Code: Select all
if ($request->get('country_id', 'post') != 38 || 223) {
$this->error['country_id'] = $language->get('error_country');
}
Code: Select all
if ($request->get('country_id', 'post') != 38 xor 223) {
$this->error['country_id'] = $language->get('error_country');
}
Code: Select all
if ($request->get('country_id') != 38 || $request->get('country_id') != 223) {
$this->error['country_id'] = $language->get('error_country');
}
Yes, but I plan to implement as many countries into my store as possible, once I work out the international shipping costs and everything.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
Thanks for the correction for me. I appreciate the help.fido-x wrote: Hi TekRaj,
You could do it using the "if" method as you suggested, the correct code would be-Regards, Fido-X.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
');">
" 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.';
Code: Select all
<?php if ($error_country) { ?>
Code: Select all
<?php if (isset($error_country) { ?>
Well, that cleared up the undefined variable error, but the country error does not show if 38 or 223 is not selected.fido-x wrote: You could try changing your line 87 fromtoCode: Select all
<?php if ($error_country) { ?>
Regards, Fido-X.Code: Select all
<?php if (isset($error_country) { ?>
Code: Select all
$view->set('error_city', @$this->error['city']);
Code: Select all
$view->set('error_country', @$this->error['country']);
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
if ($request->get('country') != 38 || $request->get('country') != 223) {
$this->error['country'] = $language->get('error_country');
}