public static function getPrice($id, $quantity = '1') { // $sets[$id][$quantity][$group_id][$date] static $sets; if (!is_array($sets)) { $sets = array(); } $price = null; if (empty($id)) { return $price; } $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedGroups()); if (!isset($sets[$id][$quantity][$groups])) { (int) $quantity; if ($quantity <= '0') { $quantity = '1'; } $product = J2StorePrices::getJ2Product($id); $item = new JObject(); //1. base price $item->product_price = $product->item_price; $item->product_baseprice = $product->item_price; //2. special/offer price if any if (isset($product->special_price) && $product->special_price > 0) { $item->product_specialprice = (double) $product->special_price; $item->product_price = (double) $product->special_price; } //3. price based on the group $group_price = J2StorePrices::getGroupPrice($id); if (isset($group_price) && $group_price) { $item->product_customer_groupprice = $group_price; //we have a group price for this product. So set the special price to null. $item->product_specialprice = null; // this will be the product price as well as the base price $item->product_price = (double) $group_price; } //3. price range based on the date and the quantity $price_range = J2StorePrices::getPriceRange($id, $quantity); if ($price_range > 0.0) { $item->product_price = $price_range; } $sets[$id][$quantity][$groups] = $item; } return $sets[$id][$quantity][$groups]; }