Forums / General Questions / A couple of PHP Warnings

A couple of PHP Warnings

Started by nwce on 25 Mar 2025, 4:19 PM · Views: 1,611

Results 1 to 15 of 15
25 Mar 2025, 4:19 PM
#1
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

A couple of PHP Warnings

I wanted to post these couple of PHP Warnings I've come across to hopefully help with future updates...and as well, if you could let me know what code to add now, so I can correct these and not have to go through these same ones each day.

#1 - I sell digital products, and when updating a customer's order to give them more download attempts, I get the following in my Debug Log...
PHP Warning: Undefined array key 1 in /includes/classes/shopping_cart.php on line 2669.

When I update more than 1 order...it then also gives me....Undefined array key 2 (in the same file on the same line)
Undefined array key 3...etc.

#2 - I am doing a cross promotion with another company and am giving a free coupon code to their customers. When the customer uses this code, I get the following PHP Warning in my Debug Log....
PHP Warning: Undefined global variable $free in includes/modules/payment/paypaldp.php on line 1645.
and also...
PHP Warning: Attempt to read property "tax_class" on null in includes/modules/payment/paypaldp.php on line 1645

Thanks for your help!

25 Mar 2025, 5:24 PM
#2
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: A couple of PHP Warnings

One other Debug Log PHP warning I received this morning while inserting a new product is...

PHP Warning: Undefined variable $attributes_value in Admin/attributes_controller.php on line 1962

Would someone be able to supply to code to correct this warning??

Thanks!

26 Mar 2025, 8:06 AM
#3
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: A couple of PHP Warnings

NWCE:

One other Debug Log PHP warning I received this morning while inserting a new product is...

PHP Warning: Undefined variable $attributes_value in Admin/attributes_controller.php on line 1962

Would someone be able to supply to code to correct this warning??

Thanks!

Has this been addressed previously? Try searching the forum for "Undefined variable $attributes_value", as suggested in the posting tips.

Simon

26 Mar 2025, 9:56 AM
#4
lat9 avatar

lat9

Administrator

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

Re: A couple of PHP Warnings

Note, too, that when posting a log that it's important to post the **full **log, including the header (which identifies which page on which the issue occurred) and the backtrace (which identifies the call-chain and, in some instances, possibly the source of the issue).

26 Mar 2025, 12:22 PM
#5
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: A couple of PHP Warnings

Thanks simon1066 for passing along the fix for this from another post. I will apply this code change from the Github link!

26 Mar 2025, 12:24 PM
#6
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: A couple of PHP Warnings

Thanks lat9 for letting me know that in order to decipher the Debug Log that you need the entire log.

I will do this with my PHP Warnings...and also see that there is a Bug Report area....will post in there.

Thanks again

26 Mar 2025, 5:22 PM
#7
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: A couple of PHP Warnings

Here is the full Debug Log for one the PHP Warnings (#2) I posted in previous post. Hope this helps to decipher it....and if you would share a code fix that would be great!

Request URI: /shop/index.php?main_page=checkout_process, IP address: 66.61.47.189, Language id 1
#0 /home/shop/includes/modules/payment/paypaldp.php(1645): zen_debug_error_handler()
#1/home/public_html/shop/includes/modules/payment/paypaldp.php(744): paypaldp->getLineItemDetails()
#2 /home/public_html/shop/includes/classes/payment.php(350): paypaldp->before_process()
#3 /home/public_html/shop/includes/modules/checkout_process.php(98): payment->before_process()
#4 /home/public_html/shop/includes/modules/pages/checkout_process/header_php.php(13): require('...')
#5 /home/public_html/shop/index.php(35): require('...')
--> PHP Warning: Undefined global variable $free in /home/public_html/shop/includes/modules/payment/paypaldp.php on line 1645.

[26-Mar-2025 08:45:43 America] Request URI: /shop/index.php?main_page=checkout_process, IP address: 66.61.47.189, Language id 1
#0 /home/public_html/shop/includes/modules/payment/paypaldp.php(1645): zen_debug_error_handler()
#1 /home/public_html/shop/includes/modules/payment/paypaldp.php(744): paypaldp->getLineItemDetails()
#2 /home/public_html/shop/includes/classes/payment.php(350): paypaldp->before_process()
#3 /home/public_html/shop/includes/modules/checkout_process.php(98): payment->before_process()
#4 /home/public_html/shop/includes/modules/pages/checkout_process/header_php.php(13): require('...')
#5 /home/public_html/shop/index.php(35): require('...')
--> PHP Warning: Attempt to read property "tax_class" on null in /home/public_html/shop/includes/modules/payment/paypaldp.php on line 1645.

26 Mar 2025, 5:50 PM
#8
lat9 avatar

lat9

Administrator

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

Re: A couple of PHP Warnings

Since you didn't say, I'm assuming that you're running zc210.

Try editing /includes/modules/payment/paypaldp.php, changing line 1645 from

        if (isset($GLOBALS[$module]) && $GLOBALS[$module]->tax_class > 0) {

to

        if (($GLOBALS[$module]->tax_class ?? 0) > 0) {

and let me know if that corrects the issue; if so, I'll get that updated on the Zen Cart GitHub.

26 Mar 2025, 6:05 PM
#9
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: A couple of PHP Warnings

lat9:

Since you didn't say, I'm assuming that you're running zc210.

This thread is tagged with v210

Simon

26 Mar 2025, 6:15 PM
#10
lat9 avatar

lat9

Administrator

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

Re: A couple of PHP Warnings

simon1066:

This thread is tagged with v210
Duh! Thanks for the correction.

26 Mar 2025, 8:25 PM
#11
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: A couple of PHP Warnings

Thanks Cindy for the code....and yes (sorry) I am running v.2.1

I will implement this code and let you know tomorrow how it all works out!

26 Mar 2025, 9:18 PM
#12
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: A couple of PHP Warnings

Here is another of the PHP Warnings that I get in Debug Log....hoping you will be able to help with this one as well.....

Request URI: /shop/index.php?main_page=shopping_cart&action=update_product, IP address: 97.154.151.109, Language id 1
#0 /home/public_html/shop/includes/classes/shopping_cart.php(2669): zen_debug_error_handler()
#1 /home/public_html/shop/includes/classes/shopping_cart.php(1784): shoppingCart->in_cart_product_mixed_changed()
#2 /home/public_html/shop/includes/main_cart_actions.php(50): shoppingCart->actionUpdateProduct()
#3 /home/public_html/shop/includes/init_includes/init_cart_handler.php(42): require('...')
#4 /home/public_html/shop/includes/autoload_func.php(40): require_once('...')
#5 /home/public_html/shop/includes/application_top.php(329): require('...')
#6 /home/public_html/shop/index.php(25): require('...')
--> PHP Warning: Undefined array key 1 in /home/public_html/shop/includes/classes/shopping_cart.php on line 2669.

[26-Mar-2025 14:55:40 America] Request URI: /shop/index.php?main_page=shopping_cart&action=update_product, IP address: 97.154.151.109, Language id 1
#0 /home/public_html/shop/includes/classes/shopping_cart.php(2669): zen_debug_error_handler()
#1 /home/public_html/shop/includes/classes/shopping_cart.php(1784): shoppingCart->in_cart_product_mixed_changed()
#2 /home/public_html/shop/includes/main_cart_actions.php(50): shoppingCart->actionUpdateProduct()
#3 /home/public_html/shop/includes/init_includes/init_cart_handler.php(42): require('...')
#4 /home/public_html/shop/includes/autoload_func.php(40): require_once('...')
#5 /home/public_html/shop/includes/application_top.php(329): require('...')
#6 /home/public_html/shop/index.php(25): require('...')
--> PHP Warning: Undefined array key 2 in /home/public_html/shop/includes/classes/shopping_cart.php on line 2669.

Thank you for your help!

27 Mar 2025, 12:31 PM
#13
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: A couple of PHP Warnings

lat9:

Since you didn't say, I'm assuming that you're running zc210.

Try editing /includes/modules/payment/paypaldp.php, changing line 1645 from

    if (isset($GLOBALS[$module]) && $GLOBALS[$module]->tax_class > 0) {
> to
> ```
        if (($GLOBALS[$module]->tax_class ?? 0) > 0) {

and let me know if that corrects the issue; if so, I'll get that updated on the Zen Cart GitHub.

I have now had this code changed for 24 hours with several orders coming through....all works perfectly with no Debug Logs or errors.
Thanks for your help!

28 Mar 2025, 12:18 PM
#14
nwce avatar

nwce

Zen Follower

Join Date:
Oct 2009
Posts:
444
Plugin Contributions:
0

Re: A couple of PHP Warnings

Lastly...I have one more Debug Log to share with a PHP Warning. If you could take a look and let me know what code changes are needed to mitigate the warning.

Request URI: /shop/ajax.php?act=ajaxPayment&method=prepareConfirmation, IP address: 8.18.235.206, Language id 1
#0 /home/public_html/shop/includes/templates/custom/templates/tpl_ajax_checkout_confirmation_default.php(35): zen_debug_error_handler()
#1 /home/public_html/shop/includes/classes/ajax/zcAjaxPayment.php(191): require_once('...')
#2 /home/public_html/shop/ajax.php(77): zcAjaxPayment->prepareConfirmation()
--> PHP Warning: Undefined global variable $ in /home/public_html/shop/includes/templates/custom/templates/tpl_ajax_checkout_confirmation_default.php on line 35.

[28-Mar-2025 06:04:36 America] Request URI: /shop/ajax.php?act=ajaxPayment&method=prepareConfirmation, IP address: 8.18.235.206, Language id 1
#0 /home/public_html/shop/includes/templates/custom/templates/tpl_ajax_checkout_confirmation_default.php(35): zen_debug_error_handler()
#1 /home/public_html/shop/includes/classes/ajax/zcAjaxPayment.php(191): require_once('...')
#2 /home/public_html/shop/ajax.php(77): zcAjaxPayment->prepareConfirmation()
--> PHP Warning: Attempt to read property "title" on null in /home/public_html/shop/includes/templates/custom/templates/tpl_ajax_checkout_confirmation_default.php on line 35.

Thanks again for your help and hope this help with future updates.

29 Mar 2025, 3:49 PM
#15
lat9 avatar

lat9

Administrator

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

Re: A couple of PHP Warnings

NWCE:

I have now had this code changed for 24 hours with several orders coming through....all works perfectly with no Debug Logs or errors.
Thanks for your help!
See this Zen Cart GitHub PR for the proposed correction: https://github.com/zencart/zencart/pull/7043