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,934

Results 21 to 40 of 42
10 Nov 2013, 3:31 PM
#21
ajeh avatar

ajeh

Oba-san

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

PHP error with the zone shipping module

RodG:

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

:)

'tis the little things that brighten my day ... :P

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

11 Nov 2013, 10:18 AM
#22
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

izar74:

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

What is It not clear about Zen Cart version?

the Zone cunfiguration:

Abilita il Metodo delle Zone
True

Metodo di Calcolo
Weight

Classe IVA
-- nessuno --

Base di Tassa
Shipping

Ordine di Visualizzazione
0

Tralasciate i Paesi; usate una virgola per separare la lista dei due caratteri dei codici ISO delle Nazioni

Zona 1 Paesi
US,CA

Zona 1 Tabella di Spedizione
3:8.50,7:10.50,99:20.00

Zona 1 Costo di Packaging
0

Costo di Packaging Per Ordine o Per Pacco Zona 1 (se in base al peso)
Order

Zona 2 Paesi

Zona 2 Tabella di Spedizione
3:8.50,7:10.50,99:20.00

Zona 2 Costo di Packaging
0

Costo di Packaging Per Ordine o Per Pacco Zona 2 (se in base al peso)
Order

Zona 3 Paesi

Zona 3 Tabella di Spedizione
3:8.50,7:10.50,99:20.00

Zona 3 Costo di Packaging
0

Costo di Packaging Per Ordine o Per Pacco Zona 3 (se in base al peso)
Order

With the above configuration NO error is generated.

With this one:

Abilita il Metodo delle Zone
True

Metodo di Calcolo
Weight

Classe IVA
-- nessuno --

Base di Tassa
Shipping

Ordine di Visualizzazione
0

Tralasciate i Paesi; usate una virgola per separare la lista dei due caratteri dei codici ISO delle Nazioni
IT

Zona 1 Paesi
US,CA

Zona 1 Tabella di Spedizione
3:8.50,7:10.50,99:20.00

Zona 1 Costo di Packaging
0

Costo di Packaging Per Ordine o Per Pacco Zona 1 (se in base al peso)
Order

Zona 2 Paesi

Zona 2 Tabella di Spedizione
3:8.50,7:10.50,99:20.00

Zona 2 Costo di Packaging
0

Costo di Packaging Per Ordine o Per Pacco Zona 2 (se in base al peso)
Order

Zona 3 Paesi

Zona 3 Tabella di Spedizione
3:8.50,7:10.50,99:20.00

Zona 3 Costo di Packaging
0

Costo di Packaging Per Ordine o Per Pacco Zona 3 (se in base al peso)
Order

an error log is generated :

[11-Nov-2013 10:14:26 UTC] PHP Warning:  Invalid argument supplied for foreach() in C:\...\includes\modules\pages\checkout_shipping\header_php.php on line 213

The checkout process will go on just fine without any other error.

It doesn't Humor me...

11 Nov 2013, 5:40 PM
#23
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 go in your Zen Cart Admin to the Tools ... Developers Tool Kit ... and in the bottom input box enter:
zones.php

and select Catalog from the dropdown and click Search ...

What are the paths and lines that come up on this search?

What is your Ship To and Ship From and the weight being tested?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

11 Nov 2013, 5:43 PM
#24
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

izar74:

What is It not clear about Zen Cart version?

the Zone cunfiguration:

With the above configuration NO error is generated.

With this one:

an error log is generated :

[11-Nov-2013 10:14:26 UTC] PHP Warning: Invalid argument supplied for foreach() in C:...\includes\modules\pages\checkout_shipping\header_php.php on line 213

> 
> The checkout process will go on just fine without any other error.
> 
> **It doesn't Humor me...**
Ahhhhhhhhhhhhhhh... sarcasm.... yes I too find that this ALWAYS inspires people to help me when I ask for help..:no:

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

11 Nov 2013, 6:28 PM
#25
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

Ajeh:

Could you go in your Zen Cart Admin to the Tools ... Developers Tool Kit ... and in the bottom input box enter:
zones.php

and select Catalog from the dropdown and click Search ...

What are the paths and lines that come up on this search?

What is your Ship To and Ship From and the weight being tested?

From search:

C:/wamp/www/negozio152/includes/languages/english/modules/shipping/zones.php

Line #19 : // $Id: zones.php 1969 2005-09-13 06:57:21Z drbyte $

C:/wamp/www/negozio152/includes/languages/italian/modules/shipping/zones.php

Line #19 : // $Id: zones.php 1969 2005-09-13 06:57:21Z drbyte $

C:/wamp/www/negozio152/includes/modules/shipping/paccocelereinternazionale.php

Line #6 : * @version $Id: zones.php 6347 2007-05-20 19:46:59Z ajeh $

Line #18 : zones.php. A list of settings will appear to the right. Click on the

C:/wamp/www/negozio152/includes/modules/shipping/postepostaraccomandata.php

Line #6 : * @version $Id: zones.php 6347 2007-05-20 19:46:59Z ajeh $

Line #18 : zones.php. A list of settings will appear to the right. Click on the

C:/wamp/www/negozio152/includes/modules/shipping/postequickpackeurope.php

Line #6 : * @version $Id: zones.php 6347 2007-05-20 19:46:59Z ajeh $

Line #18 : zones.php. A list of settings will appear to the right. Click on the

C:/wamp/www/negozio152/includes/modules/shipping/zones.php

Line #6 : * @version $Id: zones.php 14498 2009-10-01 20:16:16Z ajeh $

Line #18 : zones.php. A list of settings will appear to the right. Click on the

The second question:

Ship to = Italy
Ship From Italy
Weight= 1
Error is generated

If I use an address outside Italy (simply selecting a different address in the adresses book):

Ship to= France
Ship From= Italy
Weight=1
Error is NOT generated

11 Nov 2013, 6:40 PM
#26
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

DivaVocals:

Ahhhhhhhhhhhhhhh... sarcasm.... yes I too find that this ALWAYS inspires people to help me when I ask for help..:no:

Heyyyy Diva!! Wasn't this a problem You had? Did you solved it?

I know i've already asked in my first post.. i apologize for the repeat but it seem Sarcasm took all your attention!!!

:yes:

11 Nov 2013, 7:04 PM
#27
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 shipping modules are actually installed in the Modules ... Shipping ... and not showing the red dot?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

11 Nov 2013, 7:49 PM
#28
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

Ajeh:

What shipping modules are actually installed in the Modules ... Shipping ... and not showing the red dot?

There are only 2 module installed and with green dot:

Zone Rates

Flat Rates

I've removed all the other modules.

Just to point it out, should it be just an error in the declaration of a variable? I've searched similar error and the only reference I've found is that when that error is generated an argument of foreach() is not an array (It's just a try)...

11 Nov 2013, 10:26 PM
#29
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

izar74:

Heyyyy Diva!! Wasn't this a problem You had? Did you solved it?Yes, and if I had/remembered the answer, I would have shared it..

izar74:

I know i've already asked in my first post.. i apologize for the repeat but it seem Sarcasm took all your attention!!!

:yes:Ummm.. well from where I was sitting Linda was/is helping you.. my point was that snarky sounding comments are generally not helpful around here when someone is helping.. Especially someone as nice as Linda.. IJS..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

11 Nov 2013, 10:59 PM
#30
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

If you are shipping from Italy and to Italy why would you want to ignore Italy on the shipping module?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

11 Nov 2013, 11:26 PM
#31
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

Do you have any checkout add ons?

Can you post the full contents of your file:
/includes/modules/pages/checkout_shipping/header_php.php

What version of Zen Cart is this again?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

12 Nov 2013, 12:17 AM
#32
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

Ajeh:

Do you have any checkout add ons?

Can you post the full contents of your file:
/includes/modules/pages/checkout_shipping/header_php.php

What version of Zen Cart is this again?

One thing at a time:

Sorry Linda I made a mistake in the previous reply...

The correct answer is:

Shipping From= Italy
Shipping to = US, EU (all the state of UE)
Weight = 1

What I meant is that if the customer has a registered address outside IT (tha is the country code in the "Skip Countries" field) the error doesn't appear.
The log error is written every time else, the only solution is to remove the IT code from the fied.

Question 2:
Yes I have few add on that modify checkout here the list:

  • Stock by attributes 1.5.1.2
  • Reward Point full 2.1b

The zen cart version is 1.51.
Note: even in a fresh new install i got the same error without any add-ons.

Here the /includes/modules/pages/checkout_shipping/header_php.php

<?php
/**
 * Checkout Shipping Page
 *
 * @package page
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: header_php.php 18697 2011-05-04 14:35:20Z wilt $
 * Updated for Stock by Attributes 1.5.1.2 by POTTERYHOUSE
 */
// This should be first line of the script:
  $zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SHIPPING');

  require_once(DIR_WS_CLASSES . 'http_client.php');

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($_SESSION['cart']->count_contents() <= 0) {
    zen_redirect(zen_href_link(FILENAME_TIME_OUT));
  }

// if the customer is not logged on, redirect them to the login page
  if (!isset($_SESSION['customer_id']) || !$_SESSION['customer_id']) {
    $_SESSION['navigation']->set_snapshot();
    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  } else {
    // validate customer
    if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
      $_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_SHIPPING));
      zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    }
  }

// Validate Cart for checkout
  $_SESSION['valid_to_checkout'] = true;
  $_SESSION['cart']->get_products(true);
  if ($_SESSION['valid_to_checkout'] == false) {
    $messageStack->add('header', ERROR_CART_UPDATE, 'error');
    zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
  }

// Stock Check
  if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
    $products = $_SESSION['cart']->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {

		// START "Stock by Attributes"
		// Added to allow individual stock of different attributes
	    unset($attributes);
	    if(is_array($products[$i]['attributes'])){
			$attributes = $products[$i]['attributes'];
	    } 
	    else{
		      $attributes = null;
	    }
	
		if(!empty($attributes)){
	    	if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'], $attributes)) {
	    		zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
	    		break;
	    	}
	    }
	    else{
      if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
        zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
        break;
      }
    }
  }
	// END "Stock by Attributes"
 }

// if no shipping destination address was selected, use the customers own address as default
  if (!$_SESSION['sendto']) {
    $_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
  } else {
// verify the selected shipping address
    $check_address_query = "SELECT count(*) AS total
                            FROM   " . TABLE_ADDRESS_BOOK . "
                            WHERE  customers_id = :customersID
                            AND    address_book_id = :addressBookID";

    $check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
    $check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['sendto'], 'integer');
    $check_address = $db->Execute($check_address_query);

    if ($check_address->fields['total'] != '1') {
      $_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
      $_SESSION['shipping'] = '';
    }
  }

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;

// register a random ID in the session to check throughout the checkout procedure
// against alterations in the shopping cart contents
if (isset($_SESSION['cart']->cartID)) {
  if (!isset($_SESSION['cartID']) || $_SESSION['cart']->cartID != $_SESSION['cartID']) {
    $_SESSION['cartID'] = $_SESSION['cart']->cartID;
  }
} else {
  zen_redirect(zen_href_link(FILENAME_TIME_OUT));
}

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
  if ($order->content_type == 'virtual') {
    $_SESSION['shipping'] = 'free_free';
    $_SESSION['shipping']['title'] = 'free_free';
    $_SESSION['sendto'] = false;
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  }

  $total_weight = $_SESSION['cart']->show_weight();
  $total_count = $_SESSION['cart']->count_contents();

// load all enabled shipping modules
  require(DIR_WS_CLASSES . 'shipping.php');
  $shipping_modules = new shipping;

  $pass = true;
  if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
    $pass = false;

    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
      case 'national':
        if ($order->delivery['country_id'] == STORE_COUNTRY) {
          $pass = true;
        }
        break;
      case 'international':
        if ($order->delivery['country_id'] != STORE_COUNTRY) {
          $pass = true;
        }
        break;
      case 'both':
        $pass = true;
        break;
    }

    $free_shipping = false;
    if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
      $free_shipping = true;
    }
  } else {
    $free_shipping = false;
  }

  require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

  if (isset($_SESSION['comments'])) {
    $comments = $_SESSION['comments'];
  }


// process the selected shipping method
  if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
    if (zen_not_null($_POST['comments'])) {
      $_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
    }
    $comments = $_SESSION['comments'];
    $quote = array();

    if ( (zen_count_shipping_modules() > 0) || ($free_shipping == true) ) {
      if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) {
        /**
         * check to be sure submitted data hasn't been tampered with
         */
        if ($_POST['shipping'] == 'free_free' && ($order->content_type != 'virtual' && !$pass)) {
          $quote['error'] = 'Invalid input. Please make another selection.';
        } else {
          $_SESSION['shipping'] = $_POST['shipping'];
        }

        list($module, $method) = explode('_', $_SESSION['shipping']);
        if ( is_object($$module) || ($_SESSION['shipping'] == 'free_free') ) {
          if ($_SESSION['shipping'] == 'free_free') {
            $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
            $quote[0]['methods'][0]['cost'] = '0';
          } else {
            $quote = $shipping_modules->quote($method, $module);
          }
          if (isset($quote['error'])) {
            $_SESSION['shipping'] = '';
          } else {
            if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
              $_SESSION['shipping'] = array('id' => $_SESSION['shipping'],
                                'title' => (($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                                'cost' => $quote[0]['methods'][0]['cost']);

              zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
            }
          }
        } else {
          $_SESSION['shipping'] = false;
        }
      }
    } else {
      $_SESSION['shipping'] = false;

      zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
    }
  }

// 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();


  // Should address-edit button be offered?
  $displayAddressEdit = (MAX_ADDRESS_BOOK_ENTRIES >= 2);

  // if shipping-edit button should be overridden, do so
  $editShippingButtonLink = zen_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL');
  if (isset($_SESSION['payment']) && method_exists($$_SESSION['payment'], 'alterShippingEditButton')) {
    $theLink = $$_SESSION['payment']->alterShippingEditButton();
    if ($theLink) {
      $editShippingButtonLink = $theLink;
      $displayAddressEdit = true;
    }
  }

  $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  $breadcrumb->add(NAVBAR_TITLE_2);

// This should be last line of the script:
  $zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_SHIPPING');
12 Nov 2013, 12:23 AM
#33
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

DivaVocals:

Yes, and if I had/remembered the answer, I would have shared it..

Ummm.. well from where I was sitting Linda was/is helping you.. my point was that snarky sounding comments are generally not helpful around here when someone is helping.. Especially someone as nice as Linda.. IJS..

You couldn't be more right and that go in both direction.
I probably get a little upsetted by a word that really meaned no harm but You know sometime when everything goes wrong just a little spark can rise a fire.

12 Nov 2013, 12:27 AM
#34
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

izar74:

You couldn't be more right and that go in both direction.
I probably get a little upsetted by a word that really meaned no harm but You know sometime when everything goes wrong just a little spark can rise a fire.

I do understand.. but as a piece of friendly advice.. temper tantrums directed to the community are generally not well received.. :no:That said solo temper tantrums are not an issue.. :laugh: I've had PLENTY of those..:laugh:

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

12 Nov 2013, 12:59 AM
#35
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

Go to your Zen Cart Admin and go to Locations / Taxes ... Countries ...

Find Italy ...

Click on it and look in the URL, what is the cID for that?

What are the other settings for the whole row?

Next, go to the Customers in the Admin, and EDIT the customer that you are using for this checkout ...

Is the Country setup right for Italy?

I am assuming that this is your test Customer account that you are testing things with and that you can login as that customer ...

Login as that Customer and go to the My Account and check the Addresses setup for it ...

Edit the one(s) for Italy and do an Update ...

So far, nothing I have done in testing here as triggered this error that you are getting ...

You have Zone Rates setup to Weight and have the Skip Countries set to:
IT

You have only the first Zone 1 defined as:
US, CA

and are not using any other Zones ...

The only other shipping module installed is Flat Rate flat and the Zone Rate zones is green dot and Flat Rate flat is green dot and ALL other shipping modules are red dots ... correct?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

12 Nov 2013, 12:06 PM
#36
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

Ajeh:

Go to your Zen Cart Admin and go to Locations / Taxes ... Countries ...

Find Italy ...

Click on it and look in the URL, what is the cID for that?

What are the other settings for the whole row?

url and cID = /countries.php?page=6&cID=105
Setting = ISO Code (2): IT ISO Code (3): ITA Address Format: 5

Next, go to the Customers in the Admin, and EDIT the customer that you are using for this checkout ...

Is the Country setup right for Italy?

I am assuming that this is your test Customer account that you are testing things with and that you can login as that customer ...

Login as that Customer and go to the My Account and check the Addresses setup for it ...

Edit the one(s) for Italy and do an Update ...

Yes is the account i use for testing, and i can login as customer.
Did as You say, edited the adresses and saved it (was already set with Italy as country)

Yet the error is generated.

So far, nothing I have done in testing here as triggered this error that you are getting ...

May I ask what version of PHP and MYSQL are You testing on?

You have Zone Rates setup to Weight and have the Skip Countries set to:
IT

You have only the first Zone 1 defined as:
US, CA

and are not using any other Zones ...

The only other shipping module installed is Flat Rate flat and the Zone Rate zones is green dot and Flat Rate flat is green dot and ALL other shipping modules are red dots ... correct?

All damned correct...
I've tryed this thing on a fresh new install, no mods or anything and the error is generated in the same way, the only thing i'm gonna try is using the very base Zencart 1.51 not the Italian version (localization made by https://www.zencartitalia.it).

12 Nov 2013, 12:20 PM
#37
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

Update: I've made a fresh new install with the english version 1.51, no add-on, installed with demo data. Removed all the shiping except Flat rate and Zone rates.
The error is still there, same as before:

Invalid argument supplied for foreach() in C:\wamp\www\negozio151eng\includes\modules\pages\checkout_shipping\header_php.php on line 191
<?php
/**
 * Checkout Shipping Page
 *
 * @package page
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: header_php.php 18697 2011-05-04 14:35:20Z wilt $
 */
// This should be first line of the script:
  $zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SHIPPING');

  require_once(DIR_WS_CLASSES . 'http_client.php');

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($_SESSION['cart']->count_contents() <= 0) {
    zen_redirect(zen_href_link(FILENAME_TIME_OUT));
  }

// if the customer is not logged on, redirect them to the login page
  if (!isset($_SESSION['customer_id']) || !$_SESSION['customer_id']) {
    $_SESSION['navigation']->set_snapshot();
    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  } else {
    // validate customer
    if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
      $_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_SHIPPING));
      zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    }
  }

// Validate Cart for checkout
  $_SESSION['valid_to_checkout'] = true;
  $_SESSION['cart']->get_products(true);
  if ($_SESSION['valid_to_checkout'] == false) {
    $messageStack->add('header', ERROR_CART_UPDATE, 'error');
    zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
  }

// Stock Check
  if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
    $products = $_SESSION['cart']->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      if (zen_check_stock($products[$i]['id'], $products[$i]['quantity'])) {
        zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
        break;
      }
    }
  }
// if no shipping destination address was selected, use the customers own address as default
  if (!$_SESSION['sendto']) {
    $_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
  } else {
// verify the selected shipping address
    $check_address_query = "SELECT count(*) AS total
                            FROM   " . TABLE_ADDRESS_BOOK . "
                            WHERE  customers_id = :customersID
                            AND    address_book_id = :addressBookID";

    $check_address_query = $db->bindVars($check_address_query, ':customersID', $_SESSION['customer_id'], 'integer');
    $check_address_query = $db->bindVars($check_address_query, ':addressBookID', $_SESSION['sendto'], 'integer');
    $check_address = $db->Execute($check_address_query);

    if ($check_address->fields['total'] != '1') {
      $_SESSION['sendto'] = $_SESSION['customer_default_address_id'];
      $_SESSION['shipping'] = '';
    }
  }

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;

// register a random ID in the session to check throughout the checkout procedure
// against alterations in the shopping cart contents
if (isset($_SESSION['cart']->cartID)) {
  if (!isset($_SESSION['cartID']) || $_SESSION['cart']->cartID != $_SESSION['cartID']) {
    $_SESSION['cartID'] = $_SESSION['cart']->cartID;
  }
} else {
  zen_redirect(zen_href_link(FILENAME_TIME_OUT));
}

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
  if ($order->content_type == 'virtual') {
    $_SESSION['shipping'] = 'free_free';
    $_SESSION['shipping']['title'] = 'free_free';
    $_SESSION['sendto'] = false;
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  }

  $total_weight = $_SESSION['cart']->show_weight();
  $total_count = $_SESSION['cart']->count_contents();

// load all enabled shipping modules
  require(DIR_WS_CLASSES . 'shipping.php');
  $shipping_modules = new shipping;

  $pass = true;
  if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
    $pass = false;

    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
      case 'national':
        if ($order->delivery['country_id'] == STORE_COUNTRY) {
          $pass = true;
        }
        break;
      case 'international':
        if ($order->delivery['country_id'] != STORE_COUNTRY) {
          $pass = true;
        }
        break;
      case 'both':
        $pass = true;
        break;
    }

    $free_shipping = false;
    if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
      $free_shipping = true;
    }
  } else {
    $free_shipping = false;
  }

  require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

  if (isset($_SESSION['comments'])) {
    $comments = $_SESSION['comments'];
  }


// process the selected shipping method
  if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
    if (zen_not_null($_POST['comments'])) {
      $_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
    }
    $comments = $_SESSION['comments'];
    $quote = array();

    if ( (zen_count_shipping_modules() > 0) || ($free_shipping == true) ) {
      if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) {
        /**
         * check to be sure submitted data hasn't been tampered with
         */
        if ($_POST['shipping'] == 'free_free' && ($order->content_type != 'virtual' && !$pass)) {
          $quote['error'] = 'Invalid input. Please make another selection.';
        } else {
          $_SESSION['shipping'] = $_POST['shipping'];
        }

        list($module, $method) = explode('_', $_SESSION['shipping']);
        if ( is_object($$module) || ($_SESSION['shipping'] == 'free_free') ) {
          if ($_SESSION['shipping'] == 'free_free') {
            $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
            $quote[0]['methods'][0]['cost'] = '0';
          } else {
            $quote = $shipping_modules->quote($method, $module);
          }
          if (isset($quote['error'])) {
            $_SESSION['shipping'] = '';
          } else {
            if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
              $_SESSION['shipping'] = array('id' => $_SESSION['shipping'],
                                'title' => (($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                                'cost' => $quote[0]['methods'][0]['cost']);

              zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
            }
          }
        } else {
          $_SESSION['shipping'] = false;
        }
      }
    } else {
      $_SESSION['shipping'] = false;

      zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
    }
  }

// 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();


  // Should address-edit button be offered?
  $displayAddressEdit = (MAX_ADDRESS_BOOK_ENTRIES >= 2);

  // if shipping-edit button should be overridden, do so
  $editShippingButtonLink = zen_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL');
  if (isset($_SESSION['payment']) && method_exists($$_SESSION['payment'], 'alterShippingEditButton')) {
    $theLink = $$_SESSION['payment']->alterShippingEditButton();
    if ($theLink) {
      $editShippingButtonLink = $theLink;
      $displayAddressEdit = true;
    }
  }

  $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  $breadcrumb->add(NAVBAR_TITLE_2);

// This should be last line of the script:
  $zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_SHIPPING');
12 Nov 2013, 6:40 PM
#38
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

I've put everything on a test server:

http://www.viaincenso.com/

http://www.viaincenso.com/admintest for admin.

Sent Linda the login info and ftp info if you want to have a look

12 Nov 2013, 6:55 PM
#39
izar74 avatar

izar74

Zen Follower

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

Re: PHP error with the zone shipping module

Update: the error still generate but if you go for checkout, and go streight to the end no error is generate (seem so at the moment, still investigating) but if for any reason you decide to change something and go back or restar the checkout process the error pop!

12 Nov 2013, 10:46 PM
#40
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 am assuming that while the error is generated in your debug logs ... that the checkout is still working ...

I have generated the error, finally, and come up with a fix for you ...

Edit the file:
/includes/modules/shipping/checkout_shipping/header_php.php

and add the code in RED:

  // 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) {
[B]      if ($val['methods'] != '') {
[/B]        foreach($val['methods'] as $key2=>$method) {
          $checklist[] = $val['id'] . '_' . $method['id'];
        }
[B]      } else {
        // skip
      }
[/B]    }
    $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.

See if this stops you from generating any more debug logs ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!