Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Only allow certain shipping methods for some countries?

Only allow certain shipping methods for some countries?

Views: 4,288

Results 1 to 9 of 9
6 Sep 2013, 11:45 AM
#1
doooomed avatar

doooomed

Zen Follower

Join Date:
Jun 2009
Posts:
275
Plugin Contributions:
0

Only allow certain shipping methods for some countries?

Hello,

I am hoping there is a way to offer certain shipping methods to specific countries using the USPS mod. I would like it so some countries with questionable Postal Service would be blocked from using First Class International mail. So, for example Germany would be allowed to choose whatever shipping method they wish but the Russian Federation would only be allowed to choose Priority Mail or higher. I'm assuming this can be done using zone rates but I'm not sure where to begin. A point in the right direction would be great! Thank you!

6 Sep 2013, 2:10 PM
#2
responsivezc avatar

responsivezc

New Zenner

Join Date:
Aug 2013
Posts:
85
Plugin Contributions:
8

Re: Only allow certain shipping methods for some countries?

Hi,

Go to Admin >> Location/Taxes >> Zones Definitions
Add a new Zone there
Then, click on the folder icon next to the zone name you recently added
and start adding countries to the zone.

These are the countries that will be allowed to use the shipping module.
Then, go to Admin >> Modules >> Shipping
Select your Shipping Module and click Edit
Set the Zone you recently added as Shipping Zone for the module and click Update

6 Sep 2013, 3:39 PM
#3
doooomed avatar

doooomed

Zen Follower

Join Date:
Jun 2009
Posts:
275
Plugin Contributions:
0

Re: Only allow certain shipping methods for some countries?

Hi,

Thanks for the help but I don't want to block these countries, I want it so they are not allowed to choose First Class International for shipping, only Priority International or higher...maybe I'm missing something...

6 Sep 2013, 3:42 PM
#4
doooomed avatar

doooomed

Zen Follower

Join Date:
Jun 2009
Posts:
275
Plugin Contributions:
0

Re: Only allow certain shipping methods for some countries?

Hi,

Thanks for the help but I don't want to block these countries, I want it so they are not allowed to choose First Class International for shipping, only Priority International or higher...maybe I'm missing something...

9 Sep 2013, 2:50 PM
#5
doooomed avatar

doooomed

Zen Follower

Join Date:
Jun 2009
Posts:
275
Plugin Contributions:
0

Re: Only allow certain shipping methods for some countries?

Thought I'd give this a bump

Anyone have any ideas?

Thanks!

21 Sep 2013, 3:12 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Only allow certain shipping methods for some countries?

In the shipping module:
/includes/modules/shipping/usps.php

Let's say you want to skip First-Class on Russia (RU) and Czech Republic (CS) ... you can customize the code around line 545 with:

if ($this->usps_countries == 'US' && MODULE_SHIPPING_USPS_FIRST_CLASS_FILTER_US == 'True' && preg_match('#First-Class#i', $type) && $cnt_first > 1) continue;

**
// bof: skip First Class based on Country
$skip_first_class = false;
if ($this->usps_countries == 'CZ' || $this->usps_countries == 'RU') {
$skip_first_class = true;
}
if (preg_match('#First-Class.*(?!GXG|International)#i', $type) && $skip_first_class) {
// skip first class
} else {
$methods[] = array('id' => $type_rebuilt,
'title' => $title,
'cost' => $cost,
);
}
// eof: skip First Class based on Country
** } else {
//echo 'MISSING! USPS $type: ' . $type . (in_array($type, $this->typeCheckboxesSelected) ? ' YES' : ' NO') . ' $method: ' . $method . ' $usps_shipping_weight: ' . $usps_shipping_weight . ' $minweight: ' . $minweight . ' $maxweight: ' . $maxweight . '<br>';
}
} // end for $i to $PackageSize

  if (sizeof($methods) == 0) return false;
30 Sep 2013, 7:47 PM
#7
doooomed avatar

doooomed

Zen Follower

Join Date:
Jun 2009
Posts:
275
Plugin Contributions:
0

Re: Only allow certain shipping methods for some countries?

Hey Ajeh!

Sorry for the delay but I hadn't checked the thread in a while.

Works perfect! :jump: Thank you!!!

Now for adding more countries, do I add that whole code each time or is there a way to add multiple countries to this?

// bof: skip First Class based on Country
$skip_first_class = false;
if ($this->usps_countries == 'CZ' || $this->usps_countries == 'RU') { <---- Can I add more countries here?
$skip_first_class = true;
}
if (preg_match('#First-Class.*(?!GXG|International)#i', $type) && $skip_first_class) {
// skip first class
} else {
$methods[] = array('id' => $type_rebuilt,
'title' => $title,
'cost' => $cost,
);
}
// eof: skip First Class based on Country

30 Sep 2013, 8:05 PM
#8
doooomed avatar

doooomed

Zen Follower

Join Date:
Jun 2009
Posts:
275
Plugin Contributions:
0

Re: Only allow certain shipping methods for some countries?

Oops! Disregard the last post, I need to start paying closer attention as you answered my question in your first post. Works perfect... Thank you!

30 Sep 2013, 11:30 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Only allow certain shipping methods for some countries?

Thanks for the update that this worked for you and glad you caught on to the how to do extras part ... :cool: