Esempio n. 1
0
 public function renderDetails($tpl = null)
 {
     if ($this->getLayout() != 'modal') {
         $this->addToolBar();
         $this->sideBar = JHtmlSidebar::render();
     }
     $unidentified = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('unidentified_group'));
     $guest = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('guest_group'));
     $default = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('customer_group'));
     /*
     		$unidentified_group_information = sprintf(
     				/*$this->l('%s - All persons without a customer account or customers that are not logged in.'),
     				'<b>'.$unidentified->name[$this->context->language->id].'</b>' * /
     		);
     		$guest_group_information = sprintf(
     				/*$this->l('%s - All persons who placed an order through Guest Checkout.'),
     				'<b>'.$guest->name[$this->context->language->id].'</b>' * /
     		);
     		$default_group_information = sprintf(
     				/*$this->l('%s - All persons who created an account on this site.'),
     				'<b>'.$default->name[$this->context->language->id].'</b>' */
     //);
     $groupModel = new JeproshopGroupModelGroup();
     $groups = $groupModel->getGroupList();
     $this->assignRef('groups', $groups);
     /*$this->displayInformation($this->l('PrestaShop has three default customer groups:'));
     		$this->displayInformation($unidentified_group_information);
     		$this->displayInformation($guest_group_information);
     		$this->displayInformation($default_group_information); */
     parent::display($tpl);
 }
Esempio n. 2
0
 public function renderEditForm($tpl = null)
 {
     $helper = new JeproshopHelper();
     $this->assignRef('helper', $helper);
     $tax_rules_groups = JeproshopTaxRulesGroupModelTaxRulesGroup::getTaxRulesGroups(true);
     $this->assignRef('tax_rules_groups', $tax_rules_groups);
     $carrier_logo = JeproshopTools::isLoadedObject($this->carrier, 'carrier_id') && file_exists(COM_JEPROSHOP_CARRIER_IMAGE_DIR . $this->carrier->carrier_id . '.jpg') ? COM_JEPROSHOP_CARRIER_IMAGE_DIR . $this->carrier->carrier_id . '.jpg' : false;
     $this->assignRef('carrier_logo', $carrier_logo);
     $groups = JeproshopGroupModelGroup::getGroups(JeproshopContext::getContext()->language->lang_id);
     $this->assignRef('groups', $groups);
     $zones = JeproshopZoneModelZone::getZones();
     $this->assignRef('zones', $zones);
     $carrierZones = $this->carrier->getZones();
     $carrier_zones_ids = array();
     if (is_array($carrierZones)) {
         foreach ($carrierZones as $carrier_zone) {
             $carrier_zones_ids[] = $carrier_zone->zone_id;
         }
     }
     $this->assignRef('selected_zones', $carrier_zones_ids);
     if ($this->getLayout() != 'modal') {
         $this->addToolBar();
         $this->sideBar = JHtmlSidebar::render();
     }
     parent::display($tpl);
 }
Esempio n. 3
0
 public function renderEditForm($tpl = null)
 {
     if ($this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     $groups = JeproshopGroupModelGroup::getGroups($this->context->language->lang_id, true);
     $this->assignRef('groups', $groups);
     $this->helper = new JeproshopHelper();
     $this->addToolBar();
     $this->sideBar = JHtmlSidebar::render();
     parent::display($tpl);
 }
Esempio n. 4
0
 /**
  * Return suppliers
  *
  * @param bool $get_nb_products
  * @param int $lang_id
  * @param bool $published
  * @param bool $p
  * @param bool $n
  * @param bool $all_groups
  * @return array Suppliers
  */
 public static function getSuppliers($get_nb_products = false, $lang_id = 0, $published = true, $p = false, $n = false, $all_groups = false)
 {
     if (!$lang_id) {
         $lang_id = JeproshopSettingModelSetting::getValue('default_lang');
     }
     if (!JeproshopGroupModelGroup::isFeatureActive()) {
         $all_groups = true;
     }
     $db = JFactory::getDBO();
     $query = "SELECT supplier.*, supplier_lang." . $db->quoteName('description') . " FROM " . $db->quoteName('#__jeproshop_supplier') . " AS supplier LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_supplier_lang') . " AS supplier_lang ON (supplier." . $db->quoteName('supplier_id') . " = supplier_lang.";
     $query .= $db->quoteName('supplier_id') . " AND supplier_lang." . $db->quoteName('supplier_id') . " = " . (int) $lang_id;
     $query .= JeproshopShopModelShop::addSqlAssociation('supplier') . ")" . ($published ? " WHERE supplier." . $db->quoteName('published') . " = 1" : "") . " ORDER BY supplier.";
     $query .= $db->quoteName('name') . " ASC " . ($n && $p ? "LIMIT " . $n . ", " . ($p - 1) * $n : "");
     $db->setQuery($query);
     $suppliers = $db->loadObjectList();
     if ($suppliers === false) {
         return false;
     }
     if ($get_nb_products) {
         $sql_groups = '';
         if (!$all_groups) {
             $groups = FrontController::getCurrentCustomerGroups();
             $sql_groups = count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1';
         }
         foreach ($suppliers as $key => $supplier) {
             $query = "SELECT DISTINCT(product_supplier." . $db->quoteName('product_id') . ") FROM " . $db->quoteName('#__jeproshop_product_supplier') . " AS product_supplier ";
             $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_product') . " AS product ON (product_supplier." . $db->quoteName('product_id') . " = product.";
             $query .= $db->quoteName('supplier_id') . ") " . JeproshopShopModelShop::addSqlAssociation('product') . " WHERE product_supplier." . $db->quoteName('supplier_id');
             $query .= " = " . (int) $supplier->supplier_id . " AND product_supplier.product_attribute_id = 0 " . ($published ? "AND product_supplier." . $db->quoteName('published') . " = 1" : "");
             $query .= " AND product_shop." . $db->quoteName('visibility') . " NOT IN (\"none\") " . ($all_groups ? "" : " AND product_supplier." . $db->quoteName('product_id') . " IN (SELECT category_product." . $db->quoteName('product_id') . " FROM " . $db->quoteName('#__jeproshop_category_group') . " AS category_group LEFT JOIN " . $db->quoteName('#__jeproshop_category_product') . "  AS category_group ON (category_group." . $db->quoteName('category_id') . " = category_product." . $db->quoteName('category_id') . ") WHERE category_group." . $db->quoteName('group_id') . $sql_groups . ")");
             $db->setQuery($query);
             $result = $db->loadObjectList();
             $suppliers[$key]['nb_products'] = count($result);
         }
     }
     $nb_suppliers = count($suppliers);
     $rewrite_settings = (int) JeproshopSettingModelSetting::getValue('rewrite_settings');
     for ($i = 0; $i < $nb_suppliers; $i++) {
         $suppliers[$i]['link_rewrite'] = $rewrite_settings ? JeproshopTools::link_rewrite($suppliers[$i]['name']) : 0;
     }
     return $suppliers;
 }
Esempio n. 5
0
 public function display($tpl = null)
 {
     if (!isset($this->context) && $this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     /*if($this->context->controller->isInitialized()){*/
     $this->init();
     //}
     if (!$this->customer_access) {
         return;
     }
     if (isset($this->context->cookie->compare_id)) {
         $this->assignRef('compare_products', JeproshopCompareProductModelCompareProduct::getCompareProducts((int) $this->context->cookie->compare_id));
     }
     $this->assignScenes();
     $this->sortProducts();
     $subCategories = $this->category->getSubCategories($this->context->language->lang_id);
     if (count($subCategories)) {
         $this->assignRef('sub_categories', $subCategories);
         $this->assignRef('sub_categories_total', count($subCategories));
         $this->assignRef('sub_categories_half', ceil(count($subCategories) / 2));
     }
     $this->assignProducts();
     $catalog_mode = (bool) (JeproshopSettingModelSetting::getValue('catalog_mode') || !JeproshopGroupModelGroup::getCurrent()->show_prices);
     $this->assignRef('catalog_mode', $catalog_mode);
     $this->assignRef('allow_out_of_stock_ordering', JeproshopSettingModelSetting::getValue('allow_out_of_stock_ordering'));
     $comparator_max_item = (int) JeproshopSettingModelSetting::getValue('comparator_max_item');
     $this->assignRef('comparator_max_item', $comparator_max_item);
     $compared_products = array();
     if (JeproshopSettingModelSetting::getValue('comparator_max_item') && isset($this->context->cookie->compare_id)) {
         $compared_products = JeproshopProductCompareModelProductCompare::getCompareProducts($this->context->cookie->compare_id);
     }
     $this->assignRef('compared_products', is_array($compared_products) ? $compared_products : array());
     $this->assignRef('display_price', JeproshopSettingModelSetting::getValue('display_price'));
     parent::display($tpl);
 }
Esempio n. 6
0
 public function __construct($cart_id = null)
 {
     $db = JFactory::getDBO();
     /*$this->def = ObjectModel::getDefinition($this);
     		$this->setDefinitionRetroCompatibility();
     
     		if ($id_lang !== null)
     			$this->id_lang = (Language::getLanguage($id_lang) !== false) ? $id_lang : Configuration::get('PS_LANG_DEFAULT');
     
     		if ($id_shop && $this->isMultishop())
     		{
     			$this->id_shop = (int)$id_shop;
     			$this->get_shop_from_context = false;
     		} */
     if ($this->isMultishop() && !$this->shop_id) {
         $this->shop_id = JeproshopContext::getContext()->shop->shop_id;
     }
     if ($cart_id) {
         // Load object from database if object id is present
         $cache_id = 'jeproshop_model_cart_' . (int) $cart_id . '_' . (int) $this->shop_id;
         if (!JeproshopCache::isStored($cache_id)) {
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_cart') . " AS cart WHERE cart.cart_id = " . (int) $cart_id;
             // Get lang informations
             /*if ($id_lang)
             		{
             			$sql->leftJoin($this->def['table'].'_lang', 'b', 'a.'.$this->def['primary'].' = b.'.$this->def['primary'].' AND b.id_lang = '.(int)$id_lang);
             			if ($this->id_shop && !empty($this->def['multilang_shop']))
             				$sql->where('b.id_shop = '.$this->id_shop);
             		} */
             // Get shop informations
             if (JeproshopShopModelShop::isTableAssociated('cart')) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_cart_shop') . " AS cart_shop ON(cart.cart_id =";
                 $query .= " = cart_shop.cart_id AND cart_shop.shop_id = " . (int) $this->shop_id . ")";
             }
             $db->setQuery($query);
             $cart_data = $db->loadObject();
             if ($cart_data) {
                 /*if (!$id_lang && isset($this->def['multilang']) && $this->def['multilang'])
                 		{
                 			$sql = 'SELECT * FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_lang`
                 					WHERE `'.bqSQL($this->def['primary']).'` = '.(int)$id
                 					.(($this->id_shop && $this->isLangMultishop()) ? ' AND `id_shop` = '.$this->id_shop : '');
                 			if ($object_datas_lang = ObjectModel::$db->executeS($sql))
                 				foreach ($object_datas_lang as $row)
                 					foreach ($row as $key => $value)
                 					{
                 						if (array_key_exists($key, $this) && $key != $this->def['primary'])
                 						{
                 							if (!isset($object_datas[$key]) || !is_array($object_datas[$key]))
                 								$object_datas[$key] = array();
                 							$object_datas[$key][$row['id_lang']] = $value;
                 						}
                 					}
                 		} */
                 JeproshopCache::store($cache_id, $cart_data);
             }
         } else {
             $cart_data = JeproshopCache::retrieve($cache_id);
         }
         if ($cart_data) {
             $this->cart_id = (int) $cart_id;
             foreach ($cart_data as $key => $value) {
                 if (array_key_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     /*
     if (!is_null($id_lang))
     	$this->id_lang = (int)(Language::getLanguage($id_lang) !== false) ? $id_lang : Configuration::get('PS_LANG_DEFAULT');
     */
     if ($this->customer_id) {
         if (isset(JeproshopContext::getContext()->customer) && JeproshopContext::getContext()->customer->customer_id == $this->customer_id) {
             $customer = JeproshopContext::getContext()->customer;
         } else {
             $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id);
         }
         if ((!$this->secure_key || $this->secure_key == '-1') && $customer->secure_key) {
             $this->secure_key = $customer->secure_key;
             $this->save();
         }
     }
     $this->_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id);
 }
Esempio n. 7
0
 private function initContent()
 {
     $order_process_type = (bool) JeproshopSettingModelSetting::getValue('order_process_type');
     $this->assignRef('order_process_type', $order_process_type);
     $isGuest = false;
     $this->assignRef('is_guest', $isGuest);
     $catalog_mode = (bool) (JeproshopSettingModelSetting::getValue('catalog_mode') || !JeproshopGroupModelGroup::getCurrent()->show_prices);
     $this->assignRef('catalog_mode', $catalog_mode);
 }
Esempio n. 8
0
 public function __construct($order_id = null, $lang_id = null)
 {
     //parent::__construct();
     $db = JFactory::getDBO();
     if ($lang_id !== NULL) {
         $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang');
     }
     if ($this->isMultiShop() && !$this->shop_id) {
         $this->shop_id = JeproshopContext::getContext()->shop->shop_id;
     }
     if ($order_id) {
         $cache_id = 'jeproshop_order_model_' . $order_id . '_' . $lang_id . '_' . $this->shop_id;
         if (!JeproshopCache::isStored($cache_id)) {
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord ";
             $where = "";
             /** get language information **/
             if ($lang_id) {
                 $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang') . " AS product_lang ";
                 $query .= "ON (product.product_id = product_lang.product_id AND product_lang.lang_id = " . (int) $lang_id . ") ";
                 if ($this->shop_id && !empty($this->multiLangShop)) {
                     $where = " AND product_lang.shop_id = " . $this->shop_id;
                 }
             }
             /** Get shop information **/
             if (JeproshopShopModelShop::isTableAssociated('order')) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_order_shop') . " AS order_shop ON (";
                 $query .= "ord.order_id = order_shop.order_id AND order_shop.shop_id = " . (int) $this->shop_id . ")";
             }
             $query .= " WHERE ord.order_id = " . (int) $order_id . $where;
             $db->setQuery($query);
             $order_data = $db->loadObject();
             if ($order_data) {
                 if (!$lang_id && isset($this->multiLang) && $this->multiLang) {
                     $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_product_lang');
                     $query .= " WHERE product_id = " . (int) $order_id;
                     $db->setQuery($query);
                     $order_lang_data = $db->loadObjectList();
                     if ($order_lang_data) {
                         foreach ($order_lang_data as $row) {
                             foreach ($row as $key => $value) {
                                 if (array_key_exists($key, $this) && $key != 'order_id') {
                                     if (!isset($order_data->{$key}) || !is_array($order_data->{$key})) {
                                         $order_data->{$key} = array();
                                     }
                                     $order_data->{$key}[$row->lang_id] = $value;
                                 }
                             }
                         }
                     }
                 }
                 JeproshopCache::store($cache_id, $order_data);
             }
         } else {
             $order_data = JeproshopCache::retrieve($cache_id);
         }
         if ($order_data) {
             $order_data->product_id = $order_id;
             foreach ($order_data as $key => $value) {
                 if (array_key_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     if ($this->customer_id) {
         $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id);
         $this->_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod((int) $customer->default_group_id);
     }
 }
Esempio n. 9
0
 /**
  * Return current category childs
  *
  * @param integer $lang_id Language ID
  * @param boolean $published return only active categories
  * @return array Categories
  */
 public function getSubCategories($lang_id, $published = true)
 {
     $sql_groups_where = '';
     $sql_groups_join = '';
     $db = JFactory::getDBO();
     if (JeproshopGroupModelGroup::isFeaturePublished()) {
         $sql_groups_join = " LEFT JOIN " . $db->quoteName('#__jeproshop_category_group') . " AS category_group ON (category_group." . $db->quoteName('category_id') . " = category." . $db->quoteName('category_id') . ")";
         $groups = JeproshopController::getCurrentCustomerGroups();
         $sql_groups_where = " AND category_group." . $db->quoteName('group_id') . " " . (count($groups) ? " IN (" . implode(',', $groups) . ")" : " = " . (int) JeproshopGroupModelGroup::getCurrent()->group_id);
     }
     $query = "SELECT category.*, category_lang.lang_id, category_lang.name, category_lang.description, category_lang.link_rewrite, category_lang.meta_title, category_lang.meta_keywords, ";
     $query .= " category_lang.meta_description FROM " . $db->quoteName('#__jeproshop_category') . " AS category " . JeproshopShopModelShop::addSqlAssociation('category') . " LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_category_lang') . " AS category_lang ON (category." . $db->quoteName('category_id') . " = category_lang." . $db->quoteName('category_id');
     $query .= " AND " . $db->quoteName('lang_id') . " = " . (int) $lang_id . " " . JeproshopShopModelShop::addSqlRestrictionOnLang('category_lang') . ") " . $sql_groups_join;
     $query .= " WHERE " . $db->quoteName('parent_id') . " = " . (int) $this->category_id . ($published ? " AND " . $db->quoteName('published') . " = 1 " : "") . $sql_groups_where;
     $query .= "\tGROUP BY category." . $db->quoteName('category_id') . " ORDER BY " . $db->quoteName('depth_level') . " ASC, category_shop." . $db->quoteName('position') . " ASC";
     $db->setQuery($query);
     $result = $db->loadObjectList();
     foreach ($result as &$row) {
         $row->image_id = JeproshopTools::file_exists_cache(COM_JEPROSHOP_CATEGORY_IMAGE_DIRECTORY . $row->category_id . '.jpg') ? (int) $row->category_id : JeproshopLanguageModelLanguage::getIsoById($lang_id) . '_default';
         $row->legend = JText::_('COM_JEPROSHOP_NO_PICTURE_LABEL');
     }
     return $result;
 }
Esempio n. 10
0
 public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false, $useCookie = true, JeproshopContext $context = null)
 {
     if (!$context) {
         $context = JeproshopContext::getContext();
     }
     // Only use cookie if id_customer is not present
     if ($useCookie) {
         $customer_id = (int) $context->customer->customer_id;
     } else {
         $customer_id = 0;
     }
     if (!is_numeric($pageNumber) || !is_numeric($pageSize) || !Validate::isBool($count) || !Validate::isValidSearch($tag) || $orderBy && !$orderWay || $orderBy && !Validate::isOrderBy($orderBy) || $orderWay && !Validate::isOrderBy($orderWay)) {
         return false;
     }
     if ($pageNumber < 1) {
         $pageNumber = 1;
     }
     if ($pageSize < 1) {
         $pageSize = 10;
     }
     $shop_id = JeproshopContext::getContext()->shop->shop_id;
     $shop_id = $shop_id ? $shop_id : JeproshopSettingModelSetting::getValue('default_shop');
     $sql_groups = '';
     if (JeproshopGroupModelGroup::isFeaturePublished()) {
         $groups = JeproshopController::getCurrentCustomerGroups();
         $sql_groups = " AND customer_group." . $db->quoteName('group_id') . (count($groups) ? " IN (" . implode(',', $groups) . ")" : "= 1");
     }
     if ($count) {
         $query = "SELECT COUNT(DISTINCT product_tag." . $db->quoteName('product_id') . ") nb FROM " . $db->quoteName('#__jeproshop_product');
         $query .= " AS product " . JeproshopShopModelShop::addSqlAssociation('product') . "\tLEFT JOIN " . $db->quoteName('#__jeproshop_product_tag');
         $query .= " AS product_tag ON (product." . $db->quoteName('product_id') . " = product_tag." . $db->quoteName('product_id') . ") LEFT JOIN ";
         $query .= $db->quoteName('#__jeproshop_tag') . " AS tag ON (product_tag." . $db->quoteName('tag_id') . " = tag." . $db->quoteName('tag_id');
         $query .= " AND tag." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_product_category');
         $query .= " AS product_category ON (product_category." . $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . ") LEFT JOIN ";
         $query .= $db->quoteName('#__jeproshop_category_shop') . " AS category_shop ON (product_category." . $db->quoteName('category_id') . " = category_shop.";
         $query .= $db->quoteName('category_id') . " AND category_shop." . $db->quoteName('shop_id') . " = " . (int) $shop_id . ") ";
         $query .= JeproshopGroupModelGroup::isFeaturePublished() ? " LEFT JOIN " . $db->quoteName('#__jeproshop_category_group') . " AS category_group ON (category_group." . $db->quoteName('category_id') . " = product_category." . $db->quoteName('category_id') . ")" : "";
         $query .= "\tWHERE product_shop." . $db->quoteName('publishd') . " = 1 AND product.visibility IN ('both', 'search') AND category_shop." . $db->quoteName('shop_id');
         $query .= " = " . (int) JeproshopContext::getContext()->shop->shop_id . $sql_groups . " AND tag." . $db->quoteName('name') . " LIKE '%'" . $db->quote($tag) . "'%')";
         /*$query .= " } 
         	
         				$sql = 'SELECT DISTINCT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
         					MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name, 1 position,
         					DATEDIFF(
         						p.`date_add`,
         						DATE_SUB(
         							NOW(),
         							INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
         						)
         					) > 0 new
         				FROM `' $db->quoteName('#__jeproshop_product` p
         				INNER JOIN `'.$db->quoteName('#__jeproshop_product_lang` pl ON (
         					p.`id_product` = pl.`id_product`
         					AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
         				)'.Shop::addSqlAssociation('product', 'p', false).'
         				LEFT JOIN `'.$db->quoteName('#__jeproshop_image` i ON (i.`id_product` = p.`id_product`)'.
         					Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
         				LEFT JOIN `' . $db->quoteName('#__jeproshop_image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_product_tag` pt ON (p.`id_product` = pt.`id_product`)
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_category_product` cp ON (cp.`id_product` = p.`id_product`)
         				'.(Group::isFeatureActive() ? 'LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)' : '').'
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
         				'.Product::sqlStock('p', 0).'
         				WHERE product_shop.`active` = 1
         					AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
         					'.$sql_groups.'
         					AND t.`name` LIKE \'%'.pSQL($tag).'%\'
         					return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(
         			
         				
         					GROUP BY product_shop.id_product
         				ORDER BY position DESC'.($orderBy ? ', '.$orderBy : '').($orderWay ? ' '.$orderWay : '').'
         				LIMIT '.(int)(($pageNumber - 1) * $pageSize).','.(int)$pageSize;
         				$db->setQuery($query);
         				$result = $db->loadObjectList();
         				if (!$result)
         					return false; */
     }
     return JeproshopProductModelProduct::getProductsProperties((int) $lang_id, $result);
 }
Esempio n. 11
0
$context->currency = new JeproshopCurrencyModelCurrency($currency_id);
if (isset($context->cookie->customer_id) && (int) $context->customer_id) {
    $customer = new JeproshopCustomerModelCustomer($context->cookie->customer_id);
    if (!JeproshopTools::isLoadedObject($customer)) {
        $context->cookie->logout();
    } else {
        $customer->logged = TRUE;
        if ($customer->lang_id != $context->language->lang_id) {
            $customer->lang_id = $context->language->lang_id;
            $customer->update();
        }
    }
}
if (!isset($customer) || !JeproshopTools::isLoadedObject($customer)) {
    $customer = new JeproshopCustomerModelCustomer();
    if (JeproshopGroupModelGroup::isFeaturePublished()) {
        $customer->default_group_id = (int) JeproshopSettingModelSetting::getValue('unidentified_group');
    }
}
$customer->guest_id = $context->cookie->guest_id;
$context->customer = $customer;
/** controller and redirection */
$controller = JFactory::getApplication()->input->get('view');
if ($controller) {
    if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php')) {
        require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controller.php';
        require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php';
    } else {
        $controller = '';
    }
    $context->controller = JControllerLegacy::getInstance('Jeproshop' . $controller);
Esempio n. 12
0
 /**
  * Return manufacturers
  *
  * @param boolean $get_nb_products [optional] return products numbers for each
  * @param int $lang_id
  * @param bool $published
  * @param int $p
  * @param int $n
  * @param bool $all_group
  * @return array Manufacturers
  */
 public static function getManufacturers($get_nb_products = false, $lang_id = 0, $published = true, $p = false, $n = false, $all_group = false, $group_by = false)
 {
     if (!$lang_id) {
         $lang_id = (int) JeproshopSettingModelSetting::getValue('default_lang');
     }
     if (!JeproshopGroupModelGroup::isFeaturePublished()) {
         $all_group = true;
     }
     $db = JFactory::getDBO();
     $query = "SELECT manufacturer.*, manufacturer_lang." . $db->quoteName('description') . ", manufacturer_lang.";
     $query .= $db->quoteName('short_description') . " FROM " . $db->quoteName('#__jeproshop_manufacturer') . " AS ";
     $query .= "manufacturer " . JeproshopShopModelShop::addSqlAssociation('manufacturer') . " INNER JOIN ";
     $query .= $db->quoteName('#__jeproshop_manufacturer_lang') . " AS manufacturer_lang ON (manufacturer.";
     $query .= $db->quoteName('manufacturer_id') . " = manufacturer_lang." . $db->quoteName('manufacturer_id');
     $query .= " AND manufacturer_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")";
     $query .= $published ? " WHERE manufacturer." . $db->quoteName('published') . " = 1" : "";
     $query .= ($group_by ? " GROUP BY manufacturer." . $db->quoteName('manufacturer_id') : "") . " ORDER BY ";
     $query .= "manufacturer." . $db->quoteName('name') . " ASC " . ($p ? " LIMIT " . ((int) $p - 1) * (int) $n . ", " . (int) $n : "");
     $db->setQuery($query);
     $manufacturers = $db->loadObjectList();
     if ($manufacturers === false) {
         return false;
     }
     /*
     if ($get_nb_products)
     {
     	$sql_groups = '';
     	if (!$all_group)
     	{
     		$groups = FrontController::getCurrentCustomerGroups();
     		$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
     	}
     	
     	foreach ($manufacturers as $key => $manufacturer)
     	{
     		$manufacturers[$key]['nb_products'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
     		SELECT COUNT(DISTINCT p.`id_product`)
     		FROM `'._DB_PREFIX_.'product` p
     		'.Shop::addSqlAssociation('product', 'p').'
     		WHERE p.`id_manufacturer` = '.(int)$manufacturer['id_manufacturer'].'
     		AND product_shop.`visibility` NOT IN ("none")
     		'.($active ? ' AND product_shop.`active` = 1 ' : '').'
     		'.($all_group ? '' : ' AND p.`id_product` IN (
     			SELECT cp.`id_product`
     			FROM `'._DB_PREFIX_.'category_group` cg
     			LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
     			WHERE cg.`id_group` '.$sql_groups.'
     		)'));
     	}
     }	
     */
     $total_manufacturers = count($manufacturers);
     $rewrite_settings = (int) JeproshopSettingModelSetting::getValue('rewrite_settings');
     for ($i = 0; $i < $total_manufacturers; $i++) {
         $manufacturers[$i]->link_rewrite = $rewrite_settings ? JeproshopValidator::link_rewrite($manufacturers[$i]->name) : 0;
     }
     return $manufacturers;
 }
Esempio n. 13
0
 public static function getNestedCategories($root_category = null, $lang_id = false, $published = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
 {
     $db = JFactory::getDBO();
     if (isset($root_category) && !JeproshopTools::isInt($root_category)) {
         die(Tools::displayError());
     }
     if (!JeproshopTools::isBool($published)) {
         die(Tools::displayError());
     }
     if (isset($groups) && JeproshopGroupModelGroup::isFeaturePublished() && !is_array($groups)) {
         $groups = (array) $groups;
     }
     $cache_id = 'Category::getNestedCategories_' . md5((int) $root_category . (int) $lang_id . '_' . (int) $published . '_' . (int) $published . (isset($groups) && JeproshopGroupModelGroup::isFeaturePublished() ? implode('', $groups) : ''));
     if (!JeproshopCache::isStored($cache_id)) {
         $query = "SELECT category.*, category_lang.* FROM " . $db->quoteName('#__jeproshop_category') . " AS category ";
         $query .= ($use_shop_restriction ? JeproshopShopModelShop::addSqlAssociation('category') : "") . " LEFT JOIN ";
         $query .= $db->quoteName('#__jeproshop_category_lang') . " AS category_lang ON category." . $db->quoteName('category_id');
         $query .= " = category_lang." . $db->quoteName('category_id') . JeproshopShopModelShop::addSqlRestrictionOnLang('category_lang');
         $selector = " LEFT JOIN " . $db->quoteName('#__jeproshop_category_group') . " AS category_group ON category.";
         $selector .= $db->quoteName('category_id') . " = category_group." . $db->quoteName('category_id');
         $query .= isset($groups) && JeproshopGroupModelGroup::isFeaturePublished() ? $selector : "";
         $selector = " RIGHT JOIN " . $db->quoteName('#__jeproshop_category') . " AS category_2 ON category_2." . $db->quoteName('category_id');
         $selector .= " = " . (int) $root_category . " AND category." . $db->quoteName('n_left') . " >= category_2." . $db->quoteName('n_left');
         $selector .= " AND category." . $db->quoteName('n_right') . " <= category_2." . $db->quoteName('n_right');
         $query .= (isset($root_category) ? $selector : "") . " WHERE 1 " . $sql_filter . ($lang_id ? " AND " . $db->quoteName('lang_id') . " = " . (int) $lang_id : "");
         $query .= $published ? " AND category." . $db->quoteName('published') . " = 1" : "";
         $query .= isset($groups) && JeproshopGroupModelGroup::isFeaturePublished() ? " AND category_group." . $db->quoteName('group_id') . " IN (" . implode(',', $groups) . ") " : "";
         $selector = " GROUP BY category." . $db->quoteName('category_id');
         $query .= !$lang_id || isset($groups) && JeproshopGroupModelGroup::isFeaturePublished() ? $selector : "";
         $query .= $sql_sort != "" ? $sql_sort : " ORDER BY category." . $db->quoteName('depth_level') . " ASC";
         $query .= $sql_sort == "" && $use_shop_restriction ? ", category_shop." . $db->quoteName('position') . " ASC" : "";
         $query .= $sql_limit != "" ? $sql_limit : "";
         $db->setQuery($query);
         $result = $db->loadObjectList();
         $categories = array();
         $buff = array();
         if (!isset($root_category)) {
             $root_category = JeproshopCategoryModelCategory::getRootCategory()->category_id;
         }
         foreach ($result as $row) {
             $current =& $buff[$row->category_id];
             $current = $row;
             if ($row->category_id == $root_category) {
                 $categories[$row->category_id] =& $current;
             } else {
                 $buff[$row->parent_id]->children[$row->category_id] =& $current;
             }
         }
         JeproshopCache::store($cache_id, $categories);
     }
     return JeproshopCache::retrieve($cache_id);
 }
Esempio n. 14
0
 /**
  * @static
  * @param JeproshopContext|null $context
  * @return mixed
  */
 public static function autoAddToCart(JeproshopContext $context = null)
 {
     if ($context === null) {
         $context = JeproshopContext::getContext();
     }
     if (!JeproshopCartRuleModelCartRule::isFeaturePublished() || !JeproshopValidator::isLoadedObject($context->cart, 'cart_id')) {
         return;
     }
     $db = JFactory::getDBO();
     $query = "SELECT cart_rule.* FROM " . $db->quoteName('#__jeproshop_cart_rule') . " AS cart_rule LEFT JOIN " . $db->quoteName('#__jeproshop_cart_rule_shop');
     $query .= " AS cart_rule_shop ON cart_rule.cart_rule_id = cart_rule_shop.cart_rule_id ";
     $group_query = " LEFT JOIN " . $db->quoteName('#__jeproshop_cart_rule_group') . " AS cart_rule_group ON cart_rule.cart_rule_id = cart_rule_group.cart_rule_id ";
     $query .= (!$context->customer->customer_id && JeproshopGroupModelGroup::isFeaturePublished() ? $group_query : "") . " LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_cart_rule_carrier') . " AS cart_rule_carrier ON cart_rule.cart_rule_id = cart_rule_carrier.cart_rule_id ";
     $query .= $context->cart->carrier_id ? " LEFT JOIN " . $db->quoteName('#__jeproshop_carrier') . " AS carrier ON (carrier.reference_id = cart_rule_carrier.carrier_id AND carrier.deleted = 0)" : "";
     $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_cart_rule_country') . " AS cart_rule_country ON cart_rule.cart_rule_id = cart_rule_country.";
     $query .= "cart_rule_id WHERE cart_rule.published = 1 AND cart_rule.code = '' AND cart_rule.quantity > 0 AND cart_rule.date_from < '" . date('Y-m-d H:i:s') . "'\tAND cart_rule.date_to > '";
     $query .= date('Y-m-d H:i:s') . "' AND ( cart_rule.customer_id = 0 " . ($context->customer->customer_id ? " OR cart_rule.customer_id = " . (int) $context->cart->customer_id : "");
     $query .= ") AND ( cart_rule." . $db->quoteName('carrier_restriction') . " = 0 " . ($context->cart->carrier_id ? " OR carrier.carrier_id = " . (int) $context->cart->carrier_id : "");
     $query .= " ) AND ( cart_rule." . $db->quoteName('shop_restriction') . " = 0 " . (JeproshopShopModelShop::isFeaturePublished() && $context->shop->shop_id ? " OR cart_rule_shop.shop_id = " . (int) $context->shop->shop_id : "");
     $query .= " ) AND ( cart_rule." . $db->quoteName('group_restriction') . " = 0 ";
     if ($context->customer->customer_id) {
         $query = " OR 0 < ( SELECT customer_group." . $db->quoteName('group_id') . " FROM " . $db->quoteName('#__jeproshop_customer_group') . " AS customer_group INNER JOIN " . $db->quoteName('#__jeproshop_cart_rule_group');
         $query .= " AS cart_rule_group ON customer_group.group_id = cart_rule_group.group_id WHERE cart_rule." . $db->quoteName('cart_rule_id') . " = cart_rule_group." . $db->quoteName('cart_rule_id') . " AND customer_group.";
         $query .= $db->quoteName('customer_id') . " = " . (int) $context->customer->customer_id . " LIMIT 1\t)";
     } else {
         if (JeproshopGroupModelGroup::isFeaturePublished()) {
             $query .= " OR cart_rule_group." . $db->quoteName('group_id') . " = " . (int) JeproshopSettingModelSetting::getValue('unidentified_group');
         }
     }
     $query .= " ) AND ( cart_rule." . $db->quoteName('`reduction_product') . " <= 0 OR cart_rule." . $db->quoteName('reduction_product') . " IN ( SELECT " . $db->quoteName('product_id') . " FROM ";
     $query .= $db->quoteName('#__jeproshop_cart_product') . " WHERE " . $db->quoteName('cart_id') . " = " . (int) $context->cart->cart_id . " ) ) AND cart_rule.cart_rule_id NOT IN (SELECT cart_rule_id FROM ";
     $query .= $db->quoteName('#__jeproshop_cart_cart_rule') . " WHERE car_id = " . (int) $context->cart->cart_id . ") ORDER BY priority";
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if ($result) {
         $cart_rules = ObjectModel::hydrateCollection('CartRule', $result);
         if ($cart_rules) {
             foreach ($cart_rules as $cart_rule) {
                 if ($cart_rule->checkValidity($context, false, false)) {
                     $context->cart->addCartRule($cart_rule->cart_rule_id);
                 }
             }
         }
     }
 }
Esempio n. 15
0
    /**
     * Return suppliers
     *
     * @param bool $get_nb_products
     * @param int $lang_id
     * @param bool $published
     * @param bool $p
     * @param bool $n
     * @param bool $all_groups
     * @return array Suppliers
     */
    public static function getSuppliers($get_nb_products = false, $lang_id = 0, $published = true, $p = false, $n = false, $all_groups = false)
    {
        if (!$lang_id) {
            $lang_id = JeproshopSettingModelSetting::getValue('default_lang');
        }
        if (!JeproshopGroupModelGroup::isFeaturePublished()) {
            $all_groups = true;
        }
        $db = JFactory::getDBO();
        $query = "SELECT supplier.*, supplier_lang." . $db->quoteName('description') . " FROM " . $db->quoteName('#__jeproshop_supplier');
        $query .= " AS supplier LEFT JOIN " . $db->quoteName('#__jeproshop_supplier_lang') . " AS supplier_lang ON(supplier.";
        $query .= $db->quoteName('supplier_id') . " = supplier_lang." . $db->quoteName('supplier_id') . " AND supplier_lang.";
        $query .= $db->quoteName('lang_id') . " = " . (int) $lang_id . JeproshopShopModelShop::addSqlAssociation('supplier') . ")";
        $query .= ($published ? " WHERE supplier." . $db->quoteName('published') . " = 1" : "") . " ORDER BY supplier.";
        $query .= $db->quoteName('name') . " ASC " . ($p && $n ? " LIMIT " . $n . ", " . ($p - 1) * $n : "");
        //. " GROUP BY supplier" . $db->quoteName('supplier_id');
        $db->setQuery($query);
        $suppliers = $db->loadObjectList();
        if ($suppliers === false) {
            return false;
        }
        if ($get_nb_products) {
            $sql_groups = '';
            if (!$all_groups) {
                $groups = FrontController::getCurrentCustomerGroups();
                $sql_groups = count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1';
            }
            foreach ($suppliers as $key => $supplier) {
                $sql = '
					SELECT DISTINCT(ps.`id_product`)
					FROM `' . _DB_PREFIX_ . 'product_supplier` ps
					JOIN `' . _DB_PREFIX_ . 'product` p ON (ps.`id_product`= p.`id_product`)
					' . Shop::addSqlAssociation('product', 'p') . '
					WHERE ps.`id_supplier` = ' . (int) $supplier['id_supplier'] . '
					AND ps.id_product_attribute = 0' . ($active ? ' AND product_shop.`active` = 1' : '') . ' AND product_shop.`visibility` NOT IN ("none")' . ($all_groups ? '' : '
					AND ps.`id_product` IN (
						SELECT cp.`id_product`
						FROM `' . _DB_PREFIX_ . 'category_group` cg
						LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
						WHERE cg.`id_group` ' . $sql_groups . '
					)');
                $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
                $suppliers[$key]['nb_products'] = count($result);
            }
        }
        $nb_suppliers = count($suppliers);
        $rewrite_settings = (int) JeproshopSettingModelSetting::getValue('rewrite_settings');
        for ($i = 0; $i < $nb_suppliers; $i++) {
            $suppliers[$i]->link_rewrite = $rewrite_settings ? JeproshopValidator::link_rewrite($suppliers[$i]->name) : 0;
        }
        return $suppliers;
    }
Esempio n. 16
0
 public static function getDefaultGroupId($customer_id)
 {
     if (!JeproshopGroupModelGroup::isFeaturePublished()) {
         return JeproshopSettingModelSetting::getValue('customer_group');
     }
     if (!isset(self::$_defaultGroupId[(int) $customer_id])) {
         $db = JFactory::getDBO();
         $query = "SELECT " . $db->quoteName('default_group_id') . " FROM " . $db->quoteName('#__jeproshop_customer') . " WHERE " . $db->quoteName('customer_id') . " = " . (int) $customer_id;
         $db->setQuery($query);
         self::$_defaultGroupId[(int) $customer_id] = $db->loadResult();
     }
     return self::$_defaultGroupId[(int) $customer_id];
 }
Esempio n. 17
0
 private function initPriceForm()
 {
     if ($this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     if ($this->product->product_id) {
         $shops = JeproshopShopModelShop::getShops();
         $countries = JeproshopCountryModelCountry::getStaticCountries($this->context->language->lang_id);
         $groups = JeproshopGroupModelGroup::getStaticGroups($this->context->language->lang_id);
         $currencies = JeproshopCurrencyModelCurrency::getStaticCurrencies();
         $attributes = $this->product->getAttributesGroups((int) $this->context->language->lang_id);
         $combinations = array();
         if (count($attributes)) {
             foreach ($attributes as $attribute) {
                 $combinations[$attribute->product_attribute_id] = new JObject();
                 $combinations[$attribute->product_attribute_id]->product_attribute_id = $attribute->product_attribute_id;
                 if (!isset($combinations[$attribute->product_attribute_id]->attributes)) {
                     $combinations[$attribute->product_attribute_id]->attributes = '';
                 }
                 if (isset($combinations[$attribute->product_attribute_id])) {
                     $combinations[$attribute->product_attribute_id]->attributes .= $attribute->attribute_name . ' - ';
                     $combinations[$attribute->product_attribute_id]->price = JeproshopTools::displayPrice(JeproshopTools::convertPrice(JeproshopProductModelProduct::getStaticPrice((int) $this->product->product_id, false, $attribute->product_attribute_id), $this->context->currency), $this->context->currency);
                 }
             }
             foreach ($combinations as $combination) {
                 if (isset($combination->attributes)) {
                     $combination->attributes = rtrim($combination->attributes, ' - ');
                 }
             }
         }
         $specificPriceModificationForm = $this->displaySpecificPriceModificationForm($this->context->currency, $shops, $currencies, $countries, $groups);
         $this->assignRef('specific_price_modification_form', $specificPriceModificationForm);
         $this->assignRef('ecotax_tax_excluded', $this->product->ecotax);
         //$this->applyTaxToEcotax();
         $this->assignRef('shops', $shops);
         /*$admin_one_shop = count($this->context->employee->getAssociatedShops()) == 1;
           $this->assignRef('admin_one_shop', $admin_one_shop); */
         $this->assignRef('currencies', $currencies);
         $this->assignRef('currency', $this->context->currency);
         $this->assignRef('countries', $countries);
         $this->assignRef('groups', $groups);
         $this->assignRef('combinations', $combinations);
         $multiShop = JeproshopShopModelShop::isFeaturePublished();
         $this->assignRef('multi_shop', $multiShop);
     } else {
         JError::raiseWarnig(JText::_('COM_JEPROSHOP_YOU_MUST_SAVE_THIS_PRODUCT_BEFORE_ADDING_SPECIFIC_PRICING_MESSAGE'));
         $this->product->tax_rules_group_id = JeproshopProductModelProduct::getTaxRulesMostUsedGroupId();
         $this->assignRef('ecotax_tax_excluded', 0);
     }
     $use_tax = JeproshopSettingModelSetting::getValue('use_tax');
     $this->assignRef('use_tax', $use_tax);
     $use_ecotax = JeproshopSettingModelSetting::getValue('use_eco_tax');
     $this->assignRef('use_ecotax', $use_ecotax);
     $tax_rules_groups = JeproshopTaxRulesGroupModelTaxRulesGroup::getTaxRulesGroups(true);
     $this->assignRef('tax_rules_groups', $tax_rules_groups);
     $taxesRatesByGroup = JeproshopTaxRulesGroupModelTaxRulesGroup::getAssociatedTaxRatesByCountryId($this->context->country->country_id);
     $this->assignRef('taxesRatesByGroup', $taxesRatesByGroup);
     $ecotaxTaxRate = JeproshopTaxModelTax::getProductEcotaxRate();
     $this->assignRef('ecotaxTaxRate', $ecotaxTaxRate);
     $tax_exclude_tax_option = JeproshopTaxModelTax::taxExcludedOption();
     $this->assignRef('tax_exclude_tax_option', $tax_exclude_tax_option);
     $this->product->price = JeproshopTools::convertPrice($this->product->price, $this->context->currency, true, $this->context);
     if ($this->product->unit_price_ratio != 0) {
         $unit_price = JeproshopTools::roundPrice($this->product->price / $this->product->unit_price_ratio, 2);
     } else {
         $unit_price = 0;
     }
     $this->assignRef('unit_price', $unit_price);
 }
Esempio n. 18
0
 public function renderView($tpl = null)
 {
     if (!$this->loadObject(true)) {
         return;
     }
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $customer = new JeproshopCustomerModelCustomer($this->cart->customer_id);
     $currency = new JeproshopCurrencyModelCurrency($this->cart->currency_id);
     $this->context->cart = $this->cart;
     $this->context->currency = $currency;
     $this->context->customer = $customer;
     //$this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->cart_id);
     $products = $this->cart->getProducts();
     $customized_datas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $this->cart->cart_id);
     JeproshopProductModelProduct::addCustomizationPrice($products, $customized_datas);
     $summary = $this->cart->getSummaryDetails();
     /* Display order information */
     $order_id = (int) JeproshopOrderModelOrder::getOrderIdByCartId($this->cart->cart_id);
     $order = new JeproshopOrderModelOrder($order_id);
     if (JeproshopTools::isLoadedObject($order, 'order_id')) {
         $tax_calculation_method = $order->getTaxCalculationMethod();
         $shop_id = (int) $order->shop_id;
     } else {
         $shop_id = (int) $this->cart->shop_id;
         $tax_calculation_method = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id);
     }
     if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) {
         $total_products = $summary->total_products;
         $total_discounts = $summary->total_discounts_tax_exc;
         $total_wrapping = $summary->total_wrapping_tax_exc;
         $total_price = $summary->total_price_without_tax;
         $total_shipping = $summary->total_shipping_tax_exc;
     } else {
         $total_products = $summary->total_products_wt;
         $total_discounts = $summary->total_discounts;
         $total_wrapping = $summary->total_wrapping;
         $total_price = $summary->total_price;
         $total_shipping = $summary->total_shipping;
     }
     foreach ($products as $k => &$product) {
         if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) {
             $product->product_price = $product->price;
             $product->product_total = $product->total;
         } else {
             $product->product_price = $product->price_wt;
             $product->product_total = $product->total_wt;
         }
         $image = array();
         $db = JFactory::getDBO();
         if (isset($product->product_attribute_id) && (int) $product->product_attribute_id) {
             $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_product_attribute_image') . " WHERE product_attribute_id = " . (int) $product->product_attribute_id;
             $db->setQuery($query);
             $image = $db->loadObject();
         }
         if (!isset($image->image_id)) {
             $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_image') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product->product_id . " AND cover = 1 ";
             $db->setQuery($query);
             $image = $db->loadObject();
         }
         $product_obj = new JeproshopProductModelProduct($product->product_id);
         $product->qty_in_stock = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($product->product_id, isset($product->product_attribute_id) ? $product->product_attribute_id : null, (int) $shop_id);
         $image_product = new JeproshopImageModelImage($image->image_id);
         $product->image = isset($image->image_id) ? JeproshopImageManager::thumbnail(COM_JEPROSHOP_IMAGE_DIR . 'products/' . $image_product->getExistingImagePath() . '.jpg', 'product_mini_' . (int) $product->product_id . (isset($product->product_attribute_id) ? '_' . (int) $product->product_attribute_id : '') . '.jpg', 45, 'jpg') : '--';
     }
     /*$helper = new HelperKpi();
       $helper->id = 'box-kpi-cart';
       $helper->icon = 'icon-shopping-cart';
       $helper->color = 'color1';
       $helper->title = $this->l('Total Cart', null, null, false);
       $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
       $helper->value = Tools::displayPrice($total_price, $currency);
       $kpi = $helper->generate(); */
     //$this->assignRef('kpi', $kpi);
     $this->assignRef('products', $products);
     $discounts = $this->cart->getCartRules();
     $this->assignRef('discounts', $discounts);
     $this->assignRef('order', $order);
     $this->assignRef('currency', $currency);
     $this->assignRef('customer', $customer);
     $customerStats = $customer->getStats();
     $this->assignRef('customer_stats', $customerStats);
     $this->assignRef('total_products', $total_products);
     $this->assignRef('total_discounts', $total_discounts);
     $this->assignRef('total_wrapping', $total_wrapping);
     $this->assignRef('total_price', $total_price);
     $this->assignRef('total_shipping', $total_shipping);
     $this->assignRef('customized_datas', $customized_datas);
     if ($this->getLayout() != 'modal') {
         $this->addToolBar();
         $this->sideBar = JHtmlSidebar::render();
     }
     parent::display($tpl);
 }
Esempio n. 19
0
 public function renderEditForm($tpl = null)
 {
     $this->loadObject(true);
     $app = JFactory::getApplication();
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $shop_id = JeproshopContext::getContext()->shop->shop_id;
     $selected_categories = array(isset($this->context->controller->category->parent_id) && $this->context->controller->category->isParentCategoryAvailable($shop_id) ? (int) $this->context->controller->category->parent_id : $app->input->get('parent_id', JeproshopCategoryModelCategory::getRootCategory()->category_id));
     $unidentified = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('unidentified_group'));
     $guest = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('guest_group'));
     $default = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('customer_group'));
     $unidentified_group_information = '<b>' . $unidentified->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_ALL_PEOPLE_WITHOUT_A_VALID_CUSTOMER_ACCOUNT_MESSAGE');
     $guest_group_information = '<b>' . $guest->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_CUSTOMER_WHO_PLACED_AN_ORDER_WITH_THE_GUEST_CHECKOUT_MESSAGE');
     $default_group_information = '<b>' . $default->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_ALL_PEOPLE_WHO_HAVE_CREATED_AN_CREATED_AN_ACCOUNT_ON_THIS_SITE_MESSAGE');
     $this->assignRef('unidentified_group_information', $unidentified_group_information);
     $this->assignRef('guest_group_information', $guest_group_information);
     $this->assignRef('default_group_information', $default_group_information);
     $image = COM_JEPROSHOP_CATEGORY_IMAGE_DIR . $this->context->controller->category->category_id . '.jpg';
     $image_url = JeproshopImageManager::thumbnail($image, 'category_' . $this->context->controller->category->category_id . '.jpg', 350, 'jpg', true, true);
     $imageSize = file_exists($image) ? filesize($image) / 1000 : false;
     $shared_category = JeproshopTools::isLoadedObject($this->context->controller->category, 'category_id') && $this->context->controller->category->hasMultishopEntries();
     $this->assignRef('shared_category', $shared_category);
     $allow_accented_chars_url = (int) JeproshopSettingModelSetting::getValue('allow_accented_chars_url');
     $this->assignRef('allow_accented_chars_url', $allow_accented_chars_url);
     //$this->assignRef('selected_categories', $selected_categories);
     $categories_tree = new JeproshopCategoriesTree('jform_categories_tree', JText::_('COM_JEPROSHOP_CATEGORIES_LABEL'), null, $this->context->language->lang_id);
     $categories_tree->setTreeTemplate('associated_categories')->setSelectedCategories($selected_categories)->setUseCheckBox(true)->setInputName('parent_id');
     $categories_data = $categories_tree->render();
     $this->assignRef('categories_tree', $categories_data);
     $image = JeproshopImageManager::thumbnail(COM_JEPROSHOP_CATEGORY_IMAGE_DIR . '/' . $this->context->controller->category->category_id . '.jpg', 'category_' . (int) $this->context->controller->category->category_id . '.jpg', 350, 'jpg', true);
     $this->assignRef('image', $image ? $image : false);
     $size = $image ? filesize(COM_JEPROSHOP_CATEGORY_IMAGE_DIR . '/' . $this->context->controller->category->category_id . 'jpg') / 1000 : false;
     $this->assignRef('size', $size);
     $category_group_ids = $this->context->controller->category->getGroups();
     $groups = JeproshopGroupModelGroup::getGroups($this->context->language->lang_id);
     //if empty $carrier_groups_ids : object creation : we set the default groups
     if (empty($category_group_ids)) {
         $preSelected = array(JeproshopSettingModelSetting::getValue('unidentified_group'), JeproshopSettingModelSetting::getValue('guest_group'), JeproshopSettingModelSetting::getValue('customer_group'));
         $category_group_ids = array_merge($category_group_ids, $preSelected);
     }
     foreach ($groups as $group) {
         $groupBox = $app->input->get('group_box_' . $group->group_id, in_array($group->group_id, $category_group_ids));
         $this->assignRef('group_box_' . $group->group_id, $groupBox);
     }
     $is_root_category = (bool) $app->input->get('is_root_category');
     $this->assignRef('is_root_category', $is_root_category);
     $helper = new JeproshopHelper();
     $this->assignRef('helper', $helper);
     $this->assignRef('groups', $groups);
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
Esempio n. 20
0
 /**
  * Assign price and tax to the template
  */
 protected function assignPriceAndTax()
 {
     $customer_id = isset($this->context->customer) ? (int) $this->context->customer->customer_id : 0;
     $group_id = (int) JeproshopGroupModelGroup::getCurrent()->group_id;
     $country_id = (int) $customer_id ? JeproshopCustomerModelCustomer::getCurrentCountry($customer_id) : JeproshopSettingModelSetting::getValue('default_country');
     $group_reduction = JeproshopGroupReductionModelGroupReduction::getValueForProduct($this->product->product_id, $group_id);
     if ($group_reduction === false) {
         $group_reduction = JeproshopGroupModelGroup::getReduction((int) $this->context->cookie->customer_id) / 100;
     }
     // Tax
     $tax = (double) $this->product->getTaxesRate(new JeproshopAddressModelAddress((int) $this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')}));
     $this->assignRef('tax_rate', $tax);
     $product_price_with_tax = JeproshopProductModelProduct::getStaticPrice($this->product->product_id, true, null, 6);
     if (JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED) {
         $product_price_with_tax = JeproshopTools::roundPrice($product_price_with_tax, 2);
     }
     $product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
     $ecotax_rate = (double) JeproshopTaxModelTax::getProductEcotaxRate($this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')});
     $ecotax_tax_amount = JeproshopTools::roundPrice($this->product->ecotax, 2);
     if (JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED && (int) JeproshopSettingModelSetting::getValue('use_tax')) {
         $ecotax_tax_amount = JeproshopTools::roundPrice($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
     }
     $currency_id = (int) $this->context->cookie->currency_id;
     $product_id = (int) $this->product->product_id;
     $shop_id = $this->context->shop->shop_id;
     $quantity_discounts = JeproshopSpecificPriceModelSpecificPrice::getQuantityDiscounts($product_id, $shop_id, $currency_id, $country_id, $group_id, null, true, (int) $this->context->customer->customer_id);
     foreach ($quantity_discounts as &$quantity_discount) {
         if ($quantity_discount->product_attribute_id) {
             $combination = new JeproshopCombinationModelCombination((int) $quantity_discount->product_attribute_id);
             $attributes = $combination->getAttributesName((int) $this->context->language->lang_id);
             foreach ($attributes as $attribute) {
                 $quantity_discount->attributes = $attribute->name . ' - ';
             }
             $quantity_discount->attributes = rtrim($quantity_discount->attributes, ' - ');
         }
         if ((int) $quantity_discount->currency_id == 0 && $quantity_discount->reduction_type == 'amount') {
             $quantity_discount->reduction = JeproshopTools::convertPriceFull($quantity_discount->reduction, null, JeproshopContext::getContext()->currency);
         }
     }
     $product_price = $this->product->getPrice(JeproshopProductModelProduct::$_taxCalculationMethod == COM_JEPROSHOP_TAX_INCLUDED, false);
     $address = new JeproshopAddressModelAddress($this->context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')});
     $quantity_discounts = $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $ecotax_tax_amount);
     $this->assignRef('quantity_discounts', $quantity_discounts);
     $this->assignRef('ecotax_tax_included', $ecotax_tax_amount);
     $ecotax_tax_excluded = JeproshopTools::roundPrice($this->product->ecotax, 2);
     $this->assignRef('ecotax_tax_excluded', $ecotax_tax_excluded);
     $this->assignRef('ecotaxTax_rate', $ecotax_rate);
     $display_price = JeproshopSettingModelSetting::getValue('display_price');
     $this->assignRef('display_price', $display_price);
     $product_price_without_eco_tax = (double) $product_price_without_eco_tax;
     $this->assignRef('product_price_without_ecotax', $product_price_without_eco_tax);
     $this->assignRef('group_reduction', $group_reduction);
     $no_tax = JeproshopTaxModelTax::taxExcludedOption() || !$this->product->getTaxesRate($address);
     $this->assignRef('no_tax', $no_tax);
     $ecotax = !count($this->errors) && $this->product->ecotax > 0 ? JeproshopTools::convertPrice((double) $this->product->ecotax) : 0;
     $this->assignRef('ecotax', $ecotax);
     $tax_enabled = JeproshopSettingModelSetting::getValue('use_tax');
     $this->assignRef('tax_enabled', $tax_enabled);
     $customer_group_without_tax = JeproshopGroupModelGroup::getPriceDisplayMethod($this->context->customer->default_group_id);
     $this->assignRef('customer_group_without_tax', $customer_group_without_tax);
 }
Esempio n. 21
0
 public static function getValueForProduct($product_id, $group_id)
 {
     if (!JeproshopGroupModelGroup::isFeaturePublished()) {
         return 0;
     }
     if (!isset(self::$reduction_cache[$product_id . '_' . $group_id])) {
         $db = JFactory::getDBO();
         $query = "SELECT " . $db->quoteName('reduction') . " FROM " . $db->quoteName('#__jeproshop_product_group_reduction_cache') . " WHERE ";
         $query .= $db->quoteName('product_id') . " = " . (int) $product_id . " AND " . $db->quoteName('group_id') . " = " . (int) $group_id;
         $db->setQuery($query);
         self::$reduction_cache[$product_id . '_' . $group_id] = $db->loadResult();
     }
     // Should return string (decimal in database) and not a float
     return self::$reduction_cache[$product_id . '_' . $group_id];
 }
Esempio n. 22
0
 /**
  * Price calculation / Get product price
  *
  * @param integer $shop_id Shop id
  * @param integer $product_id Product id
  * @param integer $product_attribute_id Product attribute id
  * @param integer $country_id Country id
  * @param integer $state_id State id
  * @param $zipcode
  * @param integer $currency_id Currency id
  * @param integer $group_id Group id
  * @param integer $quantity Quantity Required for Specific prices : quantity discount application
  * @param boolean $use_tax with (1) or without (0) tax
  * @param integer $decimals Number of decimals returned
  * @param boolean $only_reduction Returns only the reduction amount
  * @param boolean $use_reduction Set if the returned amount will include reduction
  * @param boolean $with_ecotax insert ecotax in price output.
  * @param $specific_price
  * @param $use_group_reduction
  * @param int $customer_id
  * @param bool $use_customer_price
  * @param int $cart_id
  * @param int $real_quantity
  * @internal param \variable_reference $specific_price_output If a specific price applies regarding the previous parameters, this variable is filled with the corresponding SpecificPrice object*    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 priceCalculation($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, $use_group_reduction, $customer_id = 0, $use_customer_price = true, $cart_id = 0, $real_quantity = 0)
 {
     static $address = null;
     static $context = null;
     if ($address === null) {
         $address = new JeproshopAddressModelAddress();
     }
     if ($context == null) {
         $context = JeproshopContext::getContext()->cloneContext();
     }
     if ($shop_id !== null && $context->shop->shop_id != (int) $shop_id) {
         $context->shop = new JeproshopShopModelShop((int) $shop_id);
     }
     if (!$use_customer_price) {
         $customer_id = 0;
     }
     if ($product_attribute_id === null) {
         $product_attribute_id = JeproshopProductModelProduct::getDefaultAttribute($product_id);
     }
     $cache_id = $product_id . '_' . $shop_id . '_' . $currency_id . '_' . $country_id . '_' . $state_id . '_' . $zipcode . '_' . $group_id . '_' . $quantity . '_' . $product_attribute_id . '_' . ($use_tax ? '1' : '0') . '_' . $decimals . '_' . ($only_reduction ? '1' : '0') . '_' . ($use_reduction ? '1' : '0') . '_' . $with_ecotax . '_' . $customer_id . '_' . (int) $use_group_reduction . '_' . (int) $cart_id . '-' . (int) $real_quantity;
     // reference parameter is filled before any returns
     $specific_price = JeproshopSpecificPriceModelSpecificPrice::getSpecificPrice((int) $product_id, $shop_id, $currency_id, $country_id, $group_id, $quantity, $product_attribute_id, $customer_id, $cart_id, $real_quantity);
     if (isset(self::$_prices[$cache_id])) {
         return self::$_prices[$cache_id];
     }
     $db = JFactory::getDBO();
     // fetch price & attribute price
     $cache_id_2 = $product_id . '-' . $shop_id;
     if (!isset(self::$_pricesLevel2[$cache_id_2])) {
         $select = "SELECT product_shop." . $db->quoteName('price') . ", product_shop." . $db->quoteName('ecotax');
         $from = $db->quoteName('#__jeproshop_product') . " AS product INNER JOIN " . $db->quoteName('#__jeproshop_product_shop');
         $from .= " AS product_shop ON (product_shop.product_id =product.product_id AND product_shop.shop_id = " . (int) $shop_id . ")";
         if (JeproshopCombinationModelCombination::isFeaturePublished()) {
             $select .= ", product_attribute_shop.product_attribute_id, product_attribute_shop." . $db->quoteName('price') . " AS attribute_price, product_attribute_shop.default_on";
             $leftJoin = " LEFT JOIN " . $db->quoteName('#__jeproshop_product_attribute') . " AS product_attribute ON product_attribute.";
             $leftJoin .= $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . " LEFT JOIN " . $db->quoteName('#__jeproshop_product_attribute_shop');
             $leftJoin .= " AS product_attribute_shop ON (product_attribute_shop.product_attribute_id = product_attribute.product_attribute_id AND product_attribute_shop.shop_id = " . (int) $shop_id . ")";
         } else {
             $select .= ", 0 as product_attribute_id";
             $leftJoin = "";
         }
         $query = $select . " FROM " . $from . $leftJoin . " WHERE product." . $db->quoteName('product_id') . " = " . (int) $product_id;
         $db->setQuery($query);
         $results = $db->loadObjectList();
         foreach ($results as $row) {
             $array_tmp = array('price' => $row->price, 'ecotax' => $row->ecotax, 'attribute_price' => isset($row->attribute_price) ? $row->attribute_price : null);
             self::$_pricesLevel2[$cache_id_2][(int) $row->product_attribute_id] = $array_tmp;
             if (isset($row->default_on) && $row->default_on == 1) {
                 self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
             }
         }
     }
     if (!isset(self::$_pricesLevel2[$cache_id_2][(int) $product_attribute_id])) {
         return;
     }
     $result = self::$_pricesLevel2[$cache_id_2][(int) $product_attribute_id];
     if (!$specific_price || $specific_price->price < 0) {
         $price = (double) $result['price'];
     } else {
         $price = (double) $specific_price->price;
     }
     // convert only if the specific price is in the default currency (id_currency = 0)
     if (!$specific_price || !($specific_price->price >= 0 && $specific_price->currency_id)) {
         $price = JeproshopTools::convertPrice($price, $currency_id);
     }
     // Attribute price
     if (is_array($result) && (!$specific_price || !$specific_price->product_attribute_id || $specific_price->price < 0)) {
         $attribute_price = JeproshopTools::convertPrice($result['attribute_price'] !== null ? (double) $result['attribute_price'] : 0, $currency_id);
         // If you want the default combination, please use NULL value instead
         if ($product_attribute_id !== false) {
             $price += $attribute_price;
         }
     }
     // Tax
     $address->country_id = $country_id;
     $address->state_id = $state_id;
     $address->postcode = $zipcode;
     $tax_manager = JeproshopTaxManagerFactory::getManager($address, JeproshopProductModelProduct::getTaxRulesGroupIdByProductId((int) $product_id, $context));
     $product_tax_calculator = $tax_manager->getTaxCalculator();
     // Add Tax
     if ($use_tax) {
         $price = $product_tax_calculator->addTaxes($price);
     }
     // Reduction
     $specific_price_reduction = 0;
     if (($only_reduction || $use_reduction) && $specific_price) {
         if ($specific_price->reduction_type == 'amount') {
             $reduction_amount = $specific_price->reduction;
             if (!$specific_price->currency_id) {
                 $reduction_amount = JeproshopTools::convertPrice($reduction_amount, $currency_id);
             }
             $specific_price_reduction = !$use_tax ? $product_tax_calculator->removeTaxes($reduction_amount) : $reduction_amount;
         } else {
             $specific_price_reduction = $price * $specific_price->reduction;
         }
     }
     if ($use_reduction) {
         $price -= $specific_price_reduction;
     }
     // Group reduction
     if ($use_group_reduction) {
         $reduction_from_category = JeproshopGroupReductionModelGroupReduction::getValueForProduct($product_id, $group_id);
         if ($reduction_from_category !== false) {
             $group_reduction = $price * (double) $reduction_from_category;
         } else {
             // apply group reduction if there is no group reduction for this category
             $group_reduction = ($reduction = JeproshopGroupModelGroup::getReductionByGroupId($group_id)) != 0 ? $price * $reduction / 100 : 0;
         }
     } else {
         $group_reduction = 0;
     }
     if ($only_reduction) {
         return JeproshopTools::roundPrice($group_reduction + $specific_price_reduction, $decimals);
     }
     if ($use_reduction) {
         $price -= $group_reduction;
     }
     // Eco Tax
     if (($result['ecotax'] || isset($result['attribute_ecotax'])) && $with_ecotax) {
         $ecotax = $result['ecotax'];
         if (isset($result['attribute_ecotax']) && $result['attribute_ecotax'] > 0) {
             $ecotax = $result['attribute_ecotax'];
         }
         if ($currency_id) {
             $ecotax = JeproshopTools::convertPrice($ecotax, $currency_id);
         }
         if ($use_tax) {
             // reinit the tax manager for ecotax handling
             $tax_manager = JeproshopTaxManagerFactory::getManager($address, (int) JeproshopSettingModelSetting::getValue('ecotax_tax_rules_group_id'));
             $ecotax_tax_calculator = $tax_manager->getTaxCalculator();
             $price += $ecotax_tax_calculator->addTaxes($ecotax);
         } else {
             $price += $ecotax;
         }
     }
     $price = JeproshopTools::roundPrice($price, $decimals);
     if ($price < 0) {
         $price = 0;
     }
     self::$_prices[$cache_id] = $price;
     return self::$_prices[$cache_id];
 }
Esempio n. 23
0
 public function __construct($order_id = null, $lang_id = null)
 {
     if ($lang_id !== NULL) {
         $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== FALSE ? (int) $lang_id : (int) JeproshopSettingModelSetting::getValue('default_lang');
     }
     if ($order_id) {
         $cache_id = 'jeproshop_order_model_' . $order_id . '_' . $lang_id . ($this->shop_id ? '_' . $this->shop_id : '');
         if (!JeproshopCache::isStored($cache_id)) {
             $db = JFactory::getDBO();
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord ";
             $where = "";
             /** get language information **/
             if ($lang_id) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_order_lang') . " AS order_lang ";
                 $query .= " ON (ord.order_id = order_lang.order_id AND order_lang.lang_id = " . (int) $lang_id . ") ";
                 if ($this->shop_id && !empty($this->multiLangShop)) {
                     $where = " AND order_lang.shop_id = " . $this->shop_id;
                 }
             }
             /** Get shop informations **/
             if (JeproshopShopModelShop::isTableAssociated('order')) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_order_shop') . " AS order_shop ON (";
                 $query .= "ord.order_id = order_shop.order_id AND order_shop.shop_id = " . (int) $this->shop_id . ")";
             }
             $query .= " WHERE ord.order_id = " . (int) $order_id . $where;
             $db->setQuery($query);
             $order_data = $db->loadObject();
             if ($order_data) {
                 JeproshopCache::store($cache_id, $order_data);
             }
         } else {
             $order_data = JeproshopCache::retrieve($cache_id);
         }
         if ($order_data) {
             $order_data->order_id = $order_id;
             foreach ($order_data as $key => $value) {
                 if (property_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     $this->_taxCalculationMethod = JeproshopGroupModelGroup::getDefaultPriceDisplayMethod();
 }
Esempio n. 24
0
 public static function getCurrentCustomerGroups()
 {
     if (!JeproshopGroupModelGroup::isFeaturePublished()) {
         return array();
     }
     $context = JeproshopContext::getContext();
     if (!isset($context->customer) || !$context->customer->customer_id) {
         return array();
     }
     if (!is_array(self::$currentCustomerGroups)) {
         self::$currentCustomerGroups = array();
         $db = JFactory::getDBO();
         $query = "SELECT group_id FROM " . $db->quoteName('#__jeproshop_customer_group') . " WHERE customer_id = " . (int) $context->customer->customer_id;
         $db->setQuery($query);
         $result = $db->loadObjectList();
         foreach ($result as $row) {
             self::$currentCustomerGroups[] = $row->group_id;
         }
     }
     return self::$currentCustomerGroups;
 }