Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 37
  1. #21
    Join Date
    Jan 2015
    Posts
    423
    Plugin Contributions
    0

    Default Re: Upgrade Question - Parameter must be an array or an object that implements Counta

    that seems to work. Thank you

  2. #22
    Join Date
    Jan 2015
    Posts
    423
    Plugin Contributions
    0

    Default FEC error: Parameter must be an array or an object that implements Countable

    Zecart 1.57
    Fast and easy checkout 2.4.2

    I am using fast and easy checkout. I getting a warning. Could someone helo me solve this


    HTML Code:
    [15-Jul-2020 11:09:04 America/New_York] Request URI: /index.php?main_page=checkout_payment, IP address: 174.105.121.130
    #1  FECObserver->update() called at [/home/inverter/public_html/includes/classes/class.base.php:118]
    #2  base->notify() called at [/home/inverter/public_html/includes/modules/pages/checkout_payment/header_php.php:124]
    #3  require(/home/inverter/public_html/includes/modules/pages/checkout_payment/header_php.php) called at [/home/inverter/public_html/index.php:35]
    --> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/xxx/public_html/includes/classes/observers/class.fec.php on line 51.

    This is the code
    Code:
    <?php
    
    //
    
    // +----------------------------------------------------------------------+
    
    // |zen-cart Open Source E-commerce                                       |
    
    // +----------------------------------------------------------------------+
    
    // | Copyright (c) 2007-2008 Numinix Technology http://www.numinix.com    |
    
    // |                                                                      |
    
    // | Portions Copyright (c) 2003-2006 Zen Cart Development Team           |
    
    // | http://www.zen-cart.com/index.php                                    |
    
    // |                                                                      |
    
    // | Portions Copyright (c) 2003 osCommerce                               |
    
    // +----------------------------------------------------------------------+
    
    // | This source file is subject to version 2.0 of the GPL license,       |
    
    // | that is bundled with this package in the file LICENSE, and is        |
    
    // | available through the world-wide-web at the following url:           |
    
    // | http://www.zen-cart.com/license/2_0.txt.                             |
    
    // | If you did not receive a copy of the zen-cart license and are unable |
    
    // | to obtain it through the world-wide-web, please send a note to       |
    
    // | [email protected] so we can mail you a copy immediately.          |
    
    // +----------------------------------------------------------------------+
    
    //  $Id: class.fec.php 109 2010-04-28 05:47:55Z numinix $
    
    //
    
    /**
    
     * Observer class used to redirect to the FEC page
    
     *
    
     */
    
    class FECObserver extends base 
    
    {
    
    	function __construct()
    
    	{
    
    		global $zco_notifier;
    
    		$zco_notifier->attach($this, array('NOTIFY_HEADER_START_CHECKOUT_SHIPPING'));
    
        $zco_notifier->attach($this, array('NOTIFY_HEADER_END_CHECKOUT_PAYMENT'));
    
    	}
    
    	
    
    	function update(&$class, $eventID, $paramsArray) {
    
        global $messageStack; 
    
        if (FEC_STATUS == 'true') {
    
          $error = false;
    
          if (($_GET['main_page'] == FILENAME_CHECKOUT_PAYMENT || $_GET['main_page'] == FILENAME_CHECKOUT_CONFIRMATION) and sizeof($messageStack->messages) > 0) {
    
            $error = true;
    
            for ($i=0, $n=sizeof($messageStack->messages); $i<$n; $i++) {
    
              if ($messageStack->messages[$i]['class'] == 'checkout_payment') {
    
                $checkout_payment_output[] = $messageStack->messages[$i];
    
              }
    
              if ($messageStack->messages[$i]['class'] == 'redemptions') {
    
                $redemptions_output[] = $messageStack->messages[$i];
    
              }
    
            }
    
            $messageStack->reset();
    
            if (sizeof($checkout_payment_output) > 0) {
    
              for ($i=0, $n=sizeof($checkout_payment_output); $i<$n; $i++) {
    
                $messageStack->add_session('checkout_payment', strip_tags($checkout_payment_output[$i]['text']), 'error');
    
              }
    
            }
    
            if (sizeof($redemptions_output) > 0) {
    
              for ($i=0, $n=sizeof($redemptions_output); $i<$n; $i++) {
    
                $messageStack->add_session('redemptions', strip_tags($redemptions_output[$i]['text']), 'caution');
    
              }
    
            }
    
          }  
    
          if ($_GET['credit_class_error']) {
    
            $error = true;
    
            $messageStack->add_session('checkout_payment', htmlspecialchars(urldecode($_GET['credit_class_error'])), 'error');
    
          }
    
          if ($error) {
    
            zen_redirect(zen_href_link(FILENAME_CHECKOUT, "fecaction=null", 'SSL'));
    
          } else {
    
            zen_redirect(zen_href_link(FILENAME_CHECKOUT, '', 'SSL'));
    
          }
    
        }
    
    	}
    
    }
    
    // eof

  3. #23
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,668
    Plugin Contributions
    11

    Default Re: Parameter must be an array or an object that implements Countable

    PHP Code:
    // this starts at line 50.  you need to change 51 and 56.
            
    $messageStack->reset();
            if (
    is_array($checkout_payment_output) && sizeof($checkout_payment_output) > 0) {
              for (
    $i=0$n=sizeof($checkout_payment_output); $i<$n$i++) {
                
    $messageStack->add_session('checkout_payment'strip_tags($checkout_payment_output[$i]['text']), 'error');
              }
            }
            if (
    is_array($redemptions_output) && sizeof($redemptions_output) > 0) {
              for (
    $i=0$n=sizeof($redemptions_output); $i<$n$i++) {
                
    $messageStack->add_session('redemptions'strip_tags($redemptions_output[$i]['text']), 'caution');
              }
            } 
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  4. #24
    Join Date
    Jan 2015
    Posts
    423
    Plugin Contributions
    0

    Default Re: Parameter must be an array or an object that implements Countable

    Quote Originally Posted by carlwhat View Post
    PHP Code:
    // this starts at line 50.  you need to change 51 and 56.
            
    $messageStack->reset();
            if (
    is_array($checkout_payment_output) && sizeof($checkout_payment_output) > 0) {
              for (
    $i=0$n=sizeof($checkout_payment_output); $i<$n$i++) {
                
    $messageStack->add_session('checkout_payment'strip_tags($checkout_payment_output[$i]['text']), 'error');
              }
            }
            if (
    is_array($redemptions_output) && sizeof($redemptions_output) > 0) {
              for (
    $i=0$n=sizeof($redemptions_output); $i<$n$i++) {
                
    $messageStack->add_session('redemptions'strip_tags($redemptions_output[$i]['text']), 'caution');
              }
            } 
    That seems to do the trick.

  5. #25
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,668
    Plugin Contributions
    11

    Default Re: Parameter must be an array or an object that implements Countable

    Quote Originally Posted by chadlly2003 View Post
    That seems to do the trick.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  6. #26
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Parameter must be an array or an object that implements Countable

    Would recommend using
    !empty($checkout_payment_output)

    At least as the first part of that check. Reason is that if $checkout_payment_output is not defined or is set to null, then a notice is currently sent. If there is concern of it otherwise being set to a "truthy" value that is not countable nor an array, then the second check of is_array($checkout_payment_output) would be appropriate.
    Code:
     if (!empty($checkout_payment_output) && is_array($checkout_payment_output)) {
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #27
    Join Date
    Jan 2015
    Posts
    423
    Plugin Contributions
    0

    Default Parameter must be an array or an object that implements Countable in shopping cart

    zencart 1.57
    php 7.4

    I am getting an error on my shopping cart

    Error
    Code:
    PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/xxx/public_html/includes/classes/shopping_cart.php on line 1695.
    I believe this is the code that needs to be adjusted. If someone could assist me or lead me in the right direction that would be great.
    Code:
    for ($i=0, $n=sizeof($_POST['products_id']); $i<$n; $i++) {
          $adjust_max= 'false';
          if ($_POST['cart_quantity'][$i] == '') {
            $_POST['cart_quantity'][$i] = 0;
          }

    This would be the full line of code
    Code:
     $change_state = array();
        $this->flag_duplicate_quantity_msgs_set = array();
        $cart_delete = (isset($_POST['cart_delete']) && is_array($_POST['cart_delete'])) ? $_POST['cart_delete'] : array();
        for ($i=0, $n=sizeof($_POST['products_id']); $i<$n; $i++) {
          $adjust_max= 'false';
          if ($_POST['cart_quantity'][$i] == '') {
            $_POST['cart_quantity'][$i] = 0;
          }

  8. #28
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,622
    Plugin Contributions
    123

    Default Re: Parameter must be an array or an object that implements Countable in shopping car

    What sequence of actions do you need to do to produce this Warning message?
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  9. #29
    Join Date
    Jan 2015
    Posts
    423
    Plugin Contributions
    0

    Default Re: Parameter must be an array or an object that implements Countable in shopping car

    I found it in my log file. I am having a hard time reproducing the error. It does not happen often. Just once in awhile

  10. #30
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Parameter must be an array or an object that implements Countable in shopping car

    The function that code is located in is normally only run when someone updates the quantities in their shopping basket.
    The error you're reporting suggests that someone tried to update an empty cart ... ie: they submitted a form that has no products listed in the expected format.

    Things to check:
    - customizations in case custom code is not quite right
    - user agent or IP of the request, to determine if it's a legitimate user or a bot
    - addons in case other things are triggering this function besides the default stuff
    - alterations to main_cart_actions, or added extra_cart_actions
    .

    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.

 

 
Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Replies: 3
    Last Post: 24 Dec 2019, 08:16 AM
  2. Replies: 11
    Last Post: 21 Dec 2018, 09:06 PM
  3. Replies: 7
    Last Post: 16 Dec 2018, 04:00 PM

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