} $html = $this->loadTemplate($layout_type); if (!empty($html)) { echo '<div class="hikashop_subcategories_listing">' . $html . '</div>'; } if (!$this->module) { $data = $this->params->get('data'); if (isset($data->hk_product) && is_object($data->hk_product)) { $js = ''; $empty = ''; jimport('joomla.html.parameter'); $params = new HikaParameter($empty); foreach ($data->hk_product as $k => $v) { $params->set($k, $v); } $main_div_name = 'hikashop_category_information_module_' . $params->get('id'); $params->set('main_div_name', $main_div_name); echo '<div class="hikashop_submodules" style="clear:both">' . hikashop_getLayout('product', 'listing', $params, $js) . '</div>'; } else { if (!empty($this->modules)) { $html = ''; jimport('joomla.application.module.helper'); foreach ($this->modules as $module) { $html .= JModuleHelper::renderModule($module); } if (!empty($html)) { echo '<div class="hikashop_submodules" style="clear:both">' . $html . '</div>'; } } } }
public function updatecart() { hikashop_nocache(); $app = JFactory::getApplication(); $product_id = (int) JRequest::getCmd('product_id', 0); $module_id = (int) JRequest::getCmd('module_id', 0); $cart_type = JRequest::getString('hikashop_cart_type_' . $product_id . '_' . $module_id, 'null'); if ($cart_type == 'null') { $cart_type = JRequest::getString('hikashop_cart_type_' . $module_id, 'null'); } if ($cart_type == 'null') { $cart_type = JRequest::getString('cart_type', 'cart'); } $cart_type_id = $cart_type . '_id'; $class = hikashop_get('class.cart'); $class->cart_type = $cart_type; $cart_id = 0; if ($class->hasCart(JRequest::getInt('cart_id', 0, 'GET'))) { $cart_id = $class->cart->cart_id; } $addTo = JRequest::getString('add_to', ''); if ($addTo != '') { $from_id = $cart_id; if ($addTo == 'cart') { JRequest::setVar('from_id', $cart_id); } $cart_id = $app->getUserState(HIKASHOP_COMPONENT . '.' . $addTo . '_id', 0); $cart_type_id = $addTo . '_id'; JRequest::setVar('cart_type', $addTo); } else { JRequest::setVar('cart_type', $cart_type); } JRequest::setVar($cart_type_id, $cart_id); $char = JRequest::getString('characteristic', ''); if (!empty($char)) { return $this->show(); } $tmpl = JRequest::getCmd('tmpl', 'index'); $add = JRequest::getCmd('add', ''); if (!empty($add)) { $add = 1; } else { $add = 0; } if (empty($product_id)) { $product_id = JRequest::getCmd('cid', 0); } $cart_product_id = JRequest::getCmd('cart_product_id', 0); $quantity = JRequest::getInt('quantity', 1); if (hikashop_loadUser() != null || $cart_type != 'wishlist') { if (!empty($product_id)) { $type = JRequest::getWord('type', 'product'); if ($type == 'product') { $product_id = (int) $product_id; } $status = $class->update($product_id, $quantity, $add, $type); } elseif (!empty($cart_product_id)) { $status = $class->update($cart_product_id, $quantity, $add, 'item'); } else { $formData = JRequest::getVar('item', array(), '', 'array'); if (!empty($formData)) { $class->update($formData, 0, $add, 'item'); } else { $formData = JRequest::getVar('data', array(), '', 'array'); if (!empty($formData)) { $class->update($formData, 0, $add); } } } } $app->setUserState(HIKASHOP_COMPONENT . '.' . $cart_type . '_new', '1'); if (@$class->errors && $tmpl != 'component') { if (!empty($_SERVER['HTTP_REFERER'])) { if (strpos($_SERVER['HTTP_REFERER'], HIKASHOP_LIVE) === false && preg_match('#^https?://.*#', $_SERVER['HTTP_REFERER'])) { return false; } $app->redirect(str_replace('&popup=1', '', $_SERVER['HTTP_REFERER'])); } else { echo '<html><head><script type="text/javascript">history.back();</script></head><body></body></html>'; exit; } } $app->setUserState(HIKASHOP_COMPONENT . '.shipping_method', null); $app->setUserState(HIKASHOP_COMPONENT . '.shipping_id', null); $app->setUserState(HIKASHOP_COMPONENT . '.shipping_data', null); $app->setUserState(HIKASHOP_COMPONENT . '.payment_method', null); $app->setUserState(HIKASHOP_COMPONENT . '.payment_id', null); $app->setUserState(HIKASHOP_COMPONENT . '.payment_data', null); $config =& hikashop_config(); $checkout = JRequest::getString('checkout', ''); if (!empty($checkout)) { global $Itemid; $url = 'checkout'; if (!empty($Itemid)) { $url .= '&Itemid=' . $Itemid; } $url = hikashop_completeLink($url, false, true); $this->setRedirect($url); } else { if ($cart_type == 'wishlist') { $app->setUserState(HIKASHOP_COMPONENT . '.popup_cart_type', 'wishlist'); if (hikashop_loadUser() == null) { $url = JRequest::getVar('return_url', ''); if (!empty($url)) { $url = base64_decode(urldecode($url)); } $url = str_replace(array('&popup=1', '?popup=1'), '', $url); if ($config->get('redirect_url_after_add_cart', 'stay_if_cart') != 'ask_user') { $app->enqueueMessage(JText::_('LOGIN_REQUIRED_FOR_WISHLISTS')); } if ($tmpl != 'component') { if (!empty($_SERVER['HTTP_REFERER'])) { if (strpos($_SERVER['HTTP_REFERER'], HIKASHOP_LIVE) === false && preg_match('#^https?://.*#', $_SERVER['HTTP_REFERER'])) { return false; } if ($config->get('redirect_url_after_add_cart', 'stay_if_cart') == 'ask_user') { $app->enqueueMessage(JText::_('LOGIN_REQUIRED_FOR_WISHLISTS')); } $app->redirect(str_replace('&popup=1', '', $_SERVER['HTTP_REFERER'])); } } else { echo 'notLogged'; exit; } } else { $redirectConfig = $config->get('redirect_url_after_add_cart', 'stay_if_cart'); $url = ''; $stay = 0; switch ($redirectConfig) { case 'ask_user': $url = JRequest::getVar('return_url', ''); if (!empty($url)) { $url = base64_decode(urldecode($url)); } $url = str_replace(array('&popup=1', '?popup=1'), '', $url); if (JRequest::getInt('popup', 0) && empty($_COOKIE['popup']) || JRequest::getInt('quantity', 0)) { if (strpos($url, '?')) { $url .= '&'; } else { $url .= '?'; } $url .= 'popup=1'; $app->setUserState(HIKASHOP_COMPONENT . '.popup', '1'); } JRequest::setVar('cart_type', 'wishlist'); break; case 'stay': $stay = 1; break; //$stay = 1; && $url =''; //$stay = 1; && $url =''; case 'checkout': break; //$stay = 0; && $url =''; //$stay = 0; && $url =''; case 'stay_if_cart': default: $module = JModuleHelper::getModule('hikashop_wishlist', false); if ($module != null) { $stay = 1; } break; } if ($redirectConfig != 'checkout') { $module = JModuleHelper::getModule('hikashop_wishlist', false); $params = new HikaParameter(@$module->params); if (!empty($module)) { $module_options = $config->get('params_' . $module->id); } if (empty($module_options)) { $module_options = $config->get('default_params'); } $data = $params->get('hikashopwishlistmodule'); if (HIKASHOP_J30 && (empty($data) || !is_object($data))) { $db = JFactory::getDBO(); $query = 'SELECT params FROM ' . hikashop_table('modules', false) . ' WHERE id = ' . (int) $module->id; $db->setQuery($query); $itemData = json_decode($db->loadResult()); if (!empty($itemData->hikashopwishlistmodule) && is_object($itemData->hikashopwishlistmodule)) { $data = $itemData->hikashopwishlistmodule; $params->set('hikashopwishlistmodule', $data); } } if (!empty($data) && is_object($data)) { foreach ($data as $k => $v) { $module_options[$k] = $v; } } foreach ($module_options as $key => $optionElement) { $params->set($key, $optionElement); } if (!empty($module)) { foreach (get_object_vars($module) as $k => $v) { if (!is_object($v)) { $params->set($k, $v); } } $params->set('from', 'module'); } $params->set('return_url', $url); $params->set('cart_type', 'wishlist'); $js = ''; hikashop_getLayout('product', 'cart', $params, $js); } } if (empty($url)) { global $Itemid; if (isset($from_id)) { $cart_id = $from_id; } if (JRequest::getInt('new_' . $cart_type . '_id', 0) != 0 && JRequest::getInt('delete', 0) == 0) { $cart_id = JRequest::getInt('new_' . $cart_type . '_id', 0); } $cart = $class->get($cart_id, false, $cart_type); if (!empty($cart) && (int) $cart_id != 0) { $url = 'cart&task=showcart&cart_type=wishlist&cart_id=' . $cart_id . '&Itemid=' . $Itemid; } else { $url = 'cart&task=showcarts&cart_type=wishlist&Itemid=' . $Itemid; } $url = hikashop_completeLink($url, false, true); } if (!isset($stay)) { $stay = JRequest::getInt('stay', 0); } if ($stay == 0) { if (hikashop_disallowUrlRedirect($url)) { return false; } if (JRequest::getVar('from_form', true)) { JRequest::setVar('cart_type', 'wishlist'); $this->setRedirect($url); return false; } else { ob_clean(); echo 'URL|' . $url; exit; } } else { echo '<html><head><script type="text/javascript">history.back();</script></head><body></body></html>'; exit; } } else { $app->setUserState(HIKASHOP_COMPONENT . '.popup_cart_type', 'cart'); $url = JRequest::getVar('return_url', ''); if (empty($url)) { $url = JRequest::getVar('url', ''); $url = urldecode($url); } else { $url = base64_decode(urldecode($url)); } $url = str_replace(array('&popup=1', '?popup=1'), '', $url); if (hikashop_disallowUrlRedirect($url)) { $url = ''; } if (empty($url)) { global $Itemid; $url = 'checkout'; if (!empty($Itemid)) { $url .= '&Itemid=' . $Itemid; } $url = hikashop_completeLink($url, false, true); } $params = new HikaParameter(@$module->params); if ($tmpl == 'component' && $config->get('redirect_url_after_add_cart', 'stay_if_cart') != 'checkout') { $js = ''; jimport('joomla.application.module.helper'); global $Itemid; if (isset($Itemid) && empty($Itemid)) { $Itemid = null; JRequest::setVar('Itemid', null); } $module = JModuleHelper::getModule('hikashop_cart', false); $config =& hikashop_config(); $params = new HikaParameter(@$module->params); if (!empty($module)) { $module_options = $config->get('params_' . $module->id); } if (empty($module_options)) { $module_options = $config->get('default_params'); } $data = $params->get('hikashopcartmodule'); if (HIKASHOP_J30 && (empty($data) || !is_object($data))) { $db = JFactory::getDBO(); $query = 'SELECT params FROM ' . hikashop_table('modules', false) . ' WHERE id = ' . (int) $module->id; $db->setQuery($query); $itemData = json_decode($db->loadResult()); if (!empty($itemData->hikashopcartmodule) && is_object($itemData->hikashopcartmodule)) { $data = $itemData->hikashopcartmodule; $params->set('hikashopcartmodule', $data); } } if (!empty($data) && is_object($data)) { foreach ($data as $k => $v) { $module_options[$k] = $v; } } foreach ($module_options as $key => $optionElement) { $params->set($key, $optionElement); } if (!empty($module)) { foreach (get_object_vars($module) as $k => $v) { if (!is_object($v)) { $params->set($k, $v); } } $params->set('from', 'module'); } $params->set('return_url', $url); hikashop_getLayout('product', 'cart', $params, $js); return true; } else { $config =& hikashop_config(); $url = str_replace(array('&popup=1', '?popup=1'), '', $url); if (JRequest::getInt('popup', 0) || @JRequest::getInt('quantity', 0) && $config->get('redirect_url_after_add_cart', 'stay_if_cart') == 'ask_user') { if (strpos($url, '?')) { $url .= '&'; } else { $url .= '?'; } $url .= 'popup=1'; $app->setUserState(HIKASHOP_COMPONENT . '.popup', '1'); } if (JRequest::getInt('hikashop_ajax', 0) == 0) { // $config->get('ajax_add_to_cart','1') == '0'){ $this->setRedirect($url); return false; } else { ob_clean(); if ($params->get('from', 'module') != 'module' || $config->get('redirect_url_after_add_cart', 'stay_if_cart') == 'checkout') { echo 'URL|' . $url; exit; } else { $this->setRedirect($url); return false; } } } } } }
function compare() { if (!hikashop_level(2)) { return; } $app = JFactory::getApplication(); $cids = JRequest::getVar('cid', array(), '', 'array'); $config =& hikashop_config(); $this->assignRef('config', $config); global $Itemid; $menus = $app->getMenu(); $menu = $menus->getActive(); if (empty($menu)) { if (!empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } } if (empty($cids)) { if (is_object($menu)) { jimport('joomla.html.parameter'); $category_params = new HikaParameter($menu->params); $cids = $category_params->get('product_id'); if (!is_array($cids)) { $cids = array($cids); } foreach ($cids as $k => $cid) { if ($k > 7) { unset($cids[$k]); } } } } if (empty($cids)) { return; } $c = array(); foreach ($cids as $cid) { if (strpos($cid, ',') !== false) { $c = array_merge($c, explode(',', $cid)); } else { $c[] = (int) $cid; } } $cids = $c; JArrayHelper::toInteger($cids); $empty = ''; $default_params = $config->get('default_params'); 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); $params->set('show_compare', (int) $config->get('show_compare', 0)); $compare_limit = (int) $config->get('compare_limit', 5); $params->set('compare_limit', $compare_limit); $compare_inc_lastseen = (int) $config->get('compare_inc_lastseen', 0); $params->set('compare_inc_lastseen', $compare_inc_lastseen); $params->set('compare_show_name_separator', (int) $config->get('compare_show_name_separator', 1)); $params->set('catalogue', (int) $config->get('catalogue', 0)); $params->set('add_to_cart', (int) 1); $params->set('show_price_weight', (int) $config->get('show_price_weight', 0)); $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); if (count($cids) > $compare_limit) { $cids = array_slice($cids, 0, $compare_limit); } $filters = array('a.product_id IN (' . implode(',', $cids) . ')'); hikashop_addACLFilters($filters, 'product_access', 'a'); $query = 'SELECT DISTINCT a.product_id, 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) . ' ORDER BY b.ordering ASC, a.product_id ASC'; $database = JFactory::getDBO(); $database->setQuery($query); $elements = $database->loadObjectList(); if (empty($elements)) { return; } $this->modules = $config->get('product_show_modules', ''); $module = hikashop_get('helper.module'); $this->modules = $module->setModuleData($this->modules); $currencyClass = hikashop_get('class.currency'); $currency_id = hikashop_getCurrency(); $zone_id = hikashop_getZone(null); $cart = hikashop_get('helper.cart'); $this->assignRef('cart', $cart); $this->selected_variant_id = 0; $productClass = hikashop_get('class.product'); $this->assignRef('currencyHelper', $currencyClass); $fieldsClass = hikashop_get('class.field'); $this->assignRef('fieldsClass', $fieldsClass); $classbadge = hikashop_get('class.badge'); $this->assignRef('classbadge', $classbadge); $fields = array(0 => array()); $unset = array(); $done = array(); foreach ($elements as $k => $element) { $product_id = $element->product_id; if (isset($done[$product_id])) { $unset[] = $k; continue; } else { $done[$product_id] = $product_id; } if ($element->product_type == 'variant') { $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) . ' LIMIT 1'; $database->setQuery($query); $elements[$k] = $database->loadObject(); if (empty($elements[$k])) { return; } $k = array_search($product_id, $cids); if ($k !== false) { $cids[$k] = (int) $element->product_id; } } $productClass->addAlias($elements[$k]); if (!$elements[$k]->product_published) { return; } if ($compare_inc_lastseen) { $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); } $f = $fieldsClass->getFields('frontcomp', $element, 'product', 'checkout&task=state'); $fields[$element->product_id] =& $f; foreach ($f as $i => $v) { $fields[0][$i] = $v; } } if (!empty($unset)) { foreach ($unset as $u) { unset($elements[$u]); } } $query = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $cids) . ') AND file_type IN (\'product\',\'file\') ORDER BY file_ref_id ASC, file_ordering ASC, file_id ASC'; $database->setQuery($query); $product_files = $database->loadObjectList(); if (!empty($product_files)) { foreach ($elements as $k => $element) { $productClass->addFiles($elements[$k], $product_files); } } $defaultParams = $config->get('default_params'); $detault_display_type = @$defaultParams['price_display_type']; $currencyClass->getListingPrices($elements, $zone_id, $currency_id, $detault_display_type); $this->assignRef('elements', $elements); $image = hikashop_get('helper.image'); $this->assignRef('image', $image); $this->assignRef('fields', $fields); $url = $this->init(); $cart->getJS($url); $this->assignRef('redirect_url', $url); }
function save(&$element, $skipJoomla = false) { $new = empty($element->user_id); if ($new) { if (empty($element->user_created_ip)) { $element->user_created_ip = hikashop_getIP(); } if (empty($element->user_created)) { $element->user_created = time(); } if (empty($element->user_email) && !empty($element->user_cms_id)) { $user = JFactory::getUser($element->user_cms_id); $element->user_email = $user->email; } elseif (!empty($element->user_email) && empty($element->user_cms_id)) { } } if (isset($element->user_currency_id)) { $app = JFactory::getApplication(); $config =& hikashop_config(); $user = $this->get($element->user_id); if (empty($user->user_currency_id)) { $user->user_currency_id = $config->get('partner_currency'); } $previousPartnerCurrency = $user->user_currency_id; if ($app->isAdmin()) { if ($element->user_currency_id == $config->get('partner_currency')) { $element->user_currency_id = 0; } } elseif ($config->get('allow_currency_selection')) { $currencyClass = hikashop_get('class.currency'); $currency = $currencyClass->get($element->user_currency_id); if (empty($currency->currency_published)) { unset($element->user_currency_id); } } else { unset($element->user_currency_id); } if (!empty($element->user_currency_id)) { $element->user_currency_id = (int) $element->user_currency_id; } } if (!empty($element->user_params)) { $element->user_params = serialize($element->user_params); } JPluginHelper::importPlugin('hikashop'); $dispatcher = JDispatcher::getInstance(); $do = true; if ($new) { $dispatcher->trigger('onBeforeUserCreate', array(&$element, &$do)); } else { $dispatcher->trigger('onBeforeUserUpdate', array(&$element, &$do)); } if (!$do) { return false; } $element->user_id = parent::save($element); if (empty($element->user_id)) { return $element->user_id; } if ($new) { $dispatcher->trigger('onAfterUserCreate', array(&$element)); } else { $dispatcher->trigger('onAfterUserUpdate', array(&$element)); } if ($element->user_id == hikashop_loadUser()) { hikashop_loadUser(null, true); $this->get(false); } if ($new) { $plugin = JPluginHelper::getPlugin('system', 'hikashopgeolocation'); if (!empty($plugin) && hikashop_level(2)) { jimport('joomla.html.parameter'); $params = new HikaParameter($plugin->params); if (!empty($params)) { if ($params->get('user', 1)) { $geo = new stdClass(); $geo->geolocation_ref_id = $element->user_id; $geo->geolocation_type = 'user'; $geo->geolocation_ip = $element->user_created_ip; $class = hikashop_get('class.geolocation'); $class->params =& $params; $class->save($geo); } } } } else { if (!$skipJoomla && !empty($element->user_email)) { if (empty($element->user_cms_id)) { $userData = $this->get($element->user_id); $element->user_cms_id = $userData->user_cms_id; } $user = JFactory::getUser($element->user_cms_id); if (!empty($user) && $element->user_email != $user->email) { $user->email = $element->user_email; $user->save(); } } if (isset($element->user_currency_id)) { $config =& hikashop_config(); if (empty($element->user_currency_id)) { $element->user_currency_id = $config->get('partner_currency'); } if ($element->user_currency_id != $previousPartnerCurrency) { $currencyClass = hikashop_get('class.currency'); $main_currency = (int) $config->get('main_currency', 1); $null = null; $ids = array($previousPartnerCurrency => $previousPartnerCurrency, $element->user_currency_id => $element->user_currency_id, $main_currency => $main_currency); $currencies = $currencyClass->getCurrencies($ids, $null); $srcCurrency = $currencies[$previousPartnerCurrency]; $dstCurrency = $currencies[$element->user_currency_id]; $mainCurrency = $currencies[$main_currency]; $this->_updatePartnerPrice($srcCurrency, $dstCurrency, $mainCurrency, $element, 'click'); $this->_updatePartnerPrice($srcCurrency, $dstCurrency, $mainCurrency, $element, 'order'); $this->_updatePartnerPrice($srcCurrency, $dstCurrency, $mainCurrency, $element, 'user'); } } } return $element->user_id; }