Zen Cart Logo
Forums / Upgrading to 1.5.x / Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

Views: 2,715

Results 1 to 14 of 14
15 Mar 2021, 3:08 PM
#1
shrimp_gumbo_mmmhhh avatar

shrimp_gumbo_mmmhhh

Totally Zenned

Join Date:
Jun 2007
Location:
Texas, USA
Posts:
1,436
Plugin Contributions:
0

Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

v157c
backup_mysql_plugin_v1.5g
EasyPopulated4
Google reCaptcha v3.4
keep_cart_1.0
numinix_google_analytics_bada883
one_page_checkout-2.3.7
remember-me-2.0.1
sitemapxml
usu-3.0.8
zen_image_handler-5.1.10

I have upgraded and had keepcart in the database already. I put items in my cart come back after 12 hours .... they are gone! :( Has anyone else who has upgraded to 1.5.7c noticed this?

15 Mar 2021, 3:16 PM
#2
shrimp_gumbo_mmmhhh avatar

shrimp_gumbo_mmmhhh

Totally Zenned

Join Date:
Jun 2007
Location:
Texas, USA
Posts:
1,436
Plugin Contributions:
0

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

Okay..... Looking at the code I now remember that I was getting a PHP error every time the website was being hit and was drowning in log error messages. The message said something about a future error of a same named class calling a same name function. So I renamed function save_cart() to save_cart_now() in class.savecart.php and then in the config.savecart.php :

$autoLoadConfig[90][] = array('autoType'=>'classInstantiate','className'=>'save_cart','objectName'=>'save_cart');

Changed to:

$autoLoadConfig[90][] = array('autoType'=>'classInstantiate','className'=>'save_cart','objectName'=>'save_cart_now');

And the error messages stopped. Is there something else that I am missing to change the function name from the class name successfully? Thank you!

15 Mar 2021, 4:22 PM
#3
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,769
Plugin Contributions:
20

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

shrimp-gumbo-mmmhhh:

Okay..... Looking at the code I now remember that I was getting a PHP error every time the website was being hit and was drowning in log error messages. The message said something about a future error of a same named class calling a same name function. So I renamed function save_cart() to save_cart_now() in class.savecart.php and then in the config.savecart.php :

$autoLoadConfig[90][] = array('autoType'=>'classInstantiate','className'=>'save_cart','objectName'=>'save_cart');

Changed to:

$autoLoadConfig[90][] = array('autoType'=>'classInstantiate','className'=>'save_cart','objectName'=>'save_cart_now');

And the error messages stopped. Is there something else that I am missing to change the function name from the class name successfully? Thank you!

I'm not at all familiar with the plugin you've mentioned here, but will just comment on the bold part...

This indicates a (very) old style code in the class file (in your case, class.savecart.php) which looks something like:

class saveCart {
    function saveCart() {

    }
}

and should be changed to

class saveCart {
    function __construct() {

    }
}

Changing what you've changed in the auto_loader will definitely stop the plugin from working.

15 Mar 2021, 5:19 PM
#4
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,954
Plugin Contributions:
8

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

balihr:

I'm not at all familiar with the plugin you've mentioned here, but will just comment on the bold part...

This indicates a (very) old style code in the class file (in your case, class.savecart.php) which looks something like:

class saveCart {
function saveCart() {

}

}

> and should be changed to 
> ```
class saveCart {
    function __construct() {

    }
}

Changing what you've changed in the auto_loader will definitely stop the plugin from working.

it looks like from here:

https://www.zen-cart.com/downloads.php?do=file&id=992

and the aforementioned changes by @balihr look correct and sound to me.

best.

15 Mar 2021, 7:37 PM
#5
shrimp_gumbo_mmmhhh avatar

shrimp_gumbo_mmmhhh

Totally Zenned

Join Date:
Jun 2007
Location:
Texas, USA
Posts:
1,436
Plugin Contributions:
0

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

Thanks much all!

15 Mar 2021, 9:55 PM
#6
shrimp_gumbo_mmmhhh avatar

shrimp_gumbo_mmmhhh

Totally Zenned

Join Date:
Jun 2007
Location:
Texas, USA
Posts:
1,436
Plugin Contributions:
0

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

It looks like somehow I wasn't using the latest and greatest Keep Cart..... the new version also goes to a keep_cart_1.0 directory though... thank you all for the help!

15 Mar 2021, 11:19 PM
#7
shrimp_gumbo_mmmhhh avatar

shrimp_gumbo_mmmhhh

Totally Zenned

Join Date:
Jun 2007
Location:
Texas, USA
Posts:
1,436
Plugin Contributions:
0

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

Anybody have ideas of what to replace the "each" with?

--> PHP Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/account/public_html/includes/classes/observers/class.savecart.php on line 46.

				reset($_SESSION['cart']->contents);
				while (list($products_id,) = **each**($_SESSION['cart']->contents))
				{
					$prid = zen_get_prid($products_id);
					$stock_query = "select products_quantity, products_status
									from " . TABLE_PRODUCTS . "
									where products_id = '" . (int)$prid . "'";


					$stock_info = $db->Execute($stock_query);
					if ($stock_info->EOF)
						unset($_SESSION['cart']->contents[$products_id]);
					else
					{
						$stock_qty = $stock_info->fields['products_quantity'];
						$stock_status = $stock_info->fields['products_status'];
						if (($stock_qty < 1) || ($stock_status == 0))
							unset($_SESSION['cart']->contents[$products_id]);
						else
						{
							if ($stock_qty < $_SESSION['cart']->contents[$products_id]['qty'])
							$_SESSION['cart']->contents[$products_id] = array('qty' => (float)$stock_qty);
						}
					}
				}
15 Mar 2021, 11:53 PM
#9
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,954
Plugin Contributions:
8

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

it looks like this would work:

//from:
while (list($products_id,) = each($_SESSION['cart']->contents))

//to:
foreach ($_SESSION['cart']->contents as $products_id => $details)

best.

16 Mar 2021, 12:59 AM
#10
shrimp_gumbo_mmmhhh avatar

shrimp_gumbo_mmmhhh

Totally Zenned

Join Date:
Jun 2007
Location:
Texas, USA
Posts:
1,436
Plugin Contributions:
0

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

Thank you all.... so far so good. Carl it looks like your fix was what was needed. Thank you!

17 Mar 2021, 7:54 PM
#11
shrimp_gumbo_mmmhhh avatar

shrimp_gumbo_mmmhhh

Totally Zenned

Join Date:
Jun 2007
Location:
Texas, USA
Posts:
1,436
Plugin Contributions:
0

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

KEEP CART does not have its own group so I am posting this here.... Error for php 8.0

PHP Fatal error: Uncaught Error: Undefined constant "KEEP_CART_ENABLED"

/home/account/public_html/includes/classes/observers/class.savecart.php:30

17 Mar 2021, 8:13 PM
#12
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,954
Plugin Contributions:
8

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

shrimp-gumbo-mmmhhh:

KEEP CART does not have its own group so I am posting this here.... Error for php 8.0

PHP Fatal error: Uncaught Error: Undefined constant "KEEP_CART_ENABLED"

/home/account/public_html/includes/classes/observers/class.savecart.php:30

are you you have the config values in the database? what happens if you run:

SELECT * FROM `configuration` WHERE `configuration_key` LIKE '%KEEP_CART%'

if you get 0 rows, you should run the keep_cart.sql.

best.

8 Jan 2022, 8:44 PM
#13
elemi avatar

elemi

Zen Follower

Join Date:
Mar 2006
Location:
Auckland, New Zealand
Posts:
242
Plugin Contributions:
0

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

I've just loaded it onto my 1.5.7c website and got this error log

[09-Jan-2022 08:51:38 Pacific/Auckland] PHP Fatal error: Uncaught Error: Class 'save_cart' not found in /home/amoraromatherapy/public_html/includes/autoload_func.php:44
Stack trace:
#0 /home/amoraromatherapy/public_html/includes/application_top.php(222): require()
#1 /home/amoraromatherapy/public_html/index.php(25): require('/home/amoraroma...')
#2 {main}
thrown in /home/amoraromatherapy/public_html/includes/autoload_func.php on line 44

What am I looking for to fix it?

9 Jan 2022, 12:52 PM
#14
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Upgrade to v157c Keep Cart does not appear to be working anyone else notice this?

Elemi:

I've just loaded it onto my 1.5.7c website and got this error log

[09-Jan-2022 08:51:38 Pacific/Auckland] PHP Fatal error: Uncaught Error: Class 'save_cart' not found in /home/amoraromatherapy/public_html/includes/autoload_func.php:44
Stack trace:
#0 /home/amoraromatherapy/public_html/includes/application_top.php(222): require()
#1 /home/amoraromatherapy/public_html/index.php(25): require('/home/amoraroma...')
#2 {main}
thrown in /home/amoraromatherapy/public_html/includes/autoload_func.php on line 44

What am I looking for to fix it?
If it is the current version of the plugin, then you're missing /includes/classes/observers/class.savecart.php.