that seems to work. Thank you
that seems to work. Thank you
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
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');
}
}
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...
zencart 1.57
php 7.4
I am getting an error on my shopping cart
Error
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: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.
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; }
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.
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
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.
Bookmarks