/** * Load class supplier using identifier in $_GET (if possible) * otherwise return an empty supplier, or die * * @param boolean $opt Return an empty supplier if load fail * @return supplier|boolean */ public function loadObject($opt = false) { $app = JFactory::getApplication(); $currency_id = (int) $app->input->get('currency_id'); if ($currency_id && JeproshopTools::isUnsignedInt($currency_id)) { if (!$this->currency) { $this->currency = new JeproshopCurrencyModelCurrency($currency_id); } if (JeproshopTools::isLoadedObject($this->currency, 'currency_id')) { return $this->currency; } // throw exception JError::raiseError(500, 'The currency cannot be loaded (or not found)'); return false; } elseif ($opt) { if (!$this->currency) { $this->currency = new JeproshopCurrencyModelCurrency(); } return $this->currency; } else { $this->context->controller->has_errors = true; Tools::displayError('The currency cannot be loaded (the identifier is missing or invalid)'); return false; } }
public function loadObject($option = false) { $app = JFactory::getApplication(); $tag_id = $app->input->get('tag_id'); if ($tag_id && JeproshopTools::isUnsignedInt($tag_id)) { if (!$this->tag) { $this->tag = new JeproshopTagModelTag($tag_id); } if (JeproshopTools::isLoadedObject($this->tag, 'tag_id')) { return $this->tag; } JError::raiseError(500, JText::_('COM_JEPROSHOP_TAG_CANNOT_BE_LOADED_OR_FOUND_LABEL')); } elseif ($option) { if ($this->tag) { $this->tag = new JeproshopTagModelTag(); } return $this->tag; } else { JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_TAG_CANNOT_BE_LOADED_THE_IDENTIFIER_IS_MISSING_OR_INVALID_MESSAGE')); return false; } }
public function loadObject($option = false) { echo 'correct'; exit; $app = JFactory::getApplication(); $attribute_id = $app->input->get('attribute_id'); if ($attribute_id && JeproshopTools::isUnsignedInt($attribute_id)) { if (!$this->attribute) { $this->attribute = new JeproshopAttributeModelAttribute($attribute_id); } if (JeproshopTools::isLoadedObject($this->attribute, 'attribute_id')) { return $this->attribute; } JError::raiseError(500, JText::_('COM_JEPROSHOP_ATTRIBUTE_CANNOT_BE_LOADED_OR_FOUND_LABEL')); } elseif ($option) { if ($this->attribute) { $this->attribute = new JeproshopAttributeModelAttribute(); } return $this->attribute; } else { JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_ATTRIBUTE_CANNOT_BE_LOADED_THE_IDENTIFIER_IS_MISSING_OR_INVALID_MESSAGE')); return false; } }
/** * Removes a given product from the stock available * * @param int $product_id * @param int $product_attribute_id Optional * @param mixed $shop shop id or shop object Optional */ public static function removeProductFromStockAvailable($product_id, $product_attribute_id = null, $shop = null) { if (!JeproshopTools::isUnsignedInt($product_id)) { return false; } $db = JFactory::getDBO(); if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) { if (JeproshopShopModelShop::getContextShopGroup()->share_stock == 1) { $product_attribute_sql = ''; if ($product_attribute_id !== null) { $product_attribute_sql = '_attribute'; $product_attribute_id_sql = $product_attribute_id; } else { $product_attribute_id_sql = $product_id; } $query = "SELECT COUNT(*) FROM " . $db->quoteName('#__jeproshop_product' . $product_attribute_sql . '_shop') . " WHERE " . $db->quoteName('product' . $product_attribute_sql . '_id') . " = "; $query .= (int) $product_attribute_id_sql . " AND " . $db->quoteName('shop_id') . " IN (" . implode(',', array_map('intval', JeproshopShopModelShop::getContextListShopIds(JeproshopShopModelShop::SHARE_STOCK))) . ")"; $db->setQuery($query); $result = (int) $db->loadResult(); if ($result) { return true; } } } $query = "DELETE FROM " . $db->quoteName('#__jeproshop_stock_available') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product_id; $query .= ($product_attribute_id ? " AND " . $db->quoteName('product_attribute_id') . " = " . (int) $product_attribute_id : "") . JeproshopStockAvailableModelStockAvailable::addShopRestriction(null, $shop); $db->setQuery($query); $res = $db->query(); if ($product_attribute_id) { if ($shop === null || !JeproshopTools::isLoadedObject($shop, 'shop_id')) { $shop_datas = new Object(); JeproshopStockAvailableModelStockAvailable::addSqlShopParams($shop_datas); $shop_id = (int) $shop_datas->shop_id; } else { $shop_id = (int) $shop->shop_id; } $stock_available = new JeproshopStockAvailableModelStockAvailable(); $stock_available->product_id = (int) $product_id; $stock_available->product_attribute_id = (int) $product_id; $stock_available->shop_id = (int) $shop_id; $stock_available->postSave(); } JeproshopCache::clean('jeproshop_stock_available_get-quantity_Available_by_product_' . (int) $product_id . '_*'); return $res; }
public static function getStaticTaxRulesList($tax_rules_group_id = 0, JeproshopContext $context = null) { jimport('joomla.html.pagination'); $db = JFactory::getDBO(); $app = JFactory::getApplication(); $option = $app->input->get('option'); $view = $app->input->get('view'); if (!isset($context)) { $context = JeproshopContext::getContext(); } $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); $limit_start = $app->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int'); $lang_id = $app->getUserStateFromRequest($option . $view . '.lang_id', 'lang_id', $context->language->lang_id, 'int'); $use_limit = true; if ($limit === false) { $use_limit = false; } do { $query = "SELECT SQL_CALC_FOUND_ROWS country_lang." . $db->quoteName('name') . " AS country_name, state." . $db->quoteName('name') . " AS state_name, tax_rule." . $db->quoteName('behavior') . ", tax_rule." . $db->quoteName('tax_rule_id') . ", tax_rule."; $query .= $db->quoteName('description') . ", CONCAT_WS(' - ', tax_rule." . $db->quoteName('zipcode_from') . ", tax_rule." . $db->quoteName('zipcode_to') . ") AS zipcode, tax." . $db->quoteName('rate') . ", tax_rule." . $db->quoteName('country_id') . " FROM "; $query .= $db->quoteName('#__jeproshop_tax_rule') . " AS tax_rule LEFT JOIN " . $db->quoteName('#__jeproshop_country_lang') . " AS country_lang ON (tax_rule." . $db->quoteName('country_id') . " = country_lang." . $db->quoteName('country_id') . " AND country_lang."; $query .= $db->quoteName('lang_id') . " = " . (int) $lang_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_state') . " AS state ON(tax_rule." . $db->quoteName('state_id') . " = state." . $db->quoteName('state_id'); $query .= ") LEFT JOIN " . $db->quoteName('#__jeproshop_tax') . " AS tax ON(tax_rule." . $db->quoteName('tax_id') . " = tax." . $db->quoteName('tax_id') . ") WHERE 1 " . (JeproshopTools::isUnsignedInt($tax_rules_group_id) ? " AND " . $db->quoteName('tax_rules_group_id') . " = " . (int) $tax_rules_group_id : ""); $query .= " ORDER BY tax_rule." . $db->quoteName('tax_rule_id') . " ASC "; $db->setQuery($query); $total = count($db->loadObjectList()); $query .= $use_limit === true ? " LIMIT " . (int) $limit_start . ", " . (int) $limit : ""; $db->setQuery($query); $tax_rules = $db->loadObjectList(); if ($use_limit == true) { $limit_start = (int) $limit_start - (int) $limit; if ($limit_start < 0) { break; } } else { break; } } while (empty($tax_rules)); return $tax_rules; }
/** * Check if order contains (only) virtual products * * @param boolean $strict If false return true if there are at least one product virtual * @return boolean true if is a virtual order or false * */ public function isVirtual($strict = true) { $products = $this->getProducts(); if (count($products) < 1) { return false; } $virtual = true; foreach ($products as $product) { $pd = JeproshopProductDownloadModelProductDownload::getIdFromProductId((int) $product->product_id); if ($pd && JeproshopTools::isUnsignedInt($pd) && $product->download_hash && $product->display_filename != '') { if ($strict === false) { return true; } } else { $virtual &= false; } } return $virtual; }
/** * @see ObjectModel::delete() */ public function delete() { if (JeproshopTools::isUnsignedInt($this->customer_id)) { JeproshopCustomerModelCustomer::resetAddressCache($this->customer_id); } if (!$this->isUsed()) { return parent::delete(); } else { $this->deleted = true; return $this->update(); } }
public function loadObject($option = false) { $app = JFactory::getApplication(); $category_id = $app->input->get('category_id'); if (!isset($this->context) || $this->context == null) { $this->context = JeproshopContext::getContext(); } $isLoaded = false; if ($category_id && JeproshopTools::isUnsignedInt($category_id)) { if (!$this->context->controller->category) { $this->context->controller->category = new JeproshopCategoryModelCategory($category_id); } if (!JeproshopTools::isLoadedObject($this->context->controller->category, 'category_id')) { JError::raiseError(500, JText::_('COM_JEPROSHOP_CATEGORY_NOT_FOUND_MESSAGE')); $isLoaded = false; } else { $isLoaded = true; } } elseif ($option) { if (!$this->context->controller->category) { $this->context->controller->category = new JeproshopCategoryModelCategory(); } } else { JError::raiseError(500, JText::_('COM_JEPROSHOP_CATEGORY_DOES_NOT_EXIST_MESSAGE')); $isLoaded = false; } return $isLoaded; }
public function getCategoriesList() { jimport('joomla.html.pagination'); $db = JFactory::getDBO(); $app = JFactory::getApplication(); $option = $app->input->get('option'); $view = $app->input->get('view'); $context = JeproshopContext::getContext(); $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); $limitstart = $app->getUserStateFromRequest($option . $view . '.limit_start', 'limit_start', 0, 'int'); $lang_id = $app->getUserStateFromRequest($option . $view . '.lang_id', 'lang_id', $context->language->lang_id, 'int'); $shop_id = $app->getUserStateFromRequest($option . $view . '.shop_id', 'shop_id', $context->shop->shop_id, 'int'); $shop_group_id = $app->getUserStateFromRequest($option . $view . '.shop_group_id', 'shop_group_id', $context->shop->shop_group_id, 'int'); $category_id = $app->getUserStateFromRequest($option . $view . '.category_id', 'category_id', 0, 'int'); $order_by = $app->getUserStateFromRequest($option . $view . '.order_by', 'order_by', 'date_add', 'string'); $order_way = $app->getUserStateFromRequest($option . $view . '.order_way', 'order_way', 'ASC', 'string'); $published = $app->getUserStateFromRequest($option . $view . '.published', 'published', 0, 'string'); $count_categories_without_parent = count(JeproshopCategoryModelCategory::getCategoriesWithoutParent()); $top_category = JeproshopCategoryModelCategory::getTopCategory(); $parent_id = 0; if ($category_id) { $category = new JeproshopCategoryModelCategory($category_id); $parent_id = $category->category_id; } elseif (!JeproshopShopModelShop::isFeaturePublished() && $count_categories_without_parent > 1) { $parent_id = $top_category->category_id; } elseif (JeproshopShopModelShop::isFeaturePublished() && $count_categories_without_parent == 1) { $parent_id = JeproshopSettingModelSetting::getValue('root_category'); } elseif (JeproshopShopModelShop::isFeaturePublished() && $count_categories_without_parent > 1 && JeproshopShopModelShop::getShopContext() != JeproshopShopModelShop::CONTEXT_SHOP) { if (JeproshopSettingModelSetting::getValue('multishop_feature_active') && count(JeproshopShopModelShop::getShops(true, null, true)) == 1) { $parent_id = $context->shop->category_id; } else { $parent_id = $top_category->category_id; } } $explicitSelect = true; /* Manage default params values */ $use_limit = true; if ($limit === false) { $use_limit = false; } $join = " LEFT JOIN " . $db->quoteName('#__jeproshop_category_shop') . " AS category_shop ON (category." . $db->quoteName('category_id') . " = category_shop." . $db->quoteName('category_id') . " AND "; if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) { $join .= " category_shop.shop_id = " . (int) $context->shop->shop_id . ") "; } else { $join .= " category_shop.shop_id = category.default_shop_id)"; } // we add restriction for shop if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP && JeproshopShopModelShop::isFeaturePublished()) { $where = " AND category_shop." . $db->quoteName('shop_id') . " = " . (int) JeproshopContext::getContext()->shop->shop_id; } /* Check params validity */ if (!JeproshopTools::isOrderBy($order_by) || !JeproshopTools::isOrderWay($order_way) || !is_numeric($limitstart) || !is_numeric($limit) || !JeproshopTools::isUnsignedInt($lang_id)) { echo JError::raiseError(500, 'get list params is not valid'); } /* Cache */ if (preg_match('/[.!]/', $order_by)) { $order_by_split = preg_split('/[.!]/', $order_by); $order_by = bqSQL($order_by_split[0]) . '.`' . bqSQL($order_by_split[1]) . '`'; } elseif ($order_by) { $order_by = $db->quoteName($db->escape($order_by)); } // Add SQL shop restriction $shopLinkType = ""; $select_shop = $join_shop = $where_shop = ''; /*if ($shopLinkType){ $select_shop = ", shop.shop_name as shop_name "; $join_shop = " LEFT JOIN " ._DB_PREFIX_.$this->shopLinkType.' shop ON a.id_'.$this->shopLinkType.' = shop.id_'.$this->shopLinkType; $where_shop = JeproshopShopModelShop::addSqlRestriction('1', 'category'); }*/ if ($context->controller->multishop_context && JeproshopShopModelShop::isTableAssociated('category')) { if (JeproshopShopModelShop::getShopContext() != JeproshopShopModelShop::CONTEXT_ALL || !$context->employee->isSuperAdmin()) { $test_join = !preg_match('/`?' . preg_quote('#__jeproshop_category_shop') . '`? *category_shop/', $join); if (JeproshopShopModelShop::isFeaturePublished() && $test_join && JeproshopShopModelShop::isTableAssociated('category')) { $where .= " AND category.category_id IN ( SELECT category_shop.category_id FROM "; $where .= $db->quoteName('#__jeproshop_category__shop') . " AS category_shop WHERE category_shop."; $where .= "shop_id IN (" . implode(', ', JeproshopShopModelShop::getContextListShopIds()) . ") )"; } } } $select = ", category_shop.position AS position "; $tmpTableFilter = ""; /* Query in order to get results with all fields */ $lang_join = " LEFT JOIN " . $db->quoteName('#__jeproshop_category_lang') . " AS category_lang ON ("; $lang_join .= "category_lang." . $db->quoteName('category_id') . " = category." . $db->quoteName('category_id'); $lang_join .= " AND category_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id; if ($context->shop->shop_id) { if (!JeproshopShopModelShop::isFeaturePublished()) { $lang_join .= " AND category_lang." . $db->quoteName('shop_id') . " = 1"; } elseif (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) { $lang_join .= " AND category_lang." . $db->quoteName('shop_id') . " = " . (int) $context->shop->shop_id; } else { $lang_join .= " AND category_lang." . $db->quoteName('shop_id') . " = category.default_shop_id"; } } $lang_join .= ") "; $having_clause = ''; if (isset($this->_filterHaving) || isset($this->_having)) { $having_clause = ' HAVING '; if (isset($this->_filterHaving)) { $having_clause .= ltrim($this->_filterHaving, ' AND '); } if (isset($this->_having)) { $having_clause .= $this->_having . ' '; } } do { $query = "SELECT SQL_CALC_FOUND_ROWS " . ($tmpTableFilter ? " * FROM (SELECT " : ""); if ($explicitSelect) { $query .= "category." . $db->quoteName('category_id') . ", category_lang." . $db->quoteName('name') . ", category_lang." . $db->quoteName('description'); $query .= " , category." . $db->quoteName('position') . " AS category_position, " . $db->quoteName('published'); } else { $query .= ($lang_id ? " category_lang.*," : "") . " category.*"; } $query .= (isset($select) ? rtrim($select, ", ") : "") . $select_shop . " FROM " . $db->quoteName('#__jeproshop_category') . " AS category " . $lang_join . (isset($join) ? $join . " " : ""); $query .= $join_shop . " WHERE 1 " . (isset($where) ? $where . " " : "") . ($this->deleted_category ? " AND category." . $db->quoteName('deleted') . " = 0 " : "") . "AND " . $db->quoteName('parent_id'); $query .= "= " . (int) $parent_id . $where_shop . (isset($group) ? $group . " " : "") . $having_clause . " ORDER BY " . (str_replace('`', '', $order_by) == 'category_id' ? "category." : "") . " category."; $query .= $order_by . " " . $db->escape($order_way) . ($tmpTableFilter ? ") tmpTable WHERE 1" . $tmpTableFilter : ""); $db->setQuery($query); $total = count($db->loadObjectList()); $query .= $use_limit === true ? " LIMIT " . (int) $limitstart . ", " . (int) $limit : ""; $db->setQuery($query); $categories = $db->loadObjectList(); if ($use_limit === true) { $limitstart = (int) $limitstart - (int) $limit; if ($limitstart < 0) { break; } } else { break; } } while (empty($categories)); if (!empty($categories)) { foreach ($categories as $item) { $category_tree = JeproshopCategoryModelCategory::getChildren((int) $item->category_id, $context->language->lang_id); $item->set_view = count($category_tree) ? 1 : 0; } } $this->pagination = new JPagination($total, $limitstart, $limit); return $categories; }
public function delete() { if (!JeproshopTools::isUnsignedInt($this->customer_thread_id)) { return false; } $return = true; $db = JFactory::getDBO(); $query = "SELECT " . $db->quoteNAme('customer_message_id') . " FROM " . $db->quoteName('#__jeproshop_customer_message') . " WHERE " . $db->quoteName('customer_thread_id') . " = " . (int) $this->customer_thread_id; $db->setQuery($query); $results = $db->loadObjectList(); if (count($results)) { foreach ($results as $result) { $message = new JeproshopCustomerMessageModelCustomerMessage((int) $result->customer_message_id); if (!JeproshopTools::isLoadedObject($message, 'customer_thread_id')) { $return = false; } else { $return &= $message->delete(); } } } $return &= parent::delete(); return $return; }
/** * Load class object using identifier in $_GET (if possible) * otherwise return an empty object, or die * * @param boolean $opt Return an empty object if load fail * @return object|boolean */ public function loadObject($opt = false) { $app = JFactory::getApplication(); $cart_id = (int) $app->input->get('cart_id'); if ($cart_id && JeproshopTools::isUnsignedInt($cart_id)) { if (!$this->cart) { $this->cart = new JeproshopCartModelCart($cart_id); } if (JeproshopTools::isLoadedObject($this->cart, 'cart_id')) { return $this->cart; } // throw exception $this->errors[] = Tools::displayError('The object cannot be loaded (or found)'); return false; } elseif ($opt) { if (!$this->cart) { $this->cart = new JeproshopCartModelCart(); } return true; } else { $this->errors[] = Tools::displayError('The object cannot be loaded (the identifier is missing or invalid)'); return false; } }
public static function getZoneId($country_id) { if (!JeproshopTools::isUnsignedInt($country_id)) { die(JError::raiseError()); } if (isset(self::$_zones_ids[$id_country])) { return self::$_idZones[$id_country]; } $db = JFactory::getDBO(); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT `id_zone` FROM `' . _DB_PREFIX_ . 'country` WHERE `id_country` = ' . (int) $id_country); self::$_idZones[$id_country] = $result['id_zone']; return $result['id_zone']; }
/** * Check if employee password is the right one * * @param int $employee_id * @param string $passwd Password * @return boolean result */ public static function checkPassword($employee_id, $passwd) { if (!JeproshopTools::isUnsignedInt($employee_id) || !JeproshopTools::isPasswd($passwd, 8)) { die(''); } return Db::getInstance()->getValue(' SELECT `id_employee` FROM `' . _DB_PREFIX_ . 'employee` WHERE `id_employee` = ' . (int) $employee_id . ' AND `passwd` = \'' . pSQL($passwd) . '\' AND active = 1'); }
private function validateSpecificPrice($shop_id, $currency_id, $country_id, $group_id, $customer_id, $price, $from_quantity, $reduction, $reduction_type, $from, $to, $product_attribute_id = 0) { $app = JFactory::getApplication(); $product_id = $app->input->get('product_id'); if (!JeproshopTools::isUnsignedInt($shop_id) || !JeproshopTools::isUnsignedInt($currency_id) || !JeproshopTools::isUnsignedInt($country_id) || !JeproshopTools::isUnsignedInt($group_id) || !JeproshopTools::isUnsignedInt($customer_id)) { $this->context->controller->has_errors = true; JError::raiseError(500, JText::_('Wrong IDs')); } elseif (!isset($price) && !isset($reduction) || isset($price) && !JeproshopTools::isNegativePrice($price) || isset($reduction) && !JeproshopTools::isPrice($reduction)) { $this->context->controller->has_errors = true; JError::raiseError(500, JText::_('Invalid price/discount amount')); } elseif (!JeproshopTools::isUnsignedInt($from_quantity)) { $this->context->controller->has_errors = true; JError::raiseError(500, JText::_('Invalid quantity')); } elseif ($reduction && !JeproshopTools::isReductionType($reduction_type)) { $this->context->controller->has_errors = true; JError::raiseError(500, JText::_('Please select a discount type (amount or percentage).')); } elseif ($from && $to && (!JeproshopTools::isDateFormat($from) || !Validate::isDateFormat($to))) { $this->context->controller->has_errors = true; JError::raiseError(500, JText::_('The from/to date is invalid.')); } elseif (JeproshopSpecificPriceMpdelSpecificPrice::exists((int) $product_id, $product_attribute_id, $shop_id, $group_id, $country_id, $currency_id, $customer_id, $from_quantity, $from, $to, false)) { $this->context->controller->has_errors = true; JError::raiseError(500, JText::_('A specific price already exists for these parameters.')); } else { return true; } return false; }
public function initOrderDetails() { $this->context->controller->init(); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); //$this->initContent(); $app = JFactory::getApplication(); $order_id = $app->input->get('order_id'); if (!$order_id || !JeproshopTools::isUnsignedInt($order_id)) { $this->errors[] = Tools::displayError('Order ID required'); } else { $order = new JeproshopOrderModelOrder($order_id); if (JeproshopTools::isLoadedObject($order, 'order_id') && $order->customer_id == $this->context->customer->customer_id) { $order_status_id = (int) $order->getCurrentState(); $carrier = new JeproshopCarrierModelCarrier((int) $order->carrier_id, (int) $order->lang_id); $invoiceAddress = new JeproshopAddressModelAddress((int) $order->address_invoice_id); $deliveryAddress = new JeproshopAddressModelAddress((int) $order->address_delivery_id); $invoice_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($invoiceAddress->country_id); $delivery_address_fields = JeproshopAddressFormatModelAddressFormat::getOrderedAddressFields($deliveryAddress->country_id); $invoiceAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($invoiceAddress, $invoice_address_fields); $deliveryAddressFormatValues = JeproshopAddressFormatModelAddressFormat::getFormattedAddressFieldsValues($deliveryAddress, $delivery_address_fields); if ($order->total_discounts > 0) { $oldTotal = (double) ($order->total_paid - $order->total_discounts); $this->assignRef('old_total', $oldTotal); } $products = $order->getProducts(); /* DEPRECATED: customizedDatas @since 1.5 */ $customizedDatas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $order->cart_id); JeproshopProductModelProduct::addCustomizationPrice($products, $customizedDatas); JeproshopOrderReturnModelOrderReturn::addReturnedQuantity($products, $order->order_id); $customer = new JeproshopCustomerModelCustomer($order->customer_id); $this->assignRef('order', $order); $isReturnable = (int) $order->isReturnable(); $this->assignRef('return_allowed', $isReturnable); $this->assignRef('currency', new JeproshopCurrencyModelCurrency($order->currency_id)); $order_status_id = (int) $order_status_id; $this->assignRef('order_status_id', $order_status_id); $invoiceAllowed = (int) JeproshopSettingModelSetting::getValue('invoice_allowed'); $this->assignRef('invoice_allowed', $invoiceAllowed); $invoice = JeproshopOrderStatusModelOrderStatus::invoiceAvailable($order_status_id) && count($order->getInvoicesCollection()); $this->assignRef('invoice', $invoice); $this->assignRef('order_history', $order->getHistory($this->context->language->lang_id, false, true)); $this->assignRef('products', $products); $this->assignRef('discounts', $order->getCartRules()); $this->assignRef('carrier', $carrier); $this->assignRef('invoice_address', $invoiceAddress); $this->assignRef('invoice_status', JeproshopTools::isLoadedObject($invoiceAddress, 'address_id') && $invoiceAddress->state_id ? new JeproshopStatusModelStatus($invoiceAddress->state_id) : false); $this->assignRef('delivery_address', $deliveryAddress); $this->assignRef('invoice_address_fields', $invoice_address_fields); $this->assignRef('delivery_address_fields', $delivery_address_fields); $this->assignRef('invoice_address_format_values', $invoiceAddressFormatValues); $this->assignRef('delivery_address_format_values', $deliveryAddressFormatValues); $this->assignRef('delivery_status', JeproshopTools::isLoadedObject($deliveryAddress, 'address_id') && $deliveryAddress->state_id ? new JeproshopStatusModelStatus($deliveryAddress->state_id) : false); $this->assignRef('messages', JeproshopCustomerMessageModelCustomerMessage::getMessagesByOrderId((int) $order->order_id, false)); $files = JeproshopProductModelProduct::CUSTOMIZE_FILE; $this->assignRef('CUSTOMIZE_FILE', $files); $text_fields = JeproshopProductModelProduct::CUSTOMIZE_TEXT_FIELD; $this->assignRef('CUSTOMIZE_TEXT_FIELD', $text_fields); //$this->assignRef('isRecyclable', JeproshopSettingModelSetting::getValue('PS_RECYCLABLE_PACK')); $this->assignRef('use_tax', JeproshopSettingModelSetting::getValue('use_tax')); $group_use_tax = JeproshopGroupModelGroup::getPriceDisplayMethod($customer->default_group_id) == COM_JEPROSHOP_TAX_INCLUDED; $this->assignRef('group_use_tax', $group_use_tax); $this->assignRef('display_price', JeproshopSettingModelSetting::getValue('display_price')); /* DEPRECATED: customizedDatas @since 1.5 */ $this->assignRef('customizedDatas', $customizedDatas); $reordering_allowed = (int) JeproshopSettingModelSetting::getValue('enable_history_reordering'); $this->assignRef('reordering_allowed', $reordering_allowed); /* $this->context->smarty->assign(array( 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->state_id) ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXT_FIELD' => Product::CUSTOMIZE_TEXT_FIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => (Group::getPriceDisplayMethod($customer->default_group_id) == PS_TAX_INC), /* DEPRECATED: customizedDatas @since 1.5 * / 'customizedDatas' => $customizedDatas, /* DEPRECATED: customizedDatas @since 1.5 * / )); */ if ($carrier->url && $order->shipping_number) { $this->assignRef('followup', str_replace('@', $order->shipping_number, $carrier->url)); } /* $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order))); Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order)); */ unset($carrier, $addressInvoice, $addressDelivery); } else { $this->errors[] = Tools::displayError('This order cannot be found.'); } unset($order); } //$this->setTemplate(_PS_THEME_DIR_.'order-detail.tpl'); }
/** * Load class object using identifier in $_GET (if possible) * otherwise return an empty object, or die * * @param boolean $opt Return an empty object if load fail * @return object|boolean */ public function loadObject($opt = false) { /*if (!isset($this->customer) || empty($this->customer)) return true; */ $app = JFactory::getApplication(); $customer_id = (int) $app->input->get('customer_id'); if ($customer_id && JeproshopTools::isUnsignedInt($customer_id)) { if (!$this->customer) { $this->customer = new JeproshopCustomerModelCustomer($customer_id); } if (JeproshopTools::isLoadedObject($this->customer, 'customer_id')) { return $this->customer; } // throw exception //$this->errors[] = Tools::displayError('The object cannot be loaded (or found)'); return false; } elseif ($opt) { if (!$this->customer) { $this->customer = new JeproshopCustomerModelCustomer(); } return $this->customer; } else { $this->errors[] = Tools::displayError('The object cannot be loaded (the identifier is missing or invalid)'); return false; } }
/** * Change language in cookie while clicking on a flag * * @param null $cookie * @return string iso code */ public static function setCookieLanguage($cookie = null) { if (!$cookie) { $cookie = JeproshopContext::getContext()->cookie; } /* If language does not exist or is disabled, erase it */ if ($cookie->lang_id) { $lang = new JeproshopLanguageModelLanguage((int) $cookie->lang_id); if (!JeproshopTools::isLoadedObject($lang, 'lang_id') || !$lang->published || !$lang->isAssociatedToShop()) { $cookie->lang_id = null; } } /* Automatically detect language if not already defined, detect_language is set in Cookie::update **/ if ((!$cookie->lang_id || isset($cookie->detect_language)) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $array = explode(',', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])); $string = $array[0]; if (JeproshopTools::isLanguageCode($string)) { $lang = JeproshopLanguageModelLanguage::getLanguageByIETFCode($string); if (JeproshopTools::isLoadedObject($lang, 'lang_id') && $lang->published && $lang->isAssociatedToShop()) { JeproshopContext::getContext()->language = $lang; $cookie->lang_id = (int) $lang->lang_id; } } } if (isset($cookie->detect_language)) { unset($cookie->detect_language); } /* If language file not present, you must use default language file **/ if (!$cookie->lang_id || !JeproshopTools::isUnsignedInt($cookie->lang_id)) { $cookie->lang_id = (int) JeproshopSettingModelSetting::getValue('default_lang'); } $iso = JeproshopLanguageModelLanguage::getIsoById((int) $cookie->lang_id); //@include_once(_PS_THEME_DIR_.'lang/'.$iso.'.php'); return $iso; }
protected function loadObject($option = false) { $app = JFactory::getApplication(); $product_id = $app->input->get('product_id'); $isLoaded = false; $context = JeproshopContext::getContext(); if ($product_id && JeproshopTools::isUnsignedInt($product_id)) { if (!$this->product) { $this->product = new JeproshopProductModelProduct($product_id, false, $context->language->lang_id); } if (!JeproshopTools::isLoadedObject($this->product, 'product_id')) { JError::raiseError(500, JText::_('COM_JEPROSHOP_PRODUCT_NOT_FOUND_MESSAGE')); $isLoaded = false; } else { $isLoaded = true; } } elseif ($option) { if (!$this->product) { $this->product = new JeproshopProductModelProduct(); } } else { JError::raiseError(500, JText::_('COM_JEPROSHOP_PRODUCT_DOES_NOT_EXIST_MESSAGE')); $isLoaded = false; } //specified if ($isLoaded && JeproshopTools::isLoadedObject($this->product, 'product_id')) { if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP && JeproshopShopModelShop::isFeaturePublished() && !$this->product->isAssociatedToShop()) { $this->product = new JeproshopProductModelProduct((int) $this->product->product_id, false, $context->language->lang_id, (int) $this->product->default_shop_id); } $this->product->loadStockData(); } return $isLoaded; }
/** * Load class supplier using identifier in $_GET (if possible) * otherwise return an empty supplier, or die * * @param boolean $opt Return an empty supplier if load fail * @return supplier|boolean */ public function loadTaxRuleGroup($opt = false) { $app = JFactory::getApplication(); $tax_rules_group_id = (int) $app->input->get('tax_rules_group_id'); if ($tax_rules_group_id && JeproshopTools::isUnsignedInt($tax_rules_group_id)) { if (!$this->tax_rules_group) { $this->tax_rules_group = new JeproshopTaxRulesGroupModelTaxRulesGroup($tax_rules_group_id); } if (JeproshopTools::isLoadedObject($this->tax_rules_group, 'tax_rules_group_id')) { return true; } // throw exception JError::raiseError(500, 'The tax rules group cannot be loaded (or not found)'); return false; } elseif ($opt) { if (!$this->tax_rules_group) { $this->tax_rules_group = new JeproshopTaxRulesGroupModelTaxRulesGroup(); } return true; } else { $this->context->controller->has_errors = true; JError::raiseError(500, 'The tax cannot be loaded (the identifier is missing or invalid)'); return false; } }
/** * Get product price * * @param integer $product_id Product id * @param boolean $use_tax With taxes or not (optional) * @param integer $product_attribute_id Product attribute id (optional). * If set to false, do not apply the combination price impact. NULL does apply the default combination price impact. * @param integer $decimals Number of decimals (optional) * @param boolean $only_reduction Returns only the reduction amount * @param boolean $use_reduction Set if the returned amount will include reduction * @param integer $quantity Required for quantity discount application (default value: 1) * @param integer $customer_id Customer ID (for customer group reduction) * @param integer $cart_id Cart ID. Required when the cookie is not accessible (e.g., inside a payment module, a cron task...) * @param integer $address_id Customer address ID. Required for price (tax included) calculation regarding the guest localization * @param null $specific_price_output * @param boolean $with_ecotax insert ecotax in price output. * @param bool $use_group_reduction * @param JeproshopContext $context * @param bool $use_customer_price * @internal param int $divisor Useful when paying many time without fees (optional) * @internal param \variable_reference $specificPriceOutput . * If a specific price applies regarding the previous parameters, this variable is filled with the corresponding SpecificPrice object * @return float Product price */ public static function getStaticPrice($product_id, $use_tax = true, $product_attribute_id = null, $decimals = 6, $only_reduction = false, $use_reduction = true, $quantity = 1, $customer_id = null, $cart_id = null, $address_id = null, $specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, JeproshopContext $context = null, $use_customer_price = true) { if (!$context) { $context = JeproshopContext::getContext(); } $cur_cart = $context->cart; if (!JeproshopTools::isBool($use_tax) || !JeproshopTools::isUnsignedInt($product_id)) { //die(Tools::displayError()); } // Initializations $group_id = (int) JeproshopGroupModelGroup::getCurrent()->group_id; // If there is cart in context or if the specified id_cart is different from the context cart id if (!is_object($cur_cart) || JeproshopTools::isUnsignedInt($cart_id) && $cart_id && $cur_cart->cart_id != $cart_id) { /* * When a user (e.g., guest, customer, Google...) is on Jeproshop, he has already its cart as the global (see /init.php) * When a non-user calls directly this method (e.g., payment module...) is on JeproShop, he does not have already it BUT knows the cart ID * When called from the back office, cart ID can be inexistant */ if (!$cart_id && !isset($context->employee)) { JError::raiseError(500, __FILE__ . ' ' . __LINE__); } $cur_cart = new JeproshopCartModelCart($cart_id); // Store cart in context to avoid multiple instantiations in BO if (!JeproshopTools::isLoadedObject($context->cart, 'cart_id')) { $context->cart = $cur_cart; } } $db = JFactory::getDBO(); $cart_quantity = 0; if ((int) $cart_id) { $cache_id = 'jeproshop_product_model_get_price_static_' . (int) $product_id . '_' . (int) $cart_id; $cart_qty = JeproshopCache::retrieve($cache_id); if (!JeproshopCache::isStored($cache_id) || $cart_qty != (int) $quantity) { $query = "SELECT SUM(" . $db->quoteName('quantity') . ") FROM " . $db->quoteName('#__jeproshop_cart_product'); $query .= " WHERE " . $db->quoteName('product_id') . " = " . (int) $product_id . " AND " . $db->quoteName('cart_id'); $query .= " = " . (int) $cart_id; $db->setQuery($query); $cart_quantity = (int) $db->loadResult(); JeproshopCache::store($cache_id, $cart_quantity); } $cart_quantity = JeproshopCache::retrieve($cache_id); } $currency_id = (int) JeproshopTools::isLoadedObject($context->currency, 'currency_id') ? $context->currency->currency_id : JeproshopSettingModelSetting::getValue('default_currency'); // retrieve address information $country_id = (int) $context->country->country_id; $state_id = 0; $zipcode = 0; if (!$address_id && JeproshopTools::isLoadedObject($cur_cart, 'cart_id')) { $address_id = $cur_cart->{JeproshopSettingModelSetting::getValue('tax_address_type')}; } if ($address_id) { $address_info = JeproshopAddressModelAddress::getCountryAndState($address_id); if ($address_info->country_id) { $country_id = (int) $address_info->country_id; $state_id = (int) $address_info->state_id; $zipcode = $address_info->postcode; } } else { if (isset($context->customer->geoloc_country_id)) { $country_id = (int) $context->customer->geoloc_country_id; $state_id = (int) $context->customer->state_id; $zipcode = (int) $context->customer->postcode; } } if (JeproshopTaxModelTax::taxExcludedOption()) { $use_tax = false; } if ($use_tax != false && !empty($address_info->vat_number) && $address_info->country_id != JeproshopSettingModelSetting::getValue('vat_number_country') && JeproshopSettingModelSetting::getValue('vat_number_management')) { $use_tax = false; } if (is_null($customer_id) && JeproshopTools::isLoadedObject($context->customer, 'customer_id')) { $customer_id = $context->customer->customer_id; } return JeproshopProductModelProduct::priceCalculation($context->shop->shop_id, $product_id, $product_attribute_id, $country_id, $state_id, $zipcode, $currency_id, $group_id, $quantity, $use_tax, $decimals, $only_reduction, $use_reduction, $with_ecotax, $specific_price_output, $use_group_reduction, $customer_id, $use_customer_price, $cart_id, $cart_quantity); }
public static function getProducts($lang_id, $limit_start, $limit, $order_by = null, $order_way = null, $get_total = false, $published = true, $random = false, $random_number_products = 1, $check_access = true, JeproshopContext $context = null) { if (!$context) { $context = JeproshopContext::getContext(); } $db = JFactory::getDBO(); $app = JFactory::getApplication(); jimport('joomla.html.pagination'); //if ($check_access && !$context->controller->checkAccess($context->customer->customer_id, $category_id)){ return false; } if ($limit_start < 1) { $limit_start = 0; } if (empty($order_by)) { $order_by = 'position'; } else { /* Fix for all modules which are now using lowercase values for 'orderBy' parameter */ $order_by = strtolower($order_by); } if (empty($order_way)) { $order_way = "DESC"; } $order_by_prefix = false; if ($order_by == 'product_id' || $order_by == 'date_add' || $order_by == 'date_upd') { $order_by_prefix = "product"; } elseif ($order_by == 'name') { $order_by_prefix = "product_lang"; } elseif ($order_by == 'manufacturer') { $order_by_prefix = "manufacturer"; $order_by = "name"; } elseif ($order_by == 'position') { $order_by_prefix = "product"; } if ($order_by == 'price') { $order_by = 'order_price'; } if (!JeproshopTools::isOrderBy($order_by) || !JeproshopTools::isOrderWay($order_way)) { die(JError::raiseError()); } $supplier_id = (int) $app->input->get('supplier_id'); /* Return only the number of products */ $query = "SELECT COUNT(product." . $db->quoteName('product_id') . ") AS total FROM " . $db->quoteName('#__jeproshop_product') . " AS product "; $query .= JeproshopShopModelShop::addSqlAssociation('product') . " WHERE product_shop." . $db->quoteName('visibility') . " IN ('both', 'catalog')"; $query .= " AND product_shop." . $db->quoteName('published') . " = 1 " . ($supplier_id ? " AND product.supplier_id = " . (int) $supplier_id : ""); $db->setQuery($query); $total = (int) $db->loadResult(); $number_days_new_product = JeproshopSettingModelSetting::getValue('number_days_new_product'); $query = "SELECT product.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.product_attribute_id) AS "; $query .= "product_attribute_id, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, product_lang." . $db->quoteName('description'); $query .= ", product_lang." . $db->quoteName('short_description') . ", product_lang." . $db->quoteName('available_now') . ", product_lang." . $db->quoteName('available_later'); $query .= ", product_lang." . $db->quoteName('link_rewrite') . ", product_lang." . $db->quoteName('meta_description') . ", product_lang." . $db->quoteName('meta_keywords'); $query .= ", product_lang." . $db->quoteName('meta_title') . ", product_lang." . $db->quoteName('name') . ", MAX(image_shop." . $db->quoteName('image_id') . " ) AS "; $query .= "image_id, image_lang." . $db->quoteName('legend') . ", manufacturer." . $db->quoteName('name') . " AS manufacturer_name, DATEDIFF(product_shop." . $db->quoteName('date_add'); $query .= ", DATE_SUB(NOW(), INTERVAL " . (JeproshopTools::isUnsignedInt($number_days_new_product) ? $number_days_new_product : 20) . "\tDAY)) > 0 AS new, product_shop.price AS"; $query .= " order_price FROM " . $db->quoteName('#__jeproshop_product') . " AS product " . JeproshopShopModelShop::addSqlAssociation('product') . " LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_product_attribute') . " AS product_attribute ON (product." . $db->quoteName('product_id') . " = product_attribute." . $db->quoteName('product_id'); $query .= ") " . JeproshopShopModelShop::addSqlAssociation('product_attribute', false, 'product_attribute_shop.`default_on` = 1'); $query .= JeproshopProductModelProduct::sqlStock('product', 'product_attribute_shop', false, $context->shop) . " LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang'); $query .= " AS product_lang ON (product." . $db->quoteName('product_id') . " = product_lang." . $db->quoteName('product_id') . " AND product_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . JeproshopShopModelShop::addSqlRestrictionOnLang('product_lang'); $query .= ") LEFT JOIN " . $db->quoteName('#__jeproshop_image') . " AS image ON (image." . $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . ") " . JeproshopShopModelShop::addSqlAssociation('image', false, 'image_shop.cover=1') . " LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_image_lang') . " AS image_lang ON (image_shop." . $db->quoteName('image_id') . " = image_lang." . $db->quoteName('image_id') . " AND image_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_manufacturer') . " AS manufacturer ON manufacturer." . $db->quoteName('manufacturer_id') . " = product." . $db->quoteName('manufacturer_id') . "\tWHERE product_shop." . $db->quoteName('shop_id') . " = " . (int) $context->shop->shop_id; $query .= " AND product_shop." . $db->quoteName('published') . " = 1 AND product_shop." . $db->quoteName('visibility') . " IN ('both', 'catalog') "; $query .= ($supplier_id ? " AND product.supplier_id = " . (int) $supplier_id : "") . " GROUP BY product_shop.product_id"; if ($random === true) { $query .= " ORDER BY RAND() LIMIT " . (int) $random_number_products; } else { //$query .= " ORDER BY " . (!empty($order_by_prefix) ? $order_by_prefix. "." : "") . $db->quoteName($order_by); $query .= " " . $order_way . " LIMIT " . (int) $limit_start . ", " . (int) $limit; } $db->setQuery($query); $result = $db->loadObjectList(); if ($order_by == 'order_price') { JeproshopTools::orderbyPrice($result, $order_way); } if (!$result) { return array(); } self::$_pagination = new JPagination($total, $limit_start, $limit); /* Modify SQL result */ return JeproshopProductModelProduct::getProductsProperties($lang_id, $result); }
/** * Add several tags in database and link it to a product * * @param integer $lang_id Language id * @param integer $product_id Product id to link tags with * @param string|array $tag_list List of tags, as array or as a string with comas * @param string $separator * @return bool Operation success */ public static function addTags($lang_id, $product_id, $tag_list, $separator = ',') { $db = JFactory::getDBO(); if (!JeproshopTools::isUnsignedInt($lang_id)) { return false; } if (!is_array($tag_list)) { $tag_list = array_filter(array_unique(array_map('trim', preg_split('#\\' . $separator . '#', $tag_list, null, PREG_SPLIT_NO_EMPTY)))); } $list = array(); if (is_array($tag_list)) { foreach ($tag_list as $tag) { if (!JeproshopTools::isGenericName($tag)) { return false; } $tag = trim(substr($tag, 0, 32)); $tag_obj = new JeproshopTagModelTag(null, $tag, (int) $lang_id); /* Tag does not exist in database */ if (!JeproshopTools::isLoadedObject($tag_obj, 'tag_id')) { $tag_obj->name = $tag; $tag_obj->lang_id = (int) $lang_id; $tag_obj->add(); } if (!in_array($tag_obj->tag_id, $list)) { $list[] = $tag_obj->tag_id; } } } $data = ''; $result = true; foreach ($list as $tag_id) { $query = "INSERT INTO " . $db->quoteName('#__jeproshop_product_tag') . " ( " . $db->quoteName('tag_id') . ", "; $query .= $db->quoteName('product_id') . ") VALUES (" . (int) $tag_id . ", " . (int) $product_id . ")"; $db->setQuery($query); $result &= $db->query(); } return $result; }
/** * For a given product, tells if it depends on the physical (usable) stock * * @param int $product_id * @param int $shop_id Optional : gets context if null @see Context::getContext() * @return bool : depends on stock @see $depends_on_stock */ public static function dependsOnStock($product_id, $shop_id = null) { if (!JeproshopTools::isUnsignedInt($product_id)) { return false; } $db = JFactory::getDBO(); $query = "SELECT depends_on_stock FROM " . $db->quoteName('#__jeproshop_stock_available') . " WHERE product_id = " . (int) $product_id; $query .= " AND product_attribute_id = 0 " . JeproshopStockAvailableModelStockAvailable::addShopRestriction($shop_id); $db->setQuery($query); return $db->loadResult(); }
public function loadObject($option = false) { $app = JFactory::getApplication(); $carrier_id = $app->input->get('carrier_id'); if ($carrier_id && JeproshopTools::isUnsignedInt($carrier_id)) { if (!$this->carrier) { $this->carrier = new JeproshopCarrierModelcarrier($carrier_id); } if (JeproshopTools::isLoadedObject($this->carrier, 'carrier_id')) { return true; } return false; } elseif ($option) { if (!$this->carrier) { $this->carrier = new JeproshopCarrierModelCarrier(); } return true; } else { return false; } }
/** * Load class supplier using identifier in $_GET (if possible) * otherwise return an empty supplier, or die * * @param boolean $opt Return an empty supplier if load fail * @return supplier|boolean */ public function loadObject($opt = false) { $app = JFactory::getApplication(); $manufacturer_id = (int) $app->input->get('manufacturer_id'); if ($manufacturer_id && JeproshopTools::isUnsignedInt($manufacturer_id)) { if (!$this->manufacturer) { $this->manufacturer = new JeproshopManufacturerModelManufacturer($manufacturer_id); } if (JeproshopTools::isLoadedObject($this->manufacturer, 'manufacturer_id')) { return $this->manufacturer; } // throw exception JError::raiseError(500, 'The manufacturer cannot be loaded (or found)'); return false; } elseif ($opt) { if (!$this->manufacturer) { $this->manufacturer = new JeproshopManufacturerModelManufacturer(); } return $this->manufacturer; } else { $this->errors[] = Tools::displayError('The manufacturer cannot be loaded (the identifier is missing or invalid)'); return false; } }
public static function geZoneId($state_id) { if (!JeproshopTools::isUnsignedInt($state_id)) { die(JError::raiseError()); } $db = Jfactory::getDBO(); $query = "SELECT " . $db->quoteName('zone_id') . " FROM " . $db->quoteName('#__jeproshop_state') . " WHERE " . $db->quoteName('state_id') . " = " . (int) $state_id; $db->setQuery($query); return $db->loadResult(); }