Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / International address: simple add on for shipping

International address: simple add on for shipping

Views: 3,668

Results 1 to 8 of 8
1 Jun 2009, 4:18 PM
#1
jami1955 avatar

jami1955

New Zenner

Join Date:
Feb 2008
Location:
Boulder, CO, Dec 2: India
Posts:
89
Plugin Contributions:
0

International address: simple add on for shipping

Hi
I'm looking for a simple way to make a dollar amount add on for international addresses. That means the script would need to detect an international address (the store is in the USA), and then add on a percentage of the normal shipping rate for that amount. I have the shipping on table rates at the moment. ZC v. 1.3.8

thanks
JSC, Boulder:mellow:

2 Jun 2009, 7:19 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: International address: simple add on for shipping

You could test if the:
$order->delivery['country']['id']

is 223 or not and if not, then add the additional amount to the cost ...

3 Jun 2009, 8:16 PM
#3
jami1955 avatar

jami1955

New Zenner

Join Date:
Feb 2008
Location:
Boulder, CO, Dec 2: India
Posts:
89
Plugin Contributions:
0

Re: International address: simple add on for shipping

That is excellent Ajeh,

so ... the US country code is 223. Then I test whether the country code is anything else other than that, if it is, I add the international surcharge. (I would want to exclude Canada from the surcharge.)

Also, I am one of those developers who implements Zencart without knowing how to write PHP (or very little of it). So I would need an add on, like a plugin or something. Your solution is exactly right, but I'll need something I can "install" rather than write myself.

BTW, what page would that mod go into, "tpl_checkout_shipping_default.php?"

thanks,
JSC :blush:

4 Jun 2009, 2:20 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: International address: simple add on for shipping

This would be editing the shipping module itself ...

Shipping modules are in the:
/includes/modules/shipping

directory and the changes need to be made to the file(s) that you are using ...

If you are not able to customize the code yourself, you might want to post to the Commercial Help Wanted ...

21 Jul 2009, 9:04 PM
#5
ryanc44 avatar

ryanc44

New Zenner

Join Date:
Jul 2009
Posts:
4
Plugin Contributions:
0

Re: International address: simple add on for shipping

I'm trying to figure this one out myself. I have some basic programming knowledge and I think I'm getting close. If I can get this working I'll post up my findings.

21 Jul 2009, 9:32 PM
#6
ryanc44 avatar

ryanc44

New Zenner

Join Date:
Jul 2009
Posts:
4
Plugin Contributions:
0

Re: International address: simple add on for shipping

Here's my very remedial solution. Open your shipping module file located in:

/includes/modules/shipping

In my case I'm using per weight unit shipping, so I'm editing the perweightunit.php file. You want to look for the quote function- in this file starts on line 93.

Lines 97-102 make the initial quote calculation. The best bet is to grab that calculation and wrap the answer in an if/else statement- where you're adding an additional amount to the "quote" if the country is not 223. I haven't quite figured out the proper syntax to do that, so I just wrapped all of line 97-102 into the "if" part of my if/else statement and duplicated those same lines a second time into the "else" part.

I used the conditional that Ajeh supplied andt set it to NOT equal 223 - the code inside that part of the conditional I added the "10" after the handling fee. The else code I left alone. I'm not sure if that makes sense, so here's my hack code:

if ($order->delivery['country']['id'] != 223) {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units) + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING + 10)));
}
else {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units) + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
}

Hope that helps...

4 May 2011, 6:28 PM
#7
tapper avatar

tapper

Zen Follower

Join Date:
Nov 2007
Location:
Upstate NY
Posts:
233
Plugin Contributions:
0

Re: International address: simple add on for shipping

Hi

I'm trying to add $50 to international orders and no matter what I try the first part of this conditional is used and never the part after the else.

I tried it as ['country']['id'] != 223 and ['country']['id'] = 223
I put the + 50 at the beginning and at the end (before the last )))

I added 100 to the first part and 50 to the second part. For every setting whatever happens in the first part of the statement is what takes effect, whether or not it's !=223 or =223. No matter what country.

Can someone tell me what's wrong with this block?

TIA

/* If is international order add $50 shipping surcharge */
if ($order->delivery['country']['id'] != 223) {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE . $show_box_weight,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
'cost' => 50 + $shipping + (MODULE_SHIPPING_TABLE_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_TABLE_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_TABLE_HANDLING) ) ));
}
else {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE . $show_box_weight,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
'cost' => $shipping + (MODULE_SHIPPING_TABLE_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_TABLE_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_TABLE_HANDLING)) ));

}
/* END If is international order add $50 shipping surcharge */

8 Jul 2011, 10:34 PM
#8
jessica721 avatar

jessica721

New Zenner

Join Date:
Jun 2011
Posts:
14
Plugin Contributions:
0

Re: International address: simple add on for shipping

ryanc44:

Here's my very remedial solution. Open your shipping module file located in:

/includes/modules/shipping

In my case I'm using per weight unit shipping, so I'm editing the perweightunit.php file. You want to look for the quote function- in this file starts on line 93.

Lines 97-102 make the initial quote calculation. The best bet is to grab that calculation and wrap the answer in an if/else statement- where you're adding an additional amount to the "quote" if the country is not 223. I haven't quite figured out the proper syntax to do that, so I just wrapped all of line 97-102 into the "if" part of my if/else statement and duplicated those same lines a second time into the "else" part.

I used the conditional that Ajeh supplied andt set it to NOT equal 223 - the code inside that part of the conditional I added the "10" after the handling fee. The else code I left alone. I'm not sure if that makes sense, so here's my hack code:

if ($order->delivery['country']['id'] != 223) {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units) + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING + 10)));
}
else {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units) + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
}

Hope that helps...

Did you remove any php from perweightunit.php to add this in, or do I just stick it in after the if statement at line 93, or do I replace the if statement above it and replace it with this?

Thanks for your help,
Jessica :smile: