Exemple #1
0
 function show()
 {
     $user = hikashop_loadUser(true);
     $userClass = hikashop_get('class.user');
     $userClass->loadPartnerData($user);
     $config =& hikashop_config();
     if (empty($user->user_params->user_custom_fee)) {
         $user->user_params->user_partner_click_fee = $config->get('partner_click_fee', 0);
         $user->user_params->user_partner_lead_fee = $config->get('partner_lead_fee', 0);
         $user->user_params->user_partner_percent_fee = $config->get('partner_percent_fee', 0);
         $user->user_params->user_partner_flat_fee = $config->get('partner_flat_fee', 0);
     }
     $query = 'SELECT * FROM ' . hikashop_table('banner') . ' WHERE banner_published=1 ORDER BY banner_ordering ASC;';
     $database = JFactory::getDBO();
     $database->setQuery($query);
     $banners = $database->loadObjectList();
     $this->assignRef('banners', $banners);
     $advanced_stats = $config->get('affiliate_advanced_stats', 1);
     $this->assignRef('advanced_stats', $advanced_stats);
     $this->assignRef('user', $user);
     $currencyType = hikashop_get('type.currency');
     $this->assignRef('currencyType', $currencyType);
     $currencyHelper = hikashop_get('class.currency');
     $this->assignRef('currencyHelper', $currencyHelper);
     $popup = hikashop_get('helper.popup');
     $this->assignRef('popup', $popup);
     JHTML::_('behavior.tooltip');
     $affiliate_plugin = hikashop_import('system', 'hikashopaffiliate');
     $partner_id = (int) @$user->user_id;
     $this->assignRef('partner_id', $partner_id);
     $partner_info = $affiliate_plugin->params->get('partner_key_name', 'partner_id') . '=' . $partner_id;
     $this->assignRef('partner_info', $partner_info);
     $allow_currency_selection = $config->get('allow_currency_selection');
     $this->assignRef('allow_currency_selection', $allow_currency_selection);
     if (empty($this->user->user_id)) {
         $app = JFactory::getApplication();
         global $Itemid;
         $url = '';
         if (!empty($Itemid)) {
             $url = '&Itemid=' . $Itemid;
         }
         if (!HIKASHOP_J16) {
             $url = 'index.php?option=com_user&view=login' . $url;
         } else {
             $url = 'index.php?option=com_users&view=login' . $url;
         }
         $url = JRoute::_($url . '&return=' . urlencode(base64_encode(hikashop_currentUrl('', false))));
         $app->enqueueMessage('<a href="' . $url . '">' . JText::_('PLEASE_LOGIN_FIRST') . '</a>');
     }
     $config =& hikashop_config();
     $affiliate_terms = $config->get('affiliate_terms', 0);
     $this->assignRef('affiliate_terms', $affiliate_terms);
     hikashop_setPageTitle('AFFILIATE');
 }
Exemple #2
0
 function listing()
 {
     $user_id = hikashop_loadUser();
     $addresses = array();
     $fields = null;
     if ($user_id) {
         $addressClass = hikashop_get('class.address');
         $addresses = $addressClass->getByUser($user_id);
         if (!empty($addresses)) {
             $addressClass->loadZone($addresses);
             $fields =& $addressClass->fields;
         }
     }
     $this->assignRef('user_id', $user_id);
     $this->assignRef('fields', $fields);
     $this->assignRef('addresses', $addresses);
     $fieldsClass = hikashop_get('class.field');
     $this->assignRef('fieldsClass', $fieldsClass);
     $popup = hikashop_get('helper.popup');
     $this->assignRef('popup', $popup);
     hikashop_setPageTitle('ADDRESSES');
 }
Exemple #3
0
 function show()
 {
     $type = 'order';
     $order =& $this->_order($type);
     $config =& hikashop_config();
     $download_time_limit = $config->get('download_time_limit', 0);
     $this->assignRef('download_time_limit', $download_time_limit);
     $download_number_limit = $config->get('download_number_limit', 0);
     $this->assignRef('download_number_limit', $download_number_limit);
     $order_status_download_ok = false;
     $order_status_for_download = $config->get('order_status_for_download', 'confirmed,shipped');
     if (in_array($order->order_status, explode(',', $order_status_for_download))) {
         $order_status_download_ok = true;
     }
     $this->assignRef('order_status_download_ok', $order_status_download_ok);
     $popup = hikashop_get('helper.popup');
     $this->assignRef('popup', $popup);
     hikashop_setPageTitle(JText::_('HIKASHOP_ORDER') . ':' . $this->element->order_number);
 }
Exemple #4
0
 function show()
 {
     $app = JFactory::getApplication();
     $product_id = (int) hikashop_getCID('product_id');
     $config =& hikashop_config();
     $this->assignRef('config', $config);
     global $Itemid;
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     if (empty($menu) && !empty($Itemid)) {
         $menus->setActive($Itemid);
         $menu = $menus->getItem($Itemid);
     }
     if (empty($product_id) && is_object($menu)) {
         jimport('joomla.html.parameter');
         $category_params = new HikaParameter($menu->params);
         $product_id = $category_params->get('product_id');
         if (is_array($product_id)) {
             $product_id = (int) $product_id[0];
         } else {
             $product_id = (int) $product_id;
         }
         JRequest::setVar('product_id', $product_id);
     }
     if (empty($product_id)) {
         return;
     }
     $filters = array('a.product_id=' . $product_id);
     hikashop_addACLFilters($filters, 'product_access', 'a');
     $query = 'SELECT a.*, b.product_category_id, b.category_id, b.ordering FROM ' . hikashop_table('product') . ' AS a LEFT JOIN ' . hikashop_table('product_category') . ' AS b ON a.product_id = b.product_id WHERE ' . implode(' AND ', $filters) . ' LIMIT 1';
     $database = JFactory::getDBO();
     $database->setQuery($query);
     $element = $database->loadObject();
     if (empty($element)) {
         return;
     }
     $this->modules = $config->get('product_show_modules', '');
     $module = hikashop_get('helper.module');
     $this->modules = $module->setModuleData($this->modules);
     $currencyClass = hikashop_get('class.currency');
     $productClass = hikashop_get('class.product');
     $default_params = $config->get('default_params');
     $empty = '';
     jimport('joomla.html.parameter');
     $params = new HikaParameter($empty);
     foreach ($default_params as $k => $param) {
         $params->set($k, $param);
     }
     $main_currency = (int) $config->get('main_currency', 1);
     $params->set('main_currency', $main_currency);
     $discount_before_tax = (int) $config->get('discount_before_tax', 0);
     $params->set('discount_before_tax', $discount_before_tax);
     $catalogue = (int) $config->get('catalogue', 0);
     $params->set('catalogue', $catalogue);
     $show_price_weight = (int) $config->get('show_price_weight', 0);
     $params->set('show_price_weight', $show_price_weight);
     $params->set('price_with_tax', $config->get('price_with_tax'));
     $currency_id = hikashop_getCurrency();
     $zone_id = hikashop_getZone(null);
     $params->set('characteristic_display', $config->get('characteristic_display', 'table'));
     $params->set('characteristic_display_text', $config->get('characteristic_display_text', 1));
     $params->set('show_quantity_field', $config->get('show_quantity_field', 1));
     $this->assignRef('params', $params);
     $cart = hikashop_get('helper.cart');
     $this->assignRef('cart', $cart);
     $this->selected_variant_id = 0;
     if ($element->product_type == 'variant') {
         $this->selected_variant_id = $product_id;
         $filters = array('a.product_id=' . $element->product_parent_id);
         hikashop_addACLFilters($filters, 'product_access', 'a');
         $query = 'SELECT a.*,b.* FROM ' . hikashop_table('product') . ' AS a LEFT JOIN ' . hikashop_table('product_category') . ' AS b ON a.product_id = b.product_id WHERE ' . implode(' AND ', $filters) . ' ORDER BY product_category_id ASC LIMIT 1';
         $database->setQuery($query);
         $element = $database->loadObject();
         if (empty($element)) {
             return;
         }
         $product_id = $element->product_id;
         JRequest::setVar('product_id', $product_id);
     }
     if (!isset($_SESSION['hikashop_viewed_products'])) {
         $_SESSION['hikashop_viewed_products'] = array();
     } else {
         $arr = array_reverse($_SESSION['hikashop_viewed_products'], true);
     }
     $arr[$product_id] = $product_id;
     $_SESSION['hikashop_viewed_products'] = array_reverse($arr, true);
     $productClass->addAlias($element);
     if (!$element->product_published) {
         return;
     }
     $prod = new stdClass();
     $prod->product_id = $product_id;
     $prod->product_hit = $element->product_hit + 1;
     $prod->product_last_seen_date = time();
     $productClass->save($prod, true);
     $filters = array('a.product_id =' . $product_id, 'a.product_related_type=\'options\'', 'b.product_published=1', '(b.product_sale_start=\'\' OR b.product_sale_start<=' . time() . ')', '(b.product_sale_end=\'\' OR b.product_sale_end>' . time() . ')');
     hikashop_addACLFilters($filters, 'product_access', 'b');
     $query = 'SELECT b.* FROM ' . hikashop_table('product_related') . ' AS a LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_related_id	= b.product_id WHERE ' . implode(' AND ', $filters) . ' ORDER BY a.product_related_ordering ASC, a.product_related_id ASC';
     $database->setQuery($query);
     $element->options = $database->loadObjectList('product_id');
     $ids = array($product_id);
     if (!empty($element->options)) {
         foreach ($element->options as $optionElement) {
             $ids[] = (int) $optionElement->product_id;
         }
     }
     $filters = array('product_parent_id IN (' . implode(',', $ids) . ')');
     hikashop_addACLFilters($filters, 'product_access');
     $query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE ' . implode(' AND ', $filters);
     $database->setQuery($query);
     $variants = $database->loadObjectList();
     if (!empty($variants)) {
         foreach ($variants as $variant) {
             $ids[] = (int) $variant->product_id;
             if ($variant->product_parent_id == $product_id) {
                 $element->variants[$variant->product_id] = $variant;
             }
             if (!empty($element->options)) {
                 foreach ($element->options as $k => $optionElement) {
                     if ($variant->product_parent_id == $optionElement->product_id) {
                         $element->options[$k]->variants[$variant->product_id] = $variant;
                         break;
                     }
                 }
             }
         }
     }
     $sort = $config->get('characteristics_values_sorting');
     if ($sort == 'old') {
         $order = 'characteristic_id ASC';
     } elseif ($sort == 'alias') {
         $order = 'characteristic_alias ASC';
     } elseif ($sort == 'ordering') {
         $order = 'characteristic_ordering ASC';
     } else {
         $order = 'characteristic_value ASC';
     }
     $query = 'SELECT a.*,b.* FROM ' . hikashop_table('variant') . ' AS a INNER JOIN ' . hikashop_table('characteristic') . ' AS b ON a.variant_characteristic_id=b.characteristic_id WHERE a.variant_product_id IN (' . implode(',', $ids) . ') ORDER BY a.ordering ASC,b.' . $order;
     $database->setQuery($query);
     $characteristics = $database->loadObjectList();
     if (!empty($characteristics)) {
         $mainCharacteristics = array();
         foreach ($characteristics as $characteristic) {
             if ($product_id == $characteristic->variant_product_id) {
                 $mainCharacteristics[$product_id][$characteristic->characteristic_parent_id][$characteristic->characteristic_id] = $characteristic;
             }
             if (!empty($element->options)) {
                 foreach ($element->options as $k => $optionElement) {
                     if ($optionElement->product_id == $characteristic->variant_product_id) {
                         $mainCharacteristics[$optionElement->product_id][$characteristic->characteristic_parent_id][$characteristic->characteristic_id] = $characteristic;
                     }
                 }
             }
         }
         JPluginHelper::importPlugin('hikashop');
         $dispatcher = JDispatcher::getInstance();
         $dispatcher->trigger('onAfterProductCharacteristicsLoad', array(&$element, &$mainCharacteristics, &$characteristics));
         if (!empty($element->variants)) {
             $this->addCharacteristics($element, $mainCharacteristics, $characteristics);
             $this->orderVariants($element);
         }
         if (!empty($element->options)) {
             foreach ($element->options as $k => $optionElement) {
                 if (!empty($optionElement->variants)) {
                     $this->addCharacteristics($element->options[$k], $mainCharacteristics, $characteristics);
                     if (count(@$mainCharacteristics[$optionElement->product_id][0])) {
                         $this->orderVariants($element->options[$k]);
                     }
                 }
             }
         }
     }
     $query = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $ids) . ') AND file_type IN (\'product\',\'file\') ORDER BY file_ordering ASC, file_id ASC';
     $database->setQuery($query);
     $product_files = $database->loadObjectList();
     if (!empty($product_files)) {
         $productClass->addFiles($element, $product_files);
     }
     $currencyClass->getPrices($element, $ids, $currency_id, $main_currency, $zone_id, $discount_before_tax);
     $fieldsClass = hikashop_get('class.field');
     $fields = $fieldsClass->getFields('frontcomp', $element, 'product', 'checkout&task=state');
     $this->assignRef('fieldsClass', $fieldsClass);
     $this->assignRef('fields', $fields);
     if (hikashop_level(2)) {
         $itemFields = $fieldsClass->getFields('frontcomp', $element, 'item', 'checkout&task=state');
         $null = array();
         $fieldsClass->addJS($null, $null, $null);
         $fieldsClass->jsToggle($itemFields, $element, 0);
         $this->assignRef('itemFields', $itemFields);
         $extraFields = array('item' => &$itemFields);
         $requiredFields = array();
         $validMessages = array();
         $values = array('item' => $element);
         $fieldsClass->checkFieldsForJS($extraFields, $requiredFields, $validMessages, $values);
         $fieldsClass->addJS($requiredFields, $validMessages, array('item'));
     }
     $this->checkVariants($element);
     if (!empty($element->options)) {
         foreach ($element->options as $k => $optionElement) {
             $this->checkVariants($element->options[$k]);
         }
     }
     $this->setDefault($element);
     if (!empty($element->options)) {
         foreach ($element->options as $k => $optionElement) {
             $this->setDefault($element->options[$k]);
         }
     }
     $this->assignRef('element', $element);
     $doc = JFactory::getDocument();
     $product_name = $this->element->product_name;
     $product_page_title = $this->element->product_page_title;
     $product_description = $element->product_meta_description;
     $product_keywords = $element->product_keywords;
     if (!empty($this->element->main)) {
         $product_name = $this->element->main->product_name;
         if (!empty($this->element->main->product_page_title)) {
             $product_page_title = $this->element->main->product_page_title;
         }
         if (!empty($this->element->main->product_meta_description)) {
             $product_description = $this->element->main->product_meta_description;
         }
         if (!empty($this->element->main->product_keywords)) {
             $product_keywords = $this->element->main->product_keywords;
         }
     }
     if (!empty($product_keywords)) {
         $doc->setMetadata('keywords', $product_keywords);
     }
     if (!empty($product_description)) {
         $doc->setMetadata('description', $product_description);
     }
     $parent = 0;
     $url_itemid = '';
     if (!empty($Itemid)) {
         $url_itemid = '&Itemid=' . $Itemid;
     }
     if (empty($menu) || !(strpos($menu->link, 'option=' . HIKASHOP_COMPONENT) !== false && strpos($menu->link, 'view=product') !== false && strpos($menu->link, 'layout=show') !== false)) {
         $pathway = $app->getPathway();
         $config =& hikashop_config();
         $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway');
         $category_pathway = JRequest::getInt($pathway_sef_name, 0);
         if ($category_pathway) {
             $class = hikashop_get('class.category');
             if (!empty($menu->id)) {
                 $menuClass = hikashop_get('class.menus');
                 $menuData = $menuClass->get($menu->id);
                 if (@$menuData->hikashop_params['content_type'] == 'manufacturer') {
                     $new_id = 'manufacturer';
                     $class->getMainElement($new_id);
                     $menuData->hikashop_params['selectparentlisting'] = $new_id;
                 }
                 if (!empty($menuData->hikashop_params['selectparentlisting'])) {
                     $parent = $menuData->hikashop_params['selectparentlisting'];
                 }
             }
             $categories = $class->getParents($category_pathway, $parent);
             $one = true;
             foreach ($categories as $category) {
                 if ($one) {
                     $one = false;
                 } else {
                     $class->addAlias($category);
                     $pathway->addItem($category->category_name, hikashop_completeLink('category&task=listing&cid=' . (int) $category->category_id . '&name=' . $category->alias . $url_itemid));
                 }
             }
         }
         $related_sef_name = $config->get('related_sef_name', 'related_product');
         $related = JRequest::getInt($related_sef_name, 0);
         if ($config->get('simplified_breadcrumbs', 1) || !$category_pathway) {
             $category_pathway = '';
         } else {
             $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway');
             $category_pathway = '&' . $pathway_sef_name . '=' . $category_pathway;
         }
         if (!empty($related)) {
             $class = hikashop_get('class.product');
             $prod = $class->get($related);
             if (!empty($prod)) {
                 $class->addAlias($prod);
                 $pathway->addItem($prod->product_name, hikashop_completeLink('product&task=show&cid=' . (int) $prod->product_id . '&name=' . $prod->alias . $category_pathway . $url_itemid));
             }
         }
         $pathway->addItem($product_name, hikashop_completeLink('product&task=show&cid=' . (int) $element->product_id . '&name=' . $element->alias . $category_pathway . $url_itemid));
     }
     $classbadge = hikashop_get('class.badge');
     $this->assignRef('classbadge', $classbadge);
     $classbadge->loadBadges($element);
     $links = new stdClass();
     $links->previous = '';
     $links->next = '';
     if ($config->get('show_other_product_shortcut')) {
         $filters = array('b.product_published=1', 'b.product_type=\'main\'');
         $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway');
         $category_id = JRequest::getInt($pathway_sef_name, '');
         if (empty($category_id) && is_object($menu) && !empty($menu->id)) {
             $menuClass = hikashop_get('class.menus');
             $menuData = $menuClass->get($menu->id);
             if (!empty($menuData->hikashop_params['selectparentlisting'])) {
                 if ($menuData->hikashop_params['filter_type'] == 2) {
                     $menuData->hikashop_params['filter_type'] = $config->get('filter_type');
                 }
                 if (!$menuData->hikashop_params['filter_type']) {
                     $type = 'product';
                     $catName = 'a.category_id';
                     $categoryClass = hikashop_get('class.category');
                     $category = $categoryClass->get($menuData->hikashop_params['selectparentlisting'], true);
                     if (!empty($category->category_type) && $category->category_type == 'manufacturer') {
                         $type = 'manufacturer';
                         $catName = 'b.product_manufacturer_id';
                     }
                     $categoryClass->parentObject =& $this;
                     $categoryClass->type = $type;
                     $children = $categoryClass->getChildren($menuData->hikashop_params['selectparentlisting'], true, array(), '', 0, 0);
                     $filter = $catName . ' IN (';
                     foreach ($children as $child) {
                         $filter .= $child->category_id . ',';
                     }
                     $filters['category'] = $filter . (int) $menuData->hikashop_params['selectparentlisting'] . ')';
                 }
             }
         } else {
             $categoryClass = hikashop_get('class.category');
             $category = $categoryClass->get($category_id, true);
             if (!empty($category->category_type) && $category->category_type == 'manufacturer') {
                 $filters['category'] = 'b.product_manufacturer_id = ' . (int) $category_id;
             }
         }
         if (empty($category_id)) {
             $query = 'SELECT a.category_id FROM ' . hikashop_table('product_category') . ' AS a WHERE a.product_id=' . (int) $product_id . ' ORDER BY a.product_category_id ASC';
             $database->setQuery($query);
             $category_id = $database->loadResult();
             $filters['category'] = 'a.category_id = ' . (int) $category_id;
         }
         if (empty($filters['category'])) {
             $filters['category'] = 'a.category_id = ' . (int) $category_id;
         }
         hikashop_addACLFilters($filters, 'product_access', 'b');
         if ($this->params->get('show_out_of_stock', '-1') == '-1') {
             $this->params->set('show_' . 'out_of_stock', @$config->get('show_out_of_stock', '1'));
         }
         if ($this->params->get('show_out_of_stock') != '1') {
             $filters[] = 'b.product_quantity!=0';
         }
         $query = 'SELECT DISTINCT a.product_id FROM ' . hikashop_table('product_category') . ' AS a LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_id WHERE ' . implode(' AND ', $filters) . ' GROUP BY a.product_id ORDER BY a.ordering ASC';
         $database->setQuery($query);
         if (!HIKASHOP_J25) {
             $articles = $database->loadResultArray();
         } else {
             $articles = $database->loadColumn();
         }
         if (!empty($articles)) {
             foreach ($articles as $k => $article) {
                 if ($article == $element->product_id || $article == $element->product_parent_id) {
                     $links->path = JURI::root();
                     $links->path .= 'media/com_hikashop/images/icons/';
                     $class = hikashop_get('class.product');
                     if (!isset($category_pathway)) {
                         $pathway = '';
                     } else {
                         $pathway = $pathway_sef_name . '=' . $category_pathway;
                     }
                     if ($k != 0) {
                         $p = $k - 1;
                         $id_previous = $articles[$p];
                         $elt = $class->get($id_previous);
                         $class->addAlias($elt);
                         $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway');
                         $links->previous = hikashop_completeLink('product&task=show&cid=' . (int) $id_previous . '&name=' . $elt->alias . '&' . $pathway . $url_itemid);
                         $links->previous_product = $elt;
                     }
                     $n = $k;
                     while (isset($articles[$n]) && ($articles[$n] == $element->product_id || $articles[$n] == $element->product_parent_id)) {
                         $n = $n + 1;
                     }
                     if (isset($articles[$n])) {
                         $id_next = $articles[$n];
                         $elt = $class->get($id_next);
                         $class->addAlias($elt);
                         $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway');
                         $links->next = hikashop_completeLink('product&task=show&cid=' . (int) $id_next . '&name=' . $elt->alias . '&' . $pathway . $url_itemid);
                         $links->next_product = $elt;
                     }
                     break;
                 }
             }
         }
     }
     $this->assignRef('links', $links);
     $image = hikashop_get('helper.image');
     $this->assignRef('image', $image);
     $this->assignRef('currencyHelper', $currencyClass);
     $characteristic = hikashop_get('type.characteristic');
     $this->assignRef('characteristic', $characteristic);
     $query = 'SELECT b.* FROM ' . hikashop_table('product_category') . ' AS a LEFT JOIN ' . hikashop_table('category') . ' AS b ON a.category_id = b.category_id WHERE a.product_id = ' . (int) $prod->product_id . ' ORDER BY a.product_category_id ASC';
     $database->setQuery($query);
     $categories = $database->loadObjectList('category_id');
     $this->assignRef('categories', $categories);
     $productlayout = $element->product_layout;
     $productDisplayType = hikashop_get('type.productdisplay');
     $quantityDisplayType = hikashop_get('type.quantitydisplay');
     if (!empty($element->main->product_layout)) {
         $productlayout = $element->main->product_layout;
     }
     if (!$productDisplayType->check($productlayout, $app->getTemplate())) {
         $productlayout = '';
     }
     $categoryQuantityLayout = '';
     if (!empty($categories)) {
         foreach ($categories as $category) {
             if (empty($productlayout) && !empty($category->category_layout) && $productDisplayType->check($category->category_layout, $app->getTemplate())) {
                 $productlayout = $category->category_layout;
             }
             if (empty($categoryQuantityLayout) && !empty($category->category_quantity_layout) && $quantityDisplayType->check($category->category_quantity_layout, $app->getTemplate())) {
                 $categoryQuantityLayout = $category->category_quantity_layout;
             }
             if (!empty($productlayout) && !empty($categoryQuantityLayout)) {
                 break;
             }
         }
     }
     if (empty($productlayout) && $productDisplayType->check($config->get('product_display'), $app->getTemplate())) {
         $productlayout = $config->get('product_display');
     }
     if (empty($productlayout)) {
         $productlayout = 'show_default';
     }
     $this->assignRef('productlayout', $productlayout);
     if (!empty($product_page_title)) {
         $product_name = $product_page_title;
     }
     hikashop_setPageTitle($product_name);
     $url = $this->init();
     $cart->getJS($url);
     $this->assignRef('redirect_url', $url);
     if ($element->product_parent_id != 0 && isset($element->main_product_quantity_layout)) {
         $element->product_quantity_layout = $element->main_product_quantity_layout;
     }
     if (!empty($element->product_quantity_layout) && $element->product_quantity_layout != 'inherit') {
         $qLayout = $element->product_quantity_layout;
     } elseif (!empty($categoryQuantityLayout) && $categoryQuantityLayout != 'inherit') {
         $qLayout = $categoryQuantityLayout;
     } else {
         $qLayout = $config->get('product_quantity_display', 'show_default');
     }
     JRequest::setVar('quantitylayout', $qLayout);
     $canonical = false;
     if (!empty($element->main->product_canonical)) {
         $canonical = $element->main->product_canonical;
     } elseif (!empty($element->product_canonical)) {
         $canonical = $element->product_canonical;
     }
     if (!$canonical) {
         $force_canonical = $config->get('force_canonical_urls', 1);
         if ($force_canonical) {
             $newObj = new stdClass();
             $newObj->product_id = $element->product_id;
             if (!empty($element->main->product_id)) {
                 $newObj->product_id = $element->main->product_id;
             }
             $newObj->product_canonical = str_replace(HIKASHOP_LIVE, '', hikashop_currentURL());
             if ($force_canonical == 2) {
                 $productClass = hikashop_get('class.product');
                 $productClass->save($newObj);
             }
             $canonical = $newObj->product_canonical;
         }
     }
     $this->assignRef('canonical', $canonical);
 }
Exemple #5
0
 function listing()
 {
     $config =& hikashop_config();
     $this->assignRef('config', $config);
     $module = hikashop_get('helper.module');
     $module->initialize($this);
     $this->paramBase .= '_' . $this->params->get('main_div_name');
     $filters = array();
     $app = JFactory::getApplication();
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $catData = null;
     $database = JFactory::getDBO();
     $defaultParams = $config->get('default_params');
     if (empty($defaultParams['links_on_main_categories'])) {
         $defaultParams['links_on_main_categories'] = 1;
     }
     $params = array('limit' => '', 'order_dir' => 'inherit', 'margin' => '', 'border_visible' => '-1', 'div_item_layout_type' => 'inherit', 'text_center' => '-1', 'columns' => '', 'number_of_products' => '-1', 'background_color' => '', 'link_to_product_page' => '-1', 'only_if_products' => '-1', 'child_display_type' => 'inherit', 'child_limit' => '', 'links_on_main_categories' => '-1', 'layout_type' => 'inherit');
     $data = $this->params->get('data', new stdClass());
     if (isset($data->hk_category) && is_object($data->hk_category)) {
         $categoryId = (int) $this->params->get('category', 0);
         if ($categoryId > 0) {
             $categoryClass = hikashop_get('class.category');
             $cat = $categoryClass->get($categoryId);
             if ($cat->category_type == 'manufacturer') {
                 $this->params->set('content_type', 'manufacturer');
             }
         }
         if (!empty($data->hk_category->category)) {
             $this->params->set('selectparentlisting', (int) $data->hk_category->category);
         }
     }
     foreach ($params as $k => $v) {
         if ($this->params->get($k, $v) == $v) {
             $this->params->set($k, @$defaultParams[$k]);
         }
     }
     if ((int) $this->params->get('limit') == 0) {
         $this->params->set('limit', 1);
     }
     $content_type = $this->params->get('content_type');
     if ($content_type == 'manufacturer') {
         $category_type = 'manufacturer';
         $id = JRequest::getInt("cid");
         $class = hikashop_get('class.category');
         $new_id = 'manufacturer';
         $class->getMainElement($new_id);
         $this->params->set('selectparentlisting', $new_id);
     } else {
         $category_type = 'product';
     }
     if ($this->params->get('content_synchronize')) {
         if (JRequest::getString('option', '') == HIKASHOP_COMPONENT) {
             if (JRequest::getString('ctrl', 'category') == 'product') {
                 $product_id = hikashop_getCID('product_id');
                 if (!empty($product_id)) {
                     $query = 'SELECT category_id FROM ' . hikashop_table('product_category') . ' WHERE product_id=' . $product_id;
                     $database->setQuery($query);
                     if (!HIKASHOP_J25) {
                         $pageInfo->filter->cid = $database->loadResultArray();
                     } else {
                         $pageInfo->filter->cid = $database->loadColumn();
                     }
                 } else {
                     $pageInfo->filter->cid = $this->params->get('selectparentlisting');
                 }
             } elseif (JRequest::getString('ctrl', 'category') == 'category') {
                 $pageInfo->filter->cid = JRequest::getInt("cid", $this->params->get('selectparentlisting'));
             } else {
                 $pageInfo->filter->cid = $this->params->get('selectparentlisting');
             }
         } else {
             $pageInfo->filter->cid = $this->params->get('selectparentlisting');
         }
     } else {
         if (empty($this->module)) {
             $pageInfo->filter->cid = JRequest::getInt("cid", $this->params->get('selectparentlisting'));
         } else {
             $pageInfo->filter->cid = $this->params->get('selectparentlisting');
         }
     }
     if (empty($pageInfo->filter->cid)) {
         $pageInfo->filter->cid = 'product';
     }
     $category_selected = '';
     if (!is_array($pageInfo->filter->cid)) {
         $category_selected = '_' . $pageInfo->filter->cid;
         $this->paramBase .= $category_selected;
     }
     if (!empty($pageInfo->filter->cid)) {
         $acl_filters = array();
         hikashop_addACLFilters($acl_filters, 'category_access');
         if (!empty($acl_filters)) {
             if (!is_array($pageInfo->filter->cid)) {
                 $category = hikashop_get('class.category');
                 $catData = $category->get($pageInfo->filter->cid);
                 if (!empty($catData->category_type)) {
                     $category_type = $catData->category_type;
                 }
                 $pageInfo->filter->cid = array($database->Quote($pageInfo->filter->cid));
             }
             $acl_filters[] = 'category_type=\'' . $category_type . '\'';
             $acl_filters[] = 'category_id IN (' . implode(',', $pageInfo->filter->cid) . ')';
             $query = 'SELECT category_id FROM ' . hikashop_table('category') . ' WHERE ' . implode(' AND ', $acl_filters);
             $database->setQuery($query);
             if (!HIKASHOP_J25) {
                 $pageInfo->filter->cid = $database->loadResultArray();
             } else {
                 $pageInfo->filter->cid = $database->loadColumn();
             }
         }
     }
     $this->assignRef('category_selected', $category_selected);
     if ($this->params->get('category_order', 'inherit') == 'inherit') {
         $defaultParams = $config->get('default_params');
         $this->params->set('category_order', $defaultParams['category_order']);
         if ($this->params->get('category_order', 'inherit') == 'inherit') {
             $this->params->set('category_order', 'category_ordering');
         }
     }
     if ($this->params->get('order_dir', 'inherit') == 'inherit' || $this->params->get('order_dir', 'inherit') == '') {
         $defaultParams = $config->get('default_params');
         $this->params->set('order_dir', @$defaultParams['order_dir']);
         if ($this->params->get('order_dir', 'inherit') == 'inherit' || $this->params->get('order_dir', 'inherit') == '') {
             $this->params->set('order_dir', 'ASC');
         }
     }
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir_' . $this->params->get('main_div_name') . $category_selected, $this->params->get('order_dir', 'ASC'), 'word');
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order_' . $this->params->get('main_div_name') . $category_selected, 'a.' . $this->params->get('category_order', 'category_ordering'), 'cmd');
     if (!in_array(strtoupper($pageInfo->filter->order->dir), array('ASC', 'DESC'))) {
         $pageInfo->filter->order->dir = 'ASC';
     }
     $oldValue = $app->getUserState($this->paramBase . '.list_limit');
     if ($this->params->get('limit', '') == '') {
         $defaultParams = $config->get('default_params');
         $this->params->set('limit', $defaultParams['limit']);
     }
     if (empty($oldValue)) {
         $oldValue = $this->params->get('limit');
     }
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit_' . $this->params->get('main_div_name') . $category_selected, $this->params->get('limit'), 'int');
     if ($oldValue != $pageInfo->limit->value) {
         JRequest::setVar('limitstart_' . $this->params->get('main_div_name') . $category_selected, 0);
     }
     $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart_' . $this->params->get('main_div_name') . $category_selected, 0, 'int');
     if (empty($this->module)) {
         if ($config->get('hikarss_format') != 'none') {
             $doc_title = $config->get('hikarss_name', '');
             if (empty($doc_title)) {
                 if (!isset($catData)) {
                     $category = hikashop_get('class.category');
                     if (is_array($pageInfo->filter->cid)) {
                         $cat = reset($pageInfo->filter->cid);
                     } else {
                         $cat = $pageInfo->filter->cid;
                     }
                     $catData = $category->get($cat);
                 }
                 if ($catData) {
                     $doc_title = $catData->category_name;
                 }
             }
             if (!HIKASHOP_PHP5) {
                 $doc =& JFactory::getDocument();
             } else {
                 $doc = JFactory::getDocument();
             }
             if ($config->get('hikarss_format') != 'both') {
                 $link = '&format=feed&limitstart=';
                 $attribs = array('type' => 'application/rss+xml', 'title' => $doc_title . ' RSS 2.0');
                 $doc->addHeadLink(JRoute::_($link . '&type=' . $config->get('hikarss_format')), 'alternate', 'rel', $attribs);
             } else {
                 $link = '&format=feed&limitstart=';
                 $attribs = array('type' => 'application/rss+xml', 'title' => $doc_title . ' RSS 2.0');
                 $doc->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
                 $attribs = array('type' => 'application/atom+xml', 'title' => $doc_title . ' Atom 1.0');
                 $doc->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
             }
         }
         $cid = JRequest::getInt("cid", 0);
         if (empty($cid)) {
             JRequest::setVar("no_cid", 1);
         }
         if (is_array($pageInfo->filter->cid)) {
             JRequest::setVar("cid", reset($pageInfo->filter->cid));
         } else {
             JRequest::setVar("cid", $pageInfo->filter->cid);
         }
         JRequest::setVar('menu_main_category', $this->params->get('selectparentlisting'));
     }
     $searchMap = array('a.category_name', 'a.category_description', 'a.category_id');
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir;
     }
     if ($this->params->get('random', '-1') == '-1') {
         $defaultParams = $config->get('default_params');
         $this->params->set('random', $defaultParams['random']);
     }
     if ($this->params->get('random')) {
         $order = ' ORDER BY RAND()';
     }
     $class = hikashop_get('class.category');
     $class->parentObject =& $this;
     if ($this->params->get('filter_type', 2) == 2) {
         $config =& hikashop_config();
         $defaultParams = $config->get('default_params');
         $this->params->set('filter_type', $defaultParams['filter_type']);
     }
     $rows = $class->getChildren($pageInfo->filter->cid, $this->params->get('filter_type'), $filters, $order, $pageInfo->limit->start, $pageInfo->limit->value, true);
     $pageInfo->elements = new stdClass();
     if (!empty($class->query)) {
         $database->setQuery('SELECT COUNT(*) ' . $class->query);
         $pageInfo->elements->total = $database->loadResult();
         $pageInfo->elements->page = count($rows);
     } else {
         $pageInfo->elements->total = 0;
         $pageInfo->elements->page = 0;
     }
     if ($pageInfo->elements->page) {
         $ids = array();
         foreach ($rows as $key => $row) {
             $ids[(int) $row->category_id] = (int) $row->category_id;
             $class->addAlias($rows[$key]);
         }
         if ($this->params->get('number_of_products', '-1') == '-1') {
             $defaultParams = $config->get('default_params');
             $this->params->set('number_of_products', @$defaultParams['number_of_products']);
         }
         if ($this->params->get('only_if_products', '-1') == '-1') {
             $defaultParams = $config->get('default_params');
             $this->params->set('only_if_products', @$defaultParams['only_if_products']);
         }
         $number_of_products = $this->params->get('number_of_products', 0) || $this->params->get('only_if_products', 0);
         if ($this->params->get('child_display_type', 'inherit') == 'inherit') {
             $defaultParams = $config->get('default_params');
             $this->params->set('child_display_type', $defaultParams['child_display_type']);
         }
         if ($this->params->get('child_display_type') != 'nochild' || $number_of_products) {
             $childs = $class->getChildren($ids, true, array(), $order, 0, 0, false);
             if (!empty($childs)) {
                 $this->_associateChilds($rows, $childs);
                 foreach ($childs as $child) {
                     if (is_numeric($child)) {
                         $ids[$child] = $child;
                     } else {
                         $ids[(int) $child->category_id] = (int) $child->category_id;
                     }
                 }
             }
             if ($number_of_products) {
                 $additional_condition = '';
                 if ($content_type == 'manufacturer') {
                     if (!$config->get('show_out_of_stock', 1)) {
                         $additional_condition = ' AND a.product_quantity!=0';
                     }
                     $database->setQuery('SELECT count(a.product_id) AS number_of_products,a.product_manufacturer_id as category_id FROM ' . hikashop_table('product') . ' AS a WHERE a.product_published>0' . $additional_condition . ' AND a.product_parent_id=0 AND a.product_manufacturer_id IN (' . implode(',', $ids) . ') GROUP BY a.product_manufacturer_id');
                 } else {
                     if (!$config->get('show_out_of_stock', 1)) {
                         $additional_condition = ' AND b.product_quantity!=0';
                     }
                     $database->setQuery('SELECT count(a.product_id) AS number_of_products,a.category_id FROM ' . hikashop_table('product_category') . ' AS a INNER JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_id AND b.product_published>0' . $additional_condition . ' AND b.product_parent_id=0 WHERE a.category_id IN (' . implode(',', $ids) . ') GROUP BY a.category_id');
                 }
                 $counts = $database->loadObjectList('category_id');
                 $this->_getCount($rows, $counts);
             }
         }
     }
     $this->assignRef('rows', $rows);
     $this->assignRef('modules', $this->modules);
     $image = hikashop_get('helper.image');
     $this->assignRef('image', $image);
     $this->assignRef('category_image', $category_image);
     $menu_id = '';
     if (empty($this->module)) {
         if (is_array($pageInfo->filter->cid)) {
             $pageInfo->filter->cid = reset($pageInfo->filter->cid);
         }
         $element = $class->get($pageInfo->filter->cid, true);
         $fieldsClass = hikashop_get('class.field');
         $fields = $fieldsClass->getFields('frontcomp', $element, 'category', 'checkout&task=state');
         $this->assignRef('fieldsClass', $fieldsClass);
         $this->assignRef('fields', $fields);
         $this->assignRef('element', $element);
         $use_module = $this->params->get('use_module_name');
         $title = $this->params->get('page_title');
         if (empty($title)) {
             $title = $this->params->get('title');
         }
         if (empty($use_module) && !empty($element->category_name)) {
             $title = $element->category_name;
         }
         if (!empty($element->category_page_title)) {
             $page_title = $element->category_page_title;
         } else {
             $page_title = $title;
         }
         hikashop_setPageTitle($page_title);
         $this->params->set('page_title', $title);
         if (!HIKASHOP_PHP5) {
             $document =& JFactory::getDocument();
         } else {
             $document = JFactory::getDocument();
         }
         if (!empty($element->category_keywords)) {
             $document->setMetadata('keywords', $element->category_keywords);
         }
         if (!empty($element->category_meta_description)) {
             $document->setMetadata('description', $element->category_meta_description);
         }
         $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
         $pagination->hikaSuffix = '_' . $this->params->get('main_div_name') . $category_selected;
         $this->assignRef('pagination', $pagination);
         $this->params->set('show_limit', 1);
         if (!HIKASHOP_PHP5) {
             $pathway =& $app->getPathway();
         } else {
             $pathway = $app->getPathway();
         }
         $categories = $class->getParents($cid, $this->params->get('selectparentlisting'));
         global $Itemid;
         if (!empty($Itemid)) {
             $menu_id = '&Itemid=' . $Itemid;
         }
         $one = true;
         if (is_array($categories)) {
             foreach ($categories as $category) {
                 if ($one) {
                     $one = false;
                 } else {
                     $class->addAlias($category);
                     $alias = $category->alias;
                     $pathway->addItem($category->category_name, hikashop_completeLink('category&task=listing&cid=' . (int) $category->category_id . '&name=' . $alias . $menu_id));
                 }
             }
         }
     } else {
         $menu_id = $this->params->get('itemid', 0);
         if (!empty($menu_id)) {
             $menu_id = '&Itemid=' . $menu_id;
         } else {
             $menu_id = '';
         }
     }
     $this->assignRef('pageInfo', $pageInfo);
     $this->assignRef('menu_id', $menu_id);
     $this->assignRef('params', $this->params);
 }
Exemple #6
0
    function step()
    {
        $module = hikashop_get('helper.module');
        $module->initialize($this);
        $config =& hikashop_config();
        $this->display_checkout_bar = $config->get('display_checkout_bar', 2);
        $this->continueShopping = $config->get('continue_shopping');
        $step = JRequest::getInt('step', 0);
        if (!isset($this->steps[$step])) {
            $step = 0;
        }
        JPluginHelper::importPlugin('hikashop');
        $dispatcher = JDispatcher::getInstance();
        $display = trim($this->steps[$step]);
        $layouts = explode('_', $display);
        foreach ($layouts as $layout) {
            $layout = trim($layout);
            if (method_exists($this, $layout)) {
                $this->{$layout}();
            } else {
                $dispatcher->trigger('onInitCheckoutStep', array($layout, &$this));
            }
        }
        $this->assignRef('steps', $this->steps);
        $this->assignRef('step', $step);
        $this->assignRef('layouts', $layouts);
        $js = '
function isSelected(radiovar){
	if(radiovar.checked){
		return true;
	}
	for(var a=0; a < radiovar.length; a++){
		if(radiovar[a].checked && radiovar[a].value.length>0) return true;
	}
	return false;
}

function hikashopCheckMethods() {
	var varform =  document["hikashop_checkout_form"];

	if(typeof varform.elements["hikashop_payment"] != "undefined" && !isSelected(varform.elements[\'hikashop_payment\'])) {
		alert("' . JText::_('SELECT_PAYMENT', true) . '");
		return false;
	}

	if(typeof varform.elements["hikashop_shippings"] != "undefined") {
		var shippings = varform.elements["hikashop_shippings"];
		if(shippings) {
			shippings = shippings.value.split(";");
			if(shippings.length > 1) {
				for(var i = 0; i < shippings.length; i++) {
					if(!varform.elements["hikashop_shipping_" + shippings[i] ] || !isSelected(varform.elements["hikashop_shipping_" + shippings[i] ])) {
						alert("' . JText::_('SELECT_SHIPPING', true) . '");
						return false;
					}
				}
			}else{
				if(typeof varform.elements["hikashop_shipping"] != "undefined" && !isSelected(varform.elements[\'hikashop_shipping\'])) {
					alert("' . JText::_('SELECT_SHIPPING', true) . '");
					return false;
				}
			}
		}
	}

	return true;
}';
        if (!HIKASHOP_PHP5) {
            $doc =& JFactory::getDocument();
        } else {
            $doc = JFactory::getDocument();
        }
        $doc->addScriptDeclaration("\n<!--\n" . $js . "\n//-->\n");
        $this->assignRef('doc', $doc);
        $app = JFactory::getApplication();
        $this->assignRef('app', $app);
        global $Itemid;
        $url_itemid = '';
        if (!empty($Itemid)) {
            $url_itemid = '&Itemid=' . $Itemid;
        }
        $this->assignRef('url_itemid', $url_itemid);
        $this->assignRef('continueShopping', $this->continueShopping);
        $this->assignRef('display_checkout_bar', $this->display_checkout_bar);
        $cart = hikashop_get('helper.cart');
        $this->assignRef('cart', $cart);
        hikashop_setPageTitle('CHECKOUT');
    }
Exemple #7
0
 function form()
 {
     $this->registration();
     hikashop_setPageTitle('HIKA_REGISTRATION');
 }
Exemple #8
0
 function showcarts()
 {
     $app = JFactory::getApplication();
     $config = hikashop_config();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     global $Itemid;
     if (empty($menu)) {
         if (!empty($Itemid)) {
             $menus->setActive($Itemid);
             $menu = $menus->getItem($Itemid);
         }
     }
     if (is_object($menu) && is_object($menu->params)) {
         $cart_type = $menu->params->get('cart_type');
     }
     if (!empty($cart_type)) {
         JRequest::setVar('cart_type', $cart_type);
     } else {
         $cart_type = JRequest::getString('cart_type', 'cart');
         if (!in_array($cart_type, array('cart', 'wishlist'))) {
             $cart_type = 'cart';
         }
     }
     $this->assignRef('cart_type', $cart_type);
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.cart_id', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
     $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string');
     $pageInfo->search = JString::strtolower(trim($pageInfo->search));
     $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
     $oldValue = $app->getUserState($this->paramBase . '.list_limit');
     if (empty($oldValue)) {
         $oldValue = $app->getCfg('list_limit');
     }
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
     if ($oldValue != $pageInfo->limit->value) {
         $pageInfo->limit->start = 0;
         $app->setUserState($this->paramBase . '.limitstart', 0);
     }
     $database = JFactory::getDBO();
     $searchMap = array('a.cart_id', 'a.cart_name', 'a.cart_type');
     if (hikashop_loadUser() == null) {
         global $Itemid;
         $url = '';
         if (!empty($Itemid)) {
             $url = '&Itemid=' . $Itemid;
         }
         if (!HIKASHOP_J16) {
             $url = 'index.php?option=com_user&view=login' . $url;
         } else {
             $url = 'index.php?option=com_users&view=login' . $url;
         }
         if ($config->get('enable_multicart', '0')) {
             $app->redirect(JRoute::_($url . '&return=' . urlencode(base64_encode(hikashop_currentUrl('', false))), false));
         } else {
             $app->redirect(JRoute::_($url . '&return=' . base64_encode(hikashop_completeLink('cart&task=showcart&cart_type=' . $cart_type . '&Itemid=' . $Itemid, false, false, true)), false));
         }
         return false;
     }
     $user = hikashop_loadUser(true);
     if (isset($user->user_cms_id)) {
         $user->id = $user->user_cms_id;
     } else {
         if (empty($user)) {
             $user = new stdClass();
         }
         $user->id = 0;
     }
     $session = JFactory::getSession();
     if ($session->getId()) {
         $user->session = $session->getId();
     } else {
         $user->session = '';
     }
     if (hikashop_loadUser() == null) {
         $filters = array('a.session_id=' . $database->Quote($user->session) . ' AND a.cart_type =' . $database->quote($cart_type));
     } else {
         $filters = array('(a.user_id=' . (int) $user->id . ' OR a.session_id=' . $database->Quote($user->session) . ') AND a.cart_type =' . $database->quote($cart_type));
     }
     $groupBy = 'GROUP BY a.cart_id';
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = 'ORDER BY a.cart_id ASC';
     }
     if (!empty($pageInfo->search)) {
         $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\'';
         $filter = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}";
         $filters[] = $filter;
     }
     $from = 'FROM ' . hikashop_table('cart') . ' AS a';
     $cartProduct = 'LEFT JOIN ' . hikashop_table('cart_product') . ' AS b ON a.cart_id=b.cart_id';
     $where = 'WHERE (' . implode(') AND (', $filters) . ') AND a.cart_type =' . $database->quote($cart_type);
     $query = $from . ' ' . $where . ' ' . $groupBy . ' ' . $order;
     //'.$cartProduct.'
     $database->setQuery('SELECT a.* ' . $query);
     $rows = $database->loadObjectList();
     $database->setQuery('SELECT COUNT(*) ' . $from . ' ' . $where);
     $currencyClass = hikashop_get('class.currency');
     $this->assignRef('currencyHelper', $currencyClass);
     $module = hikashop_get('helper.module');
     $module->initialize($this);
     $currencyClass = hikashop_get('class.currency');
     $class = hikashop_get('class.cart');
     $productClass = hikashop_get('class.product');
     $main_currency = (int) $config->get('main_currency', 1);
     $currency_id = hikashop_getCurrency();
     if ($config->get('tax_zone_type', 'shipping') == 'billing') {
         $zone_id = hikashop_getZone('billing');
     } else {
         $zone_id = hikashop_getZone('shipping');
     }
     $discount_before_tax = (int) $config->get('discount_before_tax', 0);
     $cids = array();
     foreach ($rows as $row) {
         if ($row->cart_id != null) {
             $cids[] = $row->cart_id;
         }
     }
     $filters = '';
     $filters = array('a.cart_id IN(' . implode(",", $cids) . ')');
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = ' ORDER BY cart_id ASC';
     }
     $product = ' LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_id';
     $query = 'FROM ' . hikashop_table('cart_product') . ' AS a ' . $product . ' WHERE (' . implode(') AND (', $filters) . ') ' . $order;
     $database->setQuery('SELECT a.*,b.* ' . $query);
     if (!empty($cids)) {
         $products = $database->loadObjectList();
         $ids = array();
         foreach ($products as $row) {
             $ids[] = $row->product_id;
         }
         $row_1 = 0;
         foreach ($products as $k => $row) {
             $currencyClass->getPrices($row, $ids, $currency_id, $main_currency, $zone_id, $discount_before_tax);
             if (!isset($row->prices[0]->price_value)) {
                 if (isset($row_1->prices[0])) {
                     $row->prices[0] = $row_1->prices[0];
                 }
             }
             $products[$k]->hide = 0;
             if ($row->product_type == 'variant') {
                 $l = --$k;
                 if (isset($products[$l])) {
                     if (!isset($products[$l]) || !is_object($products[$l])) {
                         $products[$l] = new stdClass();
                     }
                     $products[$l]->hide = 1;
                 }
             }
             $row_1 = $row;
         }
         $currentId = 0;
         $values = null;
         $price = 0;
         $price_with_tax = 0;
         $quantity = 0;
         $currency = hikashop_getCurrency();
         foreach ($products as $product) {
             if (isset($product->cart_id) && isset($product->product_id)) {
                 if ($product->cart_id != $currentId) {
                     $price = 0;
                     $price_with_tax = 0;
                     $quantity = 0;
                     $currentId = $product->cart_id;
                     if (isset($product->prices[0]->price_currency_id)) {
                         $currency = $product->prices[0]->price_currency_id;
                     }
                 }
                 if (isset($product->prices[0])) {
                     $price += $product->cart_product_quantity * $product->prices[0]->price_value;
                 }
                 if (isset($product->prices[0]->price_value_with_tax)) {
                     $price_with_tax += $product->cart_product_quantity * $product->prices[0]->price_value_with_tax;
                 }
                 if (!isset($product->prices[0]->price_value)) {
                     $variant = new stdClass();
                     $variant->product_parent_id = $product->product_parent_id;
                     $variant->quantity = $product->cart_product_quantity;
                 }
                 if (isset($variant) && isset($product->prices[0]) && $product->product_id == $variant->product_parent_id) {
                     $price += $variant->quantity * $product->prices[0]->price_value;
                     $price_with_tax += $variant->quantity * $product->prices[0]->price_value_with_tax;
                 }
                 $quantity += $product->cart_product_quantity;
                 if (!isset($values[$currentId])) {
                     $values[$currentId] = new stdClass();
                 }
                 $values[$currentId]->price = $price;
                 $values[$currentId]->price_with_tax = isset($price_with_tax) ? $price_with_tax : $price;
                 $values[$currentId]->quantity = $quantity;
                 $values[$currentId]->currency = $currency;
             }
         }
         $totalCart = 0;
         $limit = 0;
         foreach ($rows as $k => $row) {
             if ($limit >= (int) $pageInfo->limit->start && $limit < (int) $pageInfo->limit->value && isset($values[$row->cart_id]) && $values[$row->cart_id] != null) {
                 $rows[$k]->price = $values[$row->cart_id]->price;
                 $rows[$k]->price_with_tax = $values[$row->cart_id]->price_with_tax;
                 $rows[$k]->quantity = $values[$row->cart_id]->quantity;
                 $rows[$k]->currency = $values[$row->cart_id]->currency;
                 $totalCart++;
             } else {
                 unset($rows[$k]);
                 $limit--;
             }
             $limit++;
         }
     }
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = count($rows);
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'cart_id');
     }
     $pageInfo->elements->page = count($rows);
     if (!$pageInfo->elements->page) {
         if (hikashop_loadUser() != null) {
             $app = JFactory::getApplication();
             if ($cart_type == 'cart') {
                 $app->enqueueMessage(JText::_('HIKA_NO_CARTS_FOUND'));
             } else {
                 $app->enqueueMessage(JText::_('HIKA_NO_WISHLISTS_FOUND'));
             }
         }
     }
     jimport('joomla.html.pagination');
     $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
     $pagination->hikaSuffix = '';
     $this->assignRef('pagination', $pagination);
     $this->assignRef('pageInfo', $pageInfo);
     $cart = hikashop_get('helper.cart');
     $this->assignRef('cart', $cart);
     $this->assignRef('config', $config);
     $this->assignRef('carts', $rows);
     if ($cart_type == 'cart') {
         $title = JText::_('CARTS');
     } else {
         $title = JText::_('WISHLISTS');
     }
     hikashop_setPageTitle($title);
 }
Exemple #9
0
        $classes[] = 'hikashop_product_of_category_' . $category->category_id;
    }
}
?>
<div id="hikashop_product_<?php 
echo preg_replace('#[^a-z0-9]#i', '_', @$this->element->product_code);
?>
_page" class="hikashop_product_page <?php 
echo implode(' ', $classes);
?>
">
<?php 
$app = JFactory::getApplication();
if (empty($this->element)) {
    $app->enqueueMessage(JText::_('PRODUCT_NOT_FOUND'));
    hikashop_setPageTitle(JText::_('PRODUCT_NOT_FOUND'));
    echo '</div>';
    return;
}
if (!empty($this->links->previous)) {
    echo "<a title='" . JText::_('PREVIOUS_PRODUCT') . "' href='" . $this->links->previous . "'><span class='hikashop_previous_product'></span></a>";
}
if (!empty($this->links->next)) {
    echo "<a title='" . JText::_('NEXT_PRODUCT') . "' href='" . $this->links->next . "'><span class='hikashop_next_product'></span></a>";
}
?>
	<div class='clear_both'></div>
	<form action="<?php 
echo hikashop_completeLink('product&task=updatecart');
?>
" method="post" name="hikashop_product_form" onsubmit="return hikashop_product_form_check();" enctype="multipart/form-data">