Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Handling fee for USPS International ONLY?

Handling fee for USPS International ONLY?

Locked

Views: 3,446

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
12 Nov 2010, 6:06 PM
#1
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Handling fee for USPS International ONLY?

Hello,
I'm tearing my hair out with the shipping modules. My cart version details and addons are in my signature. I have FREE SHIPPING! module installed as well as UPS and USPS both working.

  1. I need to add a $5 handling fee ONLY for international USPS shipping rates. This would be for all countries outside the US. I do not want a handling fee for US customers.

  2. I need to add a (Holiday) free shipping option for total orders of $100 or more in the US only.

  3. The only zone I see in the zone dropdowns for my modules is Florida which looks like a default.

  4. I guess I don't understand cloning. Can I clone the USPS shipping module?

Thanks

Salvatore

12 Nov 2010, 7:24 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Handling fee for USPS International ONLY?

To add a handling fee on just the International Orders in the USPS shipping module, you could customize:
/includes/modules/shipping/usps.php

and change the code from:

to read:

          $cost = preg_replace('/[^0-9.]/', '',  $cost);
          $cost = preg_replace('/[^0-9.]/', '',  $cost);
          if ($order->delivery['country_id'] != STORE_COUNTRY) {
            $extra_handling_int = 7000.00;
          }

Then add the $extra_handling_int to the cost of the quote:

          $methods[] = array('id' => $type,
                             'title' => $title,
                             'cost' => ($cost * $shipping_num_boxes) + $extra_handling_int + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );

Just set the amount:

            $extra_handling_int = 7000.00;

to your handling fee for international ...

For the Holiday Free Shipping Option ... build a Zone Definition for the US Only and add to the Zone Definition Details either all or part of the US to be used ...

Install the Free Shipping Options freeoptions shipping module and set the Total >= 100.00 and the Zone to the new Zone Definition that you built ...

After the Holidays, remove the Free Shipping Options freeoptions shipping module ...

As to Zones, the reason you only see a Zone Definition for Florida is that is what came, by default, with Zen Cart ... you need to create your own Zone Definitions and then add the Details to the Zone Definition that you create ...

You should not have to clone the USPS shipping module ... but you should save a clean copy and your customized copy for future upgrades ...

18 Nov 2010, 10:27 PM
#3
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Handling fee for USPS International ONLY?

Ajeh:

To add a handling fee on just the International Orders in the USPS shipping module, you could customize:
/includes/modules/shipping/usps.php

and change the code from:

to read:

      $cost = preg_replace('/[^0-9.]/', '',  $cost);
> 
> ```
          $cost = preg_replace('/[^0-9.]/', '',  $cost);
          if ($order->delivery['country_id'] != STORE_COUNTRY) {
            $extra_handling_int = 7000.00;
          }

Then add the $extra_handling_int to the cost of the quote:

      $methods[] = array('id' => $type,
                         'title' => $title,
                         'cost' => ($cost * $shipping_num_boxes) + $extra_handling_int + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
> 
> Just set the amount:
> ```
            $extra_handling_int = 7000.00;

to your handling fee for international ...

For the Holiday Free Shipping Option ... build a Zone Definition for the US Only and add to the Zone Definition Details either all or part of the US to be used ...

Install the Free Shipping Options freeoptions shipping module and set the Total >= 100.00 and the Zone to the new Zone Definition that you built ...

After the Holidays, remove the Free Shipping Options freeoptions shipping module ...

As to Zones, the reason you only see a Zone Definition for Florida is that is what came, by default, with Zen Cart ... you need to create your own Zone Definitions and then add the Details to the Zone Definition that you create ...

You should not have to clone the USPS shipping module ... but you should save a clean copy and your customized copy for future upgrades ...

          $cost = preg_replace('/[^0-9.]/', '',  $cost);
          if ($order->delivery['country_id'] != STORE_COUNTRY) {
            $extra_handling_int = 7000.00;
          }

If I plan on adding this fee to the entire world outside the contiguous US what would the 'country id' be or am I reading this wrong? How am I telling it to select USPS Priority International only?
I just want to make sure I understand exactly what I am doing here before I make the changes.
Thanks Linda

18 Nov 2010, 11:01 PM
#4
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Handling fee for USPS International ONLY?

mafiasam:

      $cost = preg_replace('/[^0-9.]/', '',  $cost);
      if ($order->delivery['country_id'] != STORE_COUNTRY) {
        $extra_handling_int = 7000.00;
      }
> 
> If I plan on adding this fee to the entire world outside the contiguous US what would the 'country id' be or am I reading this wrong? How am I telling it to select USPS Priority International only?
> I just want to make sure I understand exactly what I am doing here before I make the changes.
> 
> Thanks Linda

Linda

I see the list of 'country id's. Will I need to add all those ids? And do I add each one separated by a comma? With or without the quotes ('CF','TD','CL','CN')?

What about the US Territories? Are those considered international for Priority purposes?

Thanks

Salvatore
19 Nov 2010, 12:01 AM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Handling fee for USPS International ONLY?

The Country for USPS uses the actual country_id so if the customer has United States as their Country, then their Zone is part of the United States ...

But when you limit the Country, as in the contiguous US, then you need to make allowances for what is not your idea of the US ...

To do this, build a Zone for who does NOT get the extra charge ...

Then find the line:

        $methods = array();

Change that to read (new code in red:

// bof: check for extra charge when not in defined zone 21
      global $db;
      $skip_charge_more_flag = false;
      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . 21 . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
      while (!$check->EOF) {
        if ($check->fields['zone_id'] < 1) {
          $skip_charge_more_flag = true;
          break;
        } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
          $skip_charge_more_flag = true;
          break;
        }
        $check->MoveNext();
      }

      if ($skip_charge_more_flag == false) {
        $extra_handling_int = 7000;
      } else {
        $extra_handling_int = 0.00;
      }
// eof: check for extra charge when not in defined zone 21

        $methods = array();
20 Nov 2010, 1:12 PM
#6
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Handling fee for USPS International ONLY?

I can't seem to get the zones working for me.
I'll add a zone for the US and it just won't show up in the freeoptions module dropdowns. The Zone Rates shows up on the shopping cart shipping quotes with a message that says it's not available at this time (or something like that) but it also shows a $0.00 amount. It's pre-selected and it looks like customer could choose it for free shipping at all times.
I don't know why zones won't work.

However, the initial issue I had with adding a handling fee to International Priority was solved. Your code worked beautifully. I couldn't add a zone so I couldn't configure it for a contiguous states solution but it works fine for now. I'll deal with AK and HI orders as they come along.

Thanks Linda. Any help on the zones would be appreciated. I'm stumped.

20 Nov 2010, 4:15 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: Handling fee for USPS International ONLY?

What is the Zone ID that you have defined for the contiguous US ...

21 Nov 2010, 6:26 PM
#8
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Handling fee for USPS International ONLY?

Ajeh:

What is the Zone ID that you have defined for the contiguous US ...

Well, that's one of my problems. I don't see where I would enter an ID for the zone that I build. And there's nowhere to enter the specific states only countries.
And I've read the faq/tutorials but they don't seem to correlate with the settings under the zone rates. This has really got me confused.

21 Nov 2010, 9:52 PM
#9
ajeh avatar

ajeh

Oba-san

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

Re: Handling fee for USPS International ONLY?

In the code I posted you will see this line:

      $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . [B]21[/B] . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");

where 21 is the Zone Definition used ...

If you go to the Locations / Taxes ... Zones Definitions ... and click on EDIT on the Zone Definition for your Zone Definition of the US Contiguous States ... what is the zID in the URL?

If you have not built a Zone Definition for the US Contiguous States you need to do this first, so it can be used for this customization to work ...

23 Nov 2010, 9:07 AM
#11
mafiasam avatar

mafiasam

Zen Follower

Join Date:
Jan 2006
Location:
Portland, Oregon
Posts:
256
Plugin Contributions:
0

Re: Handling fee for USPS International ONLY?

This is where the confusion came in. Whenever I looked up zones for shipping I was always directed to the shipping module not the zones and zone definitions options under "locations/taxes".
I kept trying to figure out what the hell I was missing. The directions for zones in the faq is very vague if not altogether missing.
I'll look over this with a fresh outlook now that someone has pointed me in the right direction. Thanks Linda.

7 Dec 2010, 3:15 AM
#12
crawlina avatar

crawlina

New Zenner

Join Date:
Aug 2007
Posts:
23
Plugin Contributions:
0

Re: Handling fee for USPS International ONLY?

Dear Linda,

This above posting is similar to what I would like to do. I would like to add a handling fee either percentage or dollar amount to international orders (particularly Canada). I see I can add a handling fee for UPS that effects US and all other countries. I just want the fee to be for Canada and leave all others alone. Any help would be appreciated.http://www.zen-cart.com/forum/images/smilies/big_grin.gif

7 Dec 2010, 2:06 PM
#13
ajeh avatar

ajeh

Oba-san

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

Re: Handling fee for USPS International ONLY?

In the quote of the shipping module that you need it for, you can use:

// bof: add additional charge for zone_id 23
          global $db;
          $extra_charge = 0.00;
          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . 23 . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
          while (!$check->EOF) {
            if ($check->fields['zone_id'] < 1) {
              $check_flag = true;
              break;
            } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
              $check_flag = true;
              break;
            }
            $check->MoveNext();
          }
          if ($check_flag) {
            $extra_charge = 7000.00;
          }
          // add $extra_charge to cost below
// eof: add additional charge for zone_id 23

Then find where the cost is build and add in the $extra_charge to that ... this will only add the charge if the shipping address matches Zone Definition you built where 23 is the Zone definition built for who gets the extra charge ...