public function isAvailable() { // create cart object out of item properties $item = new JObject(); $item->user_id = $this->user_id; $item->product_id = (int) $this->product_id; $item->product_qty = !empty($this->product_quantity) ? $this->product_quantity : '1'; $item->product_attributes = $this->product_attributes; $item->vendor_id = $this->vendor_id; $item->cartitem_params = $this->wishlistitem_params; DSCTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/tables'); $product = DSCTable::getInstance('Products', 'CitruscartTable'); $product->load(array('product_id' => $this->product_id)); if (empty($product->product_enabled) || empty($product->product_id)) { $this->setError(JText::_('COM_CITRUSCART_INVALID_PRODUCT')); return false; } if ($product->product_notforsale) { $this->setError(JText::_('COM_CITRUSCART_PRODUCT_NOT_FOR_SALE')); return false; } Citruscart::load('CitruscartHelperProduct', 'helpers.product'); $product_helper = new CitruscartHelperProduct(); $availableQuantity = $product_helper->getAvailableQuantity($item->product_id, $item->product_attributes); if ($availableQuantity->product_check_inventory && $item->product_qty > $availableQuantity->quantity) { $this->setError(JText::sprintf("COM_CITRUSCART_NOT_AVAILABLE_QUANTITY", $availableQuantity->product_name, $item->product_qty)); return false; } $results = array(); $dispatcher = JDispatcher::getInstance(); $results = JFactory::getApplication()->triggerEvent("onIsWishlistItemAvailable", array(&$item)); for ($i = 0; $i < count($results); $i++) { $result = $results[$i]; if (!empty($result->error)) { $this->setError($result->message); return false; } } return true; }