News:

Looking for documentation? Take a look on our wiki

Main Menu

login.php - PHP tidiness suggestions

Started by mb000000, December 07, 2012, 13:21:43 PM

Previous topic - Next topic

mb000000

VM 2.0.14 on Joomla 1.5.26 (yes, really), PHP 5.2.17, Apache 2.2.22

I wanted a menu link for returning customers to login to see their existing orders, manage their account and so on.  So, I created a menu, added a Virtuemart/login entry and that seemed to do the trick.  However when clicking on the login link, although the VM login displays, there are PHP notices for references to unset variables VirtuemartViewUser::$from_cart and VirtuemartViewUser::$order. 

I'm sure there are many other solutions, but I simply added the following lines into components/com_virtuemart/views/user/tmpl/login.php at around line 60 (before the dispatcher trigger to plgVmDisplayLogin) if (!isset( $this->from_cart )) $this->from_cart = FALSE;
if (!isset( $this->order )) $this->order = FALSE ;

Having looked in shopfunctionsf::getLoginForm, I saw the default cases were FALSE, so used those.  The PHP Notices now go away (of course) and I get the behaviour I wanted.

And, yes, I had thought about turning PHP Notices off (they are on the live site), but I prefer to keep them on on the dev site, as I consider that one more tool to make up for a lack of a full debugging IDE for PHP (any suggestions anyone?).

HTH someone

Mark

Milbo

I added now this

if (!isset( $this->show )) $this->show = TRUE;
if (!isset( $this->from_cart )) $this->from_cart = FALSE;
if (!isset( $this->order )) $this->order = FALSE ;
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/