Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    27
    Plugin Contributions
    0

    Default Invalid argument supplied for foreach()

    zen 1.3.9g

    5.3.10 (Zend: 2.3.0)
    MySQL 5.1.61-0ubuntu0.10.04.1

    The error is

    PHP Warning: Invalid argument supplied for foreach()

    and point so "includes/classes/order.php on line 522"

    order.php contains no customization that I aware of.

    No sure what else to add or where to look for a problem.

    Would appreciate any feedback

    tia
    Last edited by rstar23; 1 Apr 2012 at 06:16 AM. Reason: added zen version
    -------------------------------------------------
    "He called you a cowboy. What are you?"
    "Just a humble bounty hunter, ma'am"

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Invalid argument supplied for foreach()

    Quote Originally Posted by rstar23 View Post

    No sure what else to add or where to look for a problem.
    Please provide
    1. A URL to the store.
    2. More information as to what we will need to do to replicate the problem.

    Cheers
    Rod

  3. #3
    Join Date
    Mar 2008
    Posts
    27
    Plugin Contributions
    0

    Default Re: Invalid argument supplied for foreach()

    The store url is legacyhomeschool.com

    Can't tell you how to replicate the error. It shows up sporadically. Will see a series of messages in the debug log spanning about an one hour period and then it stops for a few days.

    I have tried placing orders in just about every combination I could think of - with taxes, without taxes, etc. So far I have not been able to force the error.

    This is the code block from order.php. The php error points at line 522

    if (DISPLAY_PRICE_WITH_TAX == 'true') {
    // calculate the amount of tax "inc"luded in price (used if tax-in pricing is enabled)
    $tax_add = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
    } else {
    // calculate the amount of tax for this product (assuming tax is NOT included in the price)
    // $tax_add = zen_round(($products_tax / 100) * $shown_price, $currencies->currencies[$this->info['currency']]['decimal_places']);
    $tax_add = ($products_tax/100) * $shown_price;
    }
    $this->info['tax'] += $tax_add;

    //this is line 522 referenced in php error
    foreach ($taxRates as $taxDescription=>$taxRate)

    {
    $taxAdd = zen_calculate_tax($this->products[$index]['final_price']*$this->products[$index]['qty'], $taxRate)
    + zen_calculate_tax($this->products[$index]['onetime_charges'], $taxRate);
    if (isset($this->info['tax_groups'][$taxDescription]))
    {
    $this->info['tax_groups'][$taxDescription] += $taxAdd;
    } else
    {
    $this->info['tax_groups'][$taxDescription] = $taxAdd;
    }
    }


    Not sure what else I can tell you. Any help will be appreciated.
    -------------------------------------------------
    "He called you a cowboy. What are you?"
    "Just a humble bounty hunter, ma'am"

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Invalid argument supplied for foreach()

    Chances are the error is a result of the $taxRate variable being empty, or at least not being an array.
    And it's built on line 434 with a combination of several parameters including the customer's address info and corresponding zones as well as the product's tax class and other associated data.
    So, your problems are likely related to addons which affect tax calculations and/or zone calculations, and/or your zone definitions and associated tax classes and tax rates, as well as your store's settings for tax calculation, etc.

    If you could state exactly how to trigger the error message, then it would be a lot easier to tell you more specifically what might need fixing.
    Generally it seems like you've got some bad zone definitions and tax rates. Maybe you hacked out a bunch of countries and states/provinces and now your customers are choosing entries that have no corresponding country/region matching, and thus it's having trouble matching taxes properly. Or worse, maybe you've installed tax-related addons that aren't working properly.

    Please click Reply below and answer all the questions in the Posting Tips section on that page.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v151 Invalid argument supplied for foreach()
    By DML73 in forum General Questions
    Replies: 3
    Last Post: 31 Dec 2013, 04:47 AM
  2. Replies: 5
    Last Post: 29 Jun 2011, 04:16 AM
  3. Help receiving: Warning: Invalid argument supplied for foreach()
    By kateoeight in forum General Questions
    Replies: 9
    Last Post: 1 May 2007, 09:28 PM
  4. Warning: Invalid argument supplied for foreach
    By harlyman in forum General Questions
    Replies: 9
    Last Post: 23 Aug 2006, 11:39 AM
  5. Replies: 7
    Last Post: 31 Jul 2006, 04:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR