/** * Constructor. * Reads the cart contents from the "cart" table, if available. * Does not read from the userinfo table- that's up to the uesr * login and logout functions. */ public function __construct($cart_id = '') { global $_TABLES, $_PP_CONF; ppWorkflow::Init(); if (!isset($_SESSION[PP_CART_VAR])) { $_SESSION[PP_CART_VAR] = array('cart_id' => ''); } // Cart ID can be passed in, typically by IPN processors if (!empty($cart_id)) { $_SESSION[PP_CART_VAR]['cart_id'] = $cart_id; } elseif (empty($_SESSION[PP_CART_VAR]['cart_id'])) { $_SESSION[PP_CART_VAR]['cart_id'] = self::makeCartID(); } $this->m_cart = array(); $this->m_cart_id = $_SESSION[PP_CART_VAR]['cart_id']; //$this->m_billto = array(); //$this->m_shipto = array(); $this->m_info = array(); /*$txt = DB_getItem($_TABLES['paypal.cart'], 'cart_contents', "cart_id = '".DB_escapeString($this->m_cart_id)."'"); if (!empty($txt)) { $cart = @unserialize($txt); if ($cart) { $this->m_cart = $cart['items']; } }*/ $this->Load(); }
/** * Constructor. * Reads the cart contents from the "cart" table, if available. * Does not read from the userinfo table- that's up to the uesr * login and logout functions. */ public function __construct($cart_id = '', $interactive = true) { global $_TABLES, $_PP_CONF, $_USER; // Don't use session-based carts for paypal IPN, for those // we just want an empty cart that can be read. if ($interactive) { ppWorkflow::Init(); if (!isset($_SESSION[PP_CART_VAR])) { $_SESSION[PP_CART_VAR] = array('cart_id' => ''); } // Cart ID can be passed in, typically by IPN processors if (empty($cart_id)) { if (!empty($_SESSION[PP_CART_VAR]['cart_id'])) { $cart_id = $_SESSION[PP_CART_VAR]['cart_id']; } elseif (!COM_isAnonUser()) { $uid = (int) $_USER['uid']; $cart_id = DB_getItem($_TABLES['paypal.cart'], 'cart_id', "cart_uid = {$uid}"); } } // If a cart ID still not found, create a new one if (empty($cart_id)) { $cart_id = self::makeCartID(); } // Set the cart ID in the session and the local variable $_SESSION[PP_CART_VAR]['cart_id'] = $cart_id; $this->m_cart_id = $cart_id; } else { // For non-interactive sessions a cart ID must be provided $this->m_cart_id = $cart_id; } $this->m_cart = array(); //$this->m_billto = array(); //$this->m_shipto = array(); $this->m_info = array(); /*$txt = DB_getItem($_TABLES['paypal.cart'], 'cart_contents', "cart_id = '".DB_escapeString($this->m_cart_id)."'"); if (!empty($txt)) { $cart = @unserialize($txt); if ($cart) { $this->m_cart = $cart['items']; } }*/ $this->Load(); }