Continue Shopping Button

1.08.7 Fresh install - Continue Shopping 2.0 Error - Continue Shopping Button

1.08.7 Fresh install - Continue Shopping 2.0 Error

by justgovintage » Mon Nov 08, 2021 6:50 am

Hi,
I got the following error installing this today:

[08-Nov-2021 06:30:51 UTC] PHP Fatal error: Uncaught Error: Cannot use object of type Product as array in -root path-.com/includes/modules/content/shopping_cart/cm_sc_continue_shopping.php:39

Associated with this line:
$products = $_SESSION['cart']->get_products();

Are there limitations for versions of PHP with this Addon? I don't think this error is associated to the CE version I have. Thanks for your thoughts!
justgovintage
Posts: 14
Joined: Mon Nov 08, 2021 6:42 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by raiwa » Mon Nov 08, 2021 7:50 am

It is the Phoenix version which produces the error. The addon is flagged for Phoenix 1.0.8.2.
In general I only update my addons for mayor releases which would be 1.0.9.0. But I have this one already on my list for a 1.0.8.7 update. I hope I can do it during this week. Please be patient.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by justgovintage » Tue Nov 09, 2021 6:19 am

raiwa wrote:It is the Phoenix version which produces the error. The addon is flagged for Phoenix 1.0.8.2.
In general I only update my addons for mayor releases which would be 1.0.9.0. But I have this one already on my list for a 1.0.8.7 update. I hope I can do it during this week. Please be patient.
That would be awesome. I will be patient. Please keep me updated. Thanks!
justgovintage
Posts: 14
Joined: Mon Nov 08, 2021 6:42 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by raiwa » Tue Nov 09, 2021 4:05 pm

Version 2.1 for Phoenix 1.0.8.7 uploaded
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by justgovintage » Wed Nov 10, 2021 6:12 am

I think these paths are missing "/modules/content/" in your install manual. Can you confirm?

/includes/languages/english/shopping_cart/cm_sc_continue_shopping.php
/includes/languages/espanol/shopping_cart/cm_sc_continue_shopping.php
/includes/languages/german/shopping_cart/cm_sc_continue_shopping.php
justgovintage
Posts: 14
Joined: Mon Nov 08, 2021 6:42 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by raiwa » Wed Nov 10, 2021 6:19 am

Yes, just copy over the file structure as it is in the package.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by justgovintage » Wed Nov 10, 2021 6:21 am

Also, although the module is working for me, I am seeing these PHP warnings in my error log:

[10-Nov-2021 06:03:12 UTC] PHP Warning: Trying to access array offset on value of type null in /<ROOT>/includes/modules/content/shopping_cart/cm_sc_continue_shopping.php on line 38
[10-Nov-2021 06:03:12 UTC] PHP Warning: foreach() argument must be of type array|object, null given in /<ROOT>/includes/modules/content/shopping_cart/cm_sc_continue_shopping.php on line 38
[10-Nov-2021 06:03:22 UTC] PHP Warning: Undefined array key -2 in /<ROOT>/includes/modules/content/shopping_cart/cm_sc_continue_shopping.php on line 38
justgovintage
Posts: 14
Joined: Mon Nov 08, 2021 6:42 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by raiwa » Wed Nov 10, 2021 6:25 am

Thanks, I’ll check
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by raiwa » Wed Nov 10, 2021 7:18 am

Uploaded version 2.2 with the above fixes.
Thanks again for the reports.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1184
Joined: Sat Dec 21, 2019 8:08 am
Contact:

Re: 1.08.7 Fresh install - Continue Shopping 2.0 Error

by justgovintage » Thu Nov 11, 2021 5:05 am

Worked great, thanks!

I made a small tweak to the logic after verifying everything in case you or others are interested. I wanted the button to work more like a "back" button to take the customer back to the previous page they were on before going to the shopping cart (when possible) instead of to the last item in their cart. If they went to the cart by clicking on it & not by adding an item, it will more accurately take the customer back to where they were. If they did stock/quantity updates in the cart, then it could no longer use the "previous page" to return to and would instead return to the category of the last item in the cart.

{code}
// If the previous page was set & it was not checkout or shopping cart, then go back one page.
if ( isset($_SERVER['HTTP_REFERER']) && (strpos($_SERVER['HTTP_REFERER'], 'checkout' ) == false) && (strpos($_SERVER['HTTP_REFERER'], 'shopping_cart' ) == false)) {
$backlink = "javascript:history.go(-1)";
// If we don't have a previous page to go back to, then go back to the last product in the cart (if it exists).
} elseif ( isset($continueButtonId) ) {
$backlink = Guarantor::ensure_global('Linker')->build('index.php', 'cPath=' . $continueButtonId);
// Default case, nothing is in the cart, so go back to index.php
} else {
$backlink = Guarantor::ensure_global('Linker')->build('index.php');
}
{code}
justgovintage
Posts: 14
Joined: Mon Nov 08, 2021 6:42 am
Contact: