Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / PHP error with the zone shipping module

PHP error with the zone shipping module

Views: 3,932

Results 1 to 20 of 42
15 Sep 2012, 3:05 AM
#1
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

PHP error with the zone shipping module

I only get this error when the zone shipping module is active.

Invalid argument supplied for foreach() in /home4/mysite/public_html/shop/includes/modules/pages/checkout_shipping/header_php.php on line 241

I have been over the settings and I cannot figure out what the issue is. I even uninstalled and re-installed the Zones module hoping that would "right" things.. But no dice.. Hoping another set of eyes will help here..

Zone Shipping settings..

Enable Zones Method
True

Calculation Method
Weight

Tax Class
--none--

Tax Basis
Shipping

Sort Order
0

Skip Countries, use a comma separated list of the two character ISO country codes
US

Zone 1 Countries
00

Zone 1 Shipping Table
100:40.00

Zone 1 Handling Fee
0

Handling Per Order or Per Box Zone 1 (when by weight)
Order

Zone 2 Countries

Zone 2 Shipping Table
3:8.50,7:10.50,99:20.00

Zone 2 Handling Fee
0

Handling Per Order or Per Box Zone 2 (when by weight)
Order

Zone 3 Countries

Zone 3 Shipping Table
3:8.50,7:10.50,99:20.00

Zone 3 Handling Fee
0

Handling Per Order or Per Box Zone 3 (when by weight)
Order

15 Sep 2012, 3:46 AM
#2
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

What happens if you set that module to false on the enable ... does the error still happen?

If so, what happens if you uninstall the Zone Rate zones all together and go to the checkout_shipping?

15 Sep 2012, 3:51 AM
#3
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: PHP error with the zone shipping module

Ajeh:

What happens if you set that module to false on the enable ... does the error still happen?
No error on the shipping page of the checkout..

Ajeh:

If so, what happens if you uninstall the Zone Rate zones all together and go to the checkout_shipping?
No error on the shipping page of the checkout..

It's maddening!! :frusty:

15 Sep 2012, 12:42 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

Are any other shipping modules not uninstalled, as in a red icon, other than Zone Rate zones?

15 Sep 2012, 1:34 PM
#5
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: PHP error with the zone shipping module

Ajeh:

Are any other shipping modules not uninstalled, as in a red icon, other than Zone Rate zones?
These were all set to false (not uninstalled):

  • Flat Rate
  • Store Pickup
  • UPS
  • Table Rate
    So I just uninstalled them all.

The only shipping options installed and set to True now are:

  • USPS (green icon)
  • Zones (green icon)
  • Free Shipping Options (yellow icon)

In the names of "just seeing what would happen", I uninstalled and re-installed them all.. Interestingly Free Shipping Options has a yellow icon. I think it's because it has an active Shipping Zone.

However, I still get the error when landing on the shipping page of the checkout..

15 Sep 2012, 2:15 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

I cannot repeat it ...

Try this ...

Set the First Zone to CA (canada)

Set the Second Zone to 00 with the same settings as the first Zone ...

Does this change anything?

15 Sep 2012, 3:27 PM
#7
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: PHP error with the zone shipping module

Ajeh:

I cannot repeat it ...

Try this ...

Set the First Zone to CA (canada)

Set the Second Zone to 00 with the same settings as the first Zone ...

Does this change anything?
I've done some more experimenting since my last post.. I believe the issue lies in this setting: Skip Countries, use a comma separated list of the two character ISO country codes

Using the Zone shipping settings I posted, Zones shipping is not displayed when the shipping address is a US address, and it is displayed when the shipping address is outside the US. (this is correct)

I removed the value from: Skip Countries, use a comma separated list of the two character ISO country codes, and left all the other values I originally posted. Here's the result:
The error log stops appearing, but the Zones shipping now shows for everyone (not what I want).

I tried changing the setting Skip Countries, use a comma separated list of the two character ISO country codes to US and the **Zone 1 Countries **with every ISO country code except the US. Here's the result:
When the shipping address outside the US, the Zones shipping stops working. The message "No shipping available to the selected country" appears on the shipping page of the check out, but there is no error log. Using these same settings, when the shipping address is a US address, the Zones shipping does not appear (as expected) but the error log is generated.

I tried removed the values in Skip Countries, use a comma separated list of the two character ISO country codes and updated the **Zone 1 Countries **with every ISO country code except the US. Here's the result:
When the shipping address is outside the US, the Zones shipping displays the following message "No shipping available to the selected country" on the shipping page of the check out (NOT what I want), but there is no error log. Using these same settings, when the shipping address is in the US, the Zones shipping displays the following message "No shipping available to the selected country" on the shipping page of the check out (NOT what I want), but there is no error log.

15 Sep 2012, 3:40 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

When do you want to see Zone Rate zones?

15 Sep 2012, 4:02 PM
#9
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: PHP error with the zone shipping module

Ajeh:

When do you want to see Zone Rate zones?
When the shipping address is NOT a US shipping address.. This is what the second set of settings posted below is supposed to do and it works except it generates an error log

Been doing some more playing with the Zone Shipping settings..

Using the following settings, the Zones Shipping appears when the shipping address is outside the US, but I get an error log -- same one. When the shipping address is inside the US, the Zones Shipping shows "No shipping available to the selected country" (not what I want.. would prefer this shipping module not show at all), but there is no error log.

Enable Zones Method
True

Calculation Method
Weight

Tax Class
--none--

Tax Basis
Shipping

Sort Order
10

Skip Countries, use a comma separated list of the two character ISO country codes

Zone 1 Countries
AT,AU,BE,BM,BR,BS,CA,CH,CY,DE,DK,ES,FI,FR,GB,GG,GL,GR,HK,IE,IM,IS,IT,JE,JP,LI,LU,MC,ME,MX,NL,NO,NZ,PL,PT,SE,SG,TW

Zone 1 Shipping Table
100:40.00

Zone 1 Handling Fee
0

Handling Per Order or Per Box Zone 1 (when by weight)
Order

Zone 2 Countries

Zone 2 Shipping Table
3:8.50,7:10.50,99:20.00

Zone 2 Handling Fee
0

Handling Per Order or Per Box Zone 2 (when by weight)
Order

Zone 3 Countries

Zone 3 Shipping Table
3:8.50,7:10.50,99:20.00

Zone 3 Handling Fee
0

Handling Per Order or Per Box Zone 3 (when by weight)
Order

Using the following settings, the Zones Shipping appears when the shipping address is outside the US, but I get an error log -- same one. When the shipping address is inside the US, the Zones Shipping does not display, but I get an error log -- same one.

Enable Zones Method
True

Calculation Method
Weight

Tax Class
--none--

Tax Basis
Shipping

Sort Order
10

Skip Countries, use a comma separated list of the two character ISO country codes
US

Zone 1 Countries
AT,AU,BE,BM,BR,BS,CA,CH,CY,DE,DK,ES,FI,FR,GB,GG,GL,GR,HK,IE,IM,IS,IT,JE,JP,LI,LU,MC,ME,MX,NL,NO,NZ,PL,PT,SE,SG,TW

Zone 1 Shipping Table
100:40.00

Zone 1 Handling Fee
0

Handling Per Order or Per Box Zone 1 (when by weight)
Order

Zone 2 Countries

Zone 2 Shipping Table
3:8.50,7:10.50,99:20.00

Zone 2 Handling Fee
0

Handling Per Order or Per Box Zone 2 (when by weight)
Order

Zone 3 Countries

Zone 3 Shipping Table
3:8.50,7:10.50,99:20.00

Zone 3 Handling Fee
0

Handling Per Order or Per Box Zone 3 (when by weight)
Order

15 Sep 2012, 4:30 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

What is the weight of the order?

What is the Ship To?

What are your settings in the Configuration ... Shipping/Packaging ...

15 Sep 2012, 4:57 PM
#11
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: PHP error with the zone shipping module

Ajeh:

What is the weight of the order?

What is the Ship To?

What are your settings in the Configuration ... Shipping/Packaging ...

Order Weight:
1.16lb

Non-US Ship To:
234 Wellington Street
Ottawa, K1A 0G9
ON, Canada

US Ship To:
2129 Ellis Ave
Los Angeles, CA 90001

Shipping/Packaging settings:

Country of Origin United States
Postal Code 94965
Enter the Maximum Package Weight you will ship 35
Package Tare Small to Medium - added percentage:weight 10:.5
Larger packages - added packaging percentage:weight 10:5
Display Number of Boxes and Weight Status 3
Order Free Shipping 0 Weight Status 0
Shipping Estimator Display Settings for Shopping Cart 2
Display Order Comments on Admin Invoice 1
Display Order Comments on Admin Packing Slip 1
15 Sep 2012, 5:58 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

NOTE with this setting:
Enter the Maximum Package Weight you will ship

you will never get beyond 35lbs per box and it will be broken into multiple packages ...

NOTE: you use USPS so do not set that higher than 70 ...

Good new: I can repeat this issue now ... :smile:

Bad news: I do not yet have a solution ... :lookaroun

Let me see what I can do ...

15 Sep 2012, 6:07 PM
#13
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: PHP error with the zone shipping module

Ajeh:

NOTE with this setting:
Enter the Maximum Package Weight you will ship

you will never get beyond 35lbs per box and it will be broken into multiple packages ...

NOTE: you use USPS so do not set that higher than 70 ...Got it.. :smile:

Ajeh:

Good new: I can repeat this issue now ... :smile:

Bad news: I do not yet have a solution ... :lookaroun

Let me see what I can do ...
Linda you are the best!!!

15 Sep 2012, 6:30 PM
#14
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

What is on your file:
/includes/modules/pages/header_php.php

lines 230 to 250 in the file, on the server, as your line numbers do not match mine ...

15 Sep 2012, 6:57 PM
#15
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: PHP error with the zone shipping module

Ajeh:

What is on your file:
/includes/modules/pages/header_php.php

lines 230 to 250 in the file, on the server, as your line numbers do not match mine ...

There are other mods from the Gift wrapping, COWOA, and SBA mod so the lines numbers won't line up with the default.. I think this is the code you are looking for..

// get all available shipping quotes
  $quotes = $shipping_modules->quote();

  // check that the currently selected shipping method is still valid (in case a zone restriction has disabled it, etc)
  if (isset($_SESSION['shipping']) && $_SESSION['shipping'] != FALSE && $_SESSION['shipping'] != '') {
    $checklist = array();
    foreach ($quotes as $key=>$val) {
      foreach($val['methods'] as $key2=>$method) {
        $checklist[] = $val['id'] . '_' . $method['id'];
      }
    }
    $checkval = (is_array($_SESSION['shipping']) ? $_SESSION['shipping']['id'] : $_SESSION['shipping']);
    if (!in_array($checkval, $checklist)) {
      $messageStack->add('checkout_shipping', ERROR_PLEASE_RESELECT_SHIPPING_METHOD, 'error');
    }
  }

// if no shipping method has been selected, automatically select the cheapest method.
// if the modules status was changed when none were available, to save on implementing
// a javascript force-selection method, also automatically select the cheapest shipping
// method if more than one module is now enabled
  if ( !$_SESSION['shipping'] || ( $_SESSION['shipping'] && ($_SESSION['shipping'] == false) && (zen_count_shipping_modules() > 1) ) ) $_SESSION['shipping'] = $shipping_modules->cheapest();
8 Nov 2013, 2:33 PM
#16
izar74 avatar

izar74

Zen Follower

Join Date:
Mar 2009
Location:
Italy
Posts:
155
Plugin Contributions:
0

Re: PHP error with the zone shipping module

Hi, sorry to bring the dead out of the grave but I'm experiencing this exact problem.
Have you ever find out what is Itand how to fix it?

Thanks

9 Nov 2013, 1:40 AM
#17
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

Could you be more specific on what the problem is that you are having?

What are your settings in Configuration ... Shipping ...

What are your settings on the Shipping ... Zone Rates zones ...

9 Nov 2013, 3:02 PM
#18
izar74 avatar

izar74

Zen Follower

Join Date:
Mar 2009
Location:
Italy
Posts:
155
Plugin Contributions:
0

Re: PHP error with the zone shipping module

Sorry Linda,
I didn't wrote it because the problem as the settings are identical to Diva's. I configured it exactly as described to reproduce the error.
Anyway here the data:

Zencart 1.51
MySQL 5.5.24
PHP/5.4.3
I configured Shipping/Packaging settings as Diva whit the only difference tha the country is Italy.
The Zone shipping setting match Diva (for testing) and it turned out tha the error is generated in the same way i.e. if You put ANY ISO code in the field Skip Countries it would generate an error of :
Invalid argument supplied for foreach() in /.../.../includes/modules/pages/checkout_shipping/header_php.php on line 213

The code called is:

// check that the currently selected shipping method is still valid (in case a zone restriction has disabled it, etc)
  if (isset($_SESSION['shipping']) && $_SESSION['shipping'] != FALSE && $_SESSION['shipping'] != '') {
    $checklist = array();
    foreach ($quotes as $key=>$val) {
      foreach($val['methods'] as $key2=>$method) {
        $checklist[] = $val['id'] . '_' . $method['id'];
      }
    }

If You leave the field empty no error is generated (but the module will show in the checkout even if it's not selectable).

Now i'm trying to find out if possibly is a problem related to the php version.

10 Nov 2013, 2:51 AM
#19
ajeh avatar

ajeh

Oba-san

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

Re: PHP error with the zone shipping module

Humor me ...

Go to Modules ... Shipping ... and click on Zone Rate zones and copy and paste what you see in the right column in your next Post ...

What version of Zen Cart are you in?

Did you make any changes to the code regarding this issue?

10 Nov 2013, 5:28 AM
#20
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: PHP error with the zone shipping module

Ajeh:

Humor me ...

The Past, Present and future walk into a bar.
It was Tense.

:)