Whenever an item is added to the Cart, if the Cart ALREADY contains any items (regardless of how many products or their Qty), two lines of "undefined variable" are added to the Watchdog file:

Notice: Undefined variable: total_price in eval() (line 18 of /hsphere/local/home/neilfra/researchsquirrel.com/modules/php/php.module(80) : eval()'d code).

Notice: Undefined variable: total_qty in eval() (line 18 of /hsphere/local/home/neilfra/researchsquirrel.com/modules/php/php.module(80) : eval()'d code).

The error message pair is generated regardless of whether items in the Cart are Products or Kits, or whether the item added is a Product or Kit, or whether the Product or Kit is already in the Cart (increasing its Qty by buying again).

The pair is NOT generated if (a) the Cart is empty on adding the product, (b) just re-rendering the Cart page with however many products & quantities on it, (c) changing the quantities of items in the Cart either up or down, or (d) removing some or all products from the Cart (either by Deleting or setting Qty to zero and 'Update cart'). It occurs only on ADDING an item to a non-empty Cart.

I've spent a couple of hours chasing this down without success. If anyone has a solution, I'd be grateful to hear it.

Note: PHP 5.3, Drupal 7.59

Comments

neilsky created an issue. See original summary.

tr’s picture

Category: Bug report » Support request
Issue tags: -cart undefined variable php_help

That error isn't coming from Ubercart. You must have a contributed module that uses the PHP module for calculations. My guess is https://www.drupal.org/project/uc_custom_price.

tr’s picture

Status: Active » Postponed (maintainer needs more info)
neilsky’s picture

Thanks TR. The only other Ubercart module I have installed is Ubercart Discount Coupons (7.x-2.1-alpha7+5-dev), which I use a lot for product pack configurations. The problem above occurs whether or not a coupon is not applied, being applied, or is already applied, to the Cart.

If someone is able to determine if this problem is caused by the Discount Coupons module, then I guess this ticket should be moved under that stream?

Cheers

tr’s picture

It doesn't have to be an Ubercart-related module. For example, it could be Rules. The key here is that you're using the PHP module somewhere. Find out which of your modules depends on PHP or can use PHP if it's installed, and you will find the likely culprit.

tr’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

As I said, this is not coming from Ubercart - it's coming from the PHP module which Ubercart does not use. The $total_qty variable that the error message says is undefined doesn't exist in Ubercart, and the $total_price variable only appears in the test cases for Ubercart, not the code that is run on your website. So it's certain that those variable are defined and used in some other module you have on your site.