Warning: Creating default object from empty value in x/../x/cart.php on line 14

Started by The_Hat, July 19, 2013, 15:55:25 PM

Previous topic - Next topic

The_Hat

OK - I know everyone is busy so I manually updated my shop to 2.0.22a - the auto-installer wouldn't work. I think I have done this correctly but not confident of how to manually update the databases - I now have a very broken Virtuemart and had to take shop off-line - I can restore from backup but I don't want to as I should really be able to use the product in its latest version - can anyone advise on a good place to get proper instruction on how to update manually, specifically how to manually update the database schema using the files in the Install folder (I extracted the files from a manually downloaded ZIP and uploaded manually to the correct directory structure).

If anyone can help I really would be most grateful ... I am sorry if this is in the wrong area, but to me these items are development / bugs especially as my first question (see below) was reported as a bug - again, if this IS the wrong area, could someone please tell me where I should post ? (and not up my bottom - that may be funny, but not very helpful lol)

Many thanks,
Graham Martin - newbie to Virtuemart & PHP & semi-newbie to SQL, old hack in other areas ...
------------------------------------------------------------------------------------------------------------------------



UPDATE:

I managed to work out where to add the code from Milbo (thank you) - I no longer have an error on the basic cart display.

However, I tried to apply the same logic to the error in line 1213 ... I changed ...

         if ($nbPayment==1 && $virtuemart_paymentmethod_id) {
            $this->virtuemart_paymentmethod_id = $virtuemart_paymentmethod_id;
            $cart->automaticSelectedPayment=true;
            $this->setCartIntoSession();
            return true;
         } else {
            $cart->automaticSelectedPayment=false;
            $this->setCartIntoSession();
             return false;
          }

... to ...

         if ($nbPayment==1 && $virtuemart_paymentmethod_id) {
             $this->virtuemart_paymentmethod_id = $virtuemart_paymentmethod_id;
             $cart->automaticSelectedPayment=true;
             $this->setCartIntoSession();
             return true;
          } else {
            if(empty($cart->automaticSelectedPayment)){
                $cart->automaticSelectedPayment=new stdClass();
            }
             $cart->automaticSelectedPayment=false;
            $this->setCartIntoSession();
            return false;
         }

... but the error just dropped a line (ie it is still the line that first tries assigning anything to $cart that returns the WARNING message)

I really don't know what I'm doing here, any help most appreciated ...

Thank you,
Graham
I don't want to upgrade to v2.0.22a because this forum shows an error with using the "Add to Cart" button, but I will take advice  :)


========================================================================
Help please - this was all working fine, and I haven't upgraded my Virtuemart nor allowed any Joomla updates or plugin/component/modules updates either - nothing I needed to use was broken, so I didn't try to fix it  ;)

So, what WAS working, now isn't and the only thing I can think I did was clone an unpublished product (which failed, so I published it and tried the clone again and everything appeared to be fine).

The actual error is Warning: Creating default object from empty value in /home/candyroc/public_html/components/com_virtuemart/helpers/cart.php on line 1419

It can be seen at http://www.candyrockrecords.com/ and click on the "Our Shop" menu on the left. Also, now when I add something to the cart, it doesn't redisplay automatically but if I reload the page the cart shows items added OK UNDER the error message. When I go to the "Show cart", I get the following error messages:-


Warning: Creating default object from empty value in /home/candyroc/public_html/components/com_virtuemart/helpers/cart.php on line 1213

Warning: Creating default object from empty value in /home/candyroc/public_html/components/com_virtuemart/helpers/cart.php on line 1342


I have tried to sort the problem but only found the following on it - http://forum.virtuemart.net/index.php?topic=102964.0, which although I understand in basic, I'm not a great PHP developer so don't want to break anything. I'm not clear from Milbo or Thomas Kuschel's post where I need to put the coded fixes, nor which one to use.

I have a gig coming up that I need to promote so I'm getting a bit desperate, so any and all help / comments / pointers most welcomed and appreciated.

Thanks in advance for your time,
Graham Martin

Joomla! 1.5.26 Stable, PHP 5.4.16, VM 2.0.0 (it wasn't broken for my use, so I didn't try to fix it lol)