VirtueMart - 1.1 Developer's Guide

Page of 44
Other important
Environment variables
7
    // Load class definition file
    require_once( CLASSPATH."$class.php" );
    $classname = str_replace( '.class', '', $funcParams["class"]);
    if( !class_exists(strtolower($classname))) {
     $classname = 'vm'.$classname;
    }
    if( class_exists( $classname )) {
     // create an object
     $$classname = new $classname();
    
     // RUN THE FUNCTION
     // $ok  = $class->function( $vars );
     $ok = $$classname->$funcParams["method"]($vars);
    }
First, the file 
ps_product.php
 is loaded, then an object of the class 
ps_product
 is created and
the function add is called on that object. The function returns 
true
 on success and 
false
 on failure.
The variable 
$ok
 stores the function result. All this code is exectuted using the PHP eval command
for creating and executing PHP code on-the-fly.
If you wonder what the variable 
$vars
 is: it's just a working copy of the superglobal 
$_REQUEST
Array and used as the array 
$d
 inside of the functions.
2.3.3. Other important Environment variables
Array $cart
The current cart contents. The array has the following structure:
[cart] # Array ( 
            [idx] # 1 
            [0] # Array ( 
                     [quantity] # 1 
                     [product_id] # 10 
                     [description] # Size:big; Power:100W 
                   )
           )
In  this  example,  the  car  contains  one  product  with  the  quantity  of  1,  the
product ID 10 and a description.
The index "idx" is an integer and contains the size of the cart (number of
different products in it, regardless of their quantity). This variable is always
available in the global 
$_SESSION
 array: 
$_SESSION['cart']
.
Array $auth
All  the  user  information  in  one  Array,  always  available  in  the  global
$_SESSION
 array.
[auth] # Array ( 
            [show_prices] # 1 
            [user_id] # 0 
            [username] # demo 
            [perms] # 
            [first_name] # guest 
            [last_name] # 
            [shopper_group_id] # 5 
            [shopper_group_discount] # 0.00 
            [show_price_including_tax] # 1 
            [default_shopper_group] # 1 
            [is_registered_customer] # 
          )