function __construct($params = array(), $get_assoc = true, $get_attached = false) { global $db, $user; if (!empty($params['id']) || is_numeric($params)) { parent::__construct($params, $get_assoc, $get_attached); $prodtype = $this->product_type; $this->product = new $prodtype($this->product_id, false, true); } elseif (isset($params['product_id']) && isset($params['product_type'])) { // see if this is an existing item in the cart if (isset($params['orderid'])) { $order = new order($params['orderid']); } else { $order = order::getUserCart(); } //adding lookup on price to acocomdate quantity discounts $where = 'orders_id=' . $order->id . ' AND product_id=' . $params['product_id'] . ' AND products_price=' . $params['products_price'] . " AND product_type='" . $params['product_type'] . "'"; $where .= empty($params['options']) ? '' : " AND options='" . $params['options'] . "'"; $where .= empty($params['user_input_fields']) ? '' : " AND user_input_fields='" . $params['user_input_fields'] . "'"; $item = $db->selectObject($this->table, $where); $this->product = new $params['product_type']($params['product_id'], false, true); if (empty($item)) { parent::__construct(array('orders_id' => $order->id, 'user_id' => $user->id, 'product_id' => $this->product->id, 'product_type' => $params['product_type'], 'products_name' => $this->product->title, 'products_price' => $this->product->getBasePrice()), $get_assoc, $get_attached); } else { parent::__construct($item->id, $get_assoc, $get_attached); //$this->quantity = $this->product->incrementQuantity($this->quantity); } } else { parent::__construct(null, $get_assoc, $get_attached); } if (isset($this->options)) { $this->opts = expUnserialize($this->options); } if (!empty($this->user_input_fields)) { //$this->user_input_fields = expUnserialize($this->user_input_fields); } }
$microtime_str = explode(' ', microtime()); $i_start = $microtime_str[0] + $microtime_str[1]; // Initialize the Exponent Framework require_once 'exponent.php'; //active global timer if in DEVELOPMENT mode if (DEVELOPMENT) { $timer = new expTimer(); } // if the user has turned on sef_urls then we need to route the request, otherwise we can just // skip it and default back to the old way of doing things. $router->routeRequest(); // initialize this users cart if they have ecom installed. // define whether or not ecom is enabled if ($db->selectValue('modstate', 'active', 'module="storeController"')) { define('ECOM', 1); $order = order::getUserCart(); // Create a globle store config // We're forcing the location. Global store setting will always have this loc $cfg->mod = "ecomconfig"; $cfg->src = "@globalstoresettings"; $cfg->int = ""; $storeConfig = new expConfig($cfg); } else { define('ECOM', 0); } if (isset($_GET['id']) && !is_numeric($_GET['id'])) { $_GET['id'] = intval($_GET['id']); } $section = $router->getSection(); if ($db->havedb) { $sectionObj = $router->getSectionObj($section);