public static function getProductRoute($contentId, $contentCatId, $language) { list($id, $name) = explode(':', $contentId, 2); if (!(include_once rtrim(JPATH_ADMINISTRATOR, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_hikashop' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php')) { return; } $class = hikashop_get('class.product'); $data = $class->get($id); if (empty($link)) { $link = 'index.php?option=com_hikashop&ctrl=product&task=show&cid=' . $id . '&name=' . $name; } $needles = array('layout' => 'listing'); if (!empty($language) && $language != '*' && JLanguageMultilang::isEnabled()) { static::buildLanguageLookup(); if (isset(static::$lang_lookup[$language])) { $link .= '&lang=' . static::$lang_lookup[$language]; $needles['language'] = $language; } } if ($item = self::lookupItem($needles, 'product')) { $link .= '&Itemid=' . $item; } elseif (!empty($needles) && ($item = self::lookupItem(array(), 'product'))) { $link .= '&Itemid=' . $item; } $link = hikashop_contentLink($link, $data, false, true); return $link; }
$group = $this->config->get('group_options', 0); foreach ($this->order->products as $product) { if ($group && $product->order_product_option_parent_id) { continue; } ?> <tr class="row<?php echo $k; ?> "> <td class="hikashop_order_item_name_value"> <?php if ($this->invoice_type == 'order' && !empty($product->product_id)) { ?> <a class="hikashop_order_product_link" href="<?php echo hikashop_contentLink('product&task=show&cid=' . $product->product_id . $url_itemid, $product); ?> "> <?php } ?> <p class="hikashop_order_product_name"> <?php echo $product->order_product_name; ?> <?php if ($this->config->get('show_code')) { ?> <span class="hikashop_product_code_order"><?php echo $product->order_product_code; ?>
function waitlist() { $user = hikashop_loadUser(true); $this->assignRef('element', $user); $app = JFactory::getApplication(); $product_id = (int) hikashop_getCID('product_id'); $config =& hikashop_config(); $this->assignRef('config', $config); $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; } 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) . ' LIMIT 1'; $database->setQuery($query); $main = $database->loadObject(); if (empty($main)) { return; } $main->variants = array($element); $element = $main; $product_id = $element->product_id; $ids = array($element->variants[0]->product_id, $product_id); $query = 'SELECT a.*,b.* FROM ' . hikashop_table('variant') . ' AS a LEFT 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,b.characteristic_value'; $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; } } $cartClass = hikashop_get('class.cart'); $cartClass->addCharacteristics($element, $mainCharacteristics, $characteristics); $productClass = hikashop_get('class.product'); $productClass->checkVariant($element->variants[0], $element); $element = $element->variants[0]; } } $productClass = hikashop_get('class.product'); $productClass->addAlias($element); if (!$element->product_published) { return; } $this->assignRef('product', $element); global $Itemid; $url_itemid = ''; if (!empty($Itemid)) { $url_itemid = '&Itemid=' . $Itemid; } $product_url = hikashop_contentLink('product&task=show&cid=' . (int) $element->product_id . '&name=' . $element->alias . $url_itemid, $element); $this->assignRef('product_url', $product_url); }
<?php /** * @package HikaShop for Joomla! * @version 2.6.1 * @author hikashop.com * @copyright (C) 2010-2016 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); $link = hikashop_contentLink('product&task=show&cid=' . $this->row->product_id . '&name=' . $this->row->alias . $this->itemid . $this->category_pathway, $this->row); if (!empty($this->row->extraData->top)) { echo implode("\r\n", $this->row->extraData->top); } if ($this->config->get('thumbnail', 1)) { ?> <!-- PRODUCT IMG --> <div style="height:<?php echo $this->image->main_thumbnail_y; ?> px;text-align:center;clear:both;" class="hikashop_product_image"> <div style="position:relative;text-align:center;clear:both;width:<?php echo $this->image->main_thumbnail_x; ?> px;margin: auto;" class="hikashop_product_image_subdiv"> <?php if ($this->params->get('link_to_product_page', 1)) { ?> <a href="<?php echo $link; ?>
function getLink($cid, $alias = '') { if (!is_object($cid)) { $obj = new stdClass(); $obj->category_id = $cid; $obj->alias = $alias; $cid = $obj; } if (!empty($cid->override_url)) { return $cid->override_url; } global $Itemid; $config =& hikashop_config(); if (empty($this->module) && !empty($Itemid) && $config->get('forward_to_submenus', 1)) { $app = JFactory::getApplication(); $menus = $app->getMenu(); if (!HIKASHOP_J16) { $query = 'SELECT a.id as itemid FROM `#__menu` as a WHERE a.access = 0 AND a.parent=' . (int) $Itemid; } else { $query = 'SELECT a.id as itemid FROM `#__menu` as a WHERE a.client_id=0 AND a.parent_id=' . (int) $Itemid; } $db = JFactory::getDBO(); $db->setQuery($query); $submenus = $db->loadObjectList(); foreach ($submenus as $submenu) { $menu = $menus->getItem($submenu->itemid); if (!empty($menu) && !empty($menu->link) && strpos($menu->link, 'option=' . HIKASHOP_COMPONENT) !== false && (strpos($menu->link, 'view=category') !== false || strpos($menu->link, 'view=') === false || strpos($menu->link, 'view=product') !== false)) { $params = $config->get('menu_' . $submenu->itemid); if (!empty($params) && $params['selectparentlisting'] == $cid->category_id) { return JRoute::_('index.php?option=com_hikashop&Itemid=' . $submenu->itemid); } } } } $type = 'category'; if (!empty($this->menu_id)) { $parts = explode('=', $this->menu_id); $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getItem($parts[1]); if (!empty($menu) && !empty($menu->link) && strpos($menu->link, 'option=' . HIKASHOP_COMPONENT) !== false && (strpos($menu->link, 'view=') === false || strpos($menu->link, 'view=product') !== false)) { $type = 'product'; } } return hikashop_contentLink($type . '&task=listing&cid=' . $cid->category_id . '&name=' . $cid->alias . $this->menu_id, $cid); }
$params = new HikaParameter($empty); echo $this->cart->displayButton(JText::_('ADD_ME_WAITLIST'), 'add_waitlist', $params, hikashop_completeLink('product&task=waitlist&cid=' . $this->row->product_id . $url_itemid), 'window.location=\'' . str_replace("'", "\\'", hikashop_completeLink('product&task=waitlist&cid=' . $this->row->product_id . $url_itemid)) . '\';return false;'); } if (hikashop_level(1) && $this->params->get('add_to_wishlist') && $wishlistEnabled && !$hideForGuest && $this->config->get('display_add_to_wishlist_for_free_products', '1')) { if (!empty($this->row->has_options)) { if ($this->params->get('add_to_cart', 1)) { echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'), 'choose_options', $this->params, hikashop_contentLink('product&task=show&product_id=' . $this->row->product_id . '&name=' . $this->row->alias . $url_itemid . $this->category_pathway, $this->row), 'window.location = \'' . str_replace("'", "\\'", hikashop_contentLink('product&task=show&product_id=' . $this->row->product_id . '&name=' . $this->row->alias . $url_itemid . $this->category_pathway, $this->row)) . '\';return false;', ''); } } else { echo '<div class="hikashop_add_wishlist">'; echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'), 'add', $this->params, $url, $wishlistAjax, '', @$this->row->product_max_per_order, 1, '', false); echo '<span></span>'; echo '</div>'; } } } ?> </div> <?php } elseif (hikashop_level(1) && $wishlistEnabled && $this->params->get('add_to_wishlist', '1') && $this->config->get('display_add_to_wishlist_for_free_products', '1') && !$hideForGuest && !$this->config->get('display_add_to_cart_for_free_products')) { if (!empty($this->row->has_options)) { if ($this->params->get('add_to_cart', 1)) { echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'), 'choose_options', $this->params, hikashop_contentLink('product&task=show&product_id=' . $this->row->product_id . '&name=' . $this->row->alias . $url_itemid . $this->category_pathway, $this->row), 'window.location = \'' . str_replace("'", "\\'", hikashop_contentLink('product&task=show&product_id=' . $this->row->product_id . '&name=' . $this->row->alias . $url_itemid . $this->category_pathway, $this->row)) . '\';return false;', ''); } } else { $wishlistAjax = 'if(hikashopCheckChangeForm(\'item\'' . $formName . ')){ return hikashopModifyQuantity(\'' . (int) @$this->row->product_id . '\',field,1' . $formName . ',\'wishlist\',' . $module_id . '); } else { return false; }'; echo '<div class="hikashop_add_wishlist">'; echo $this->cart->displayButton(JText::_('ADD_TO_WISHLIST'), 'add', $this->params, $url, $wishlistAjax, '', @$this->row->product_max_per_order, 1, '', false); echo '</div>'; } }
if (isset($cart->images[0])) { $image_options = array('default' => true, 'forcesize' => $this->config->get('image_force_size', true), 'scale' => $this->config->get('image_scale_mode', 'inside')); $img = $this->image->getThumbnail(@$cart->images[0]->file_path, array('width' => $width, 'height' => $height), $image_options); if ($img->success) { echo '<img class="hikashop_product_cart_image" title="' . $this->escape(@$cart->images[0]->file_description) . '" alt="' . $this->escape(@$cart->images[0]->file_name) . '" src="' . $img->url . '"/>'; } } ?> </td> <td data-title="<?php echo JText::_('CART_PRODUCT_NAME'); ?> "> <p class="hikashop_cart_product_name"> <a class="hikashop_no_print" href="<?php echo hikashop_contentLink('product&task=show&cid=' . $cart->product_id . '&name=' . $cart->alias . $url_itemid, $cart); ?> "> <?php if (!isset($cart->bought) || !$cart->bought) { echo $cart->product_name; } else { echo JHTML::tooltip(implode('<br />', $cart->bought), JText::_('HIKA_BOUGHT_BY'), '', $cart->product_name); } if ($this->params->get('show_code')) { echo ' (' . $cart->product_code . ')'; } ?> </a> </p> <?php
function add_waitlist() { JRequest::checkToken('request') || jexit('Invalid Token'); $element = new stdClass(); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['register'] as $column => $value) { hikashop_secureField($column); $element->{$column} = strip_tags($value); } $user = JFactory::getUser(); $app = JFactory::getApplication(); if (empty($element->email) && $user->guest) { $app->enqueueMessage(JText::_('VALID_EMAIL')); return $this->waitlist(); } $config =& hikashop_config(); if (!$config->get('product_waitlist', 0)) { return $this->waitlist(); } $waitlist_subscribe_limit = $config->get('product_waitlist_sub_limit', 10); $product_id = 0; $itemId = JRequest::getVar('Itemid'); $url_itemid = ''; if (!empty($itemId)) { $url_itemid = '&Itemid=' . $itemId; } $alias = ''; if (!empty($element->product_id)) { $class = hikashop_get('class.product'); $product = $class->get((int) $element->product_id); if (!empty($product)) { if ($product->product_type == 'variant') { $db = JFactory::getDBO(); $db->setQuery('SELECT * FROM ' . hikashop_table('variant') . ' AS a LEFT JOIN ' . hikashop_table('characteristic') . ' AS b ON a.variant_characteristic_id=b.characteristic_id WHERE a.variant_product_id=' . (int) $element->product_id . ' ORDER BY a.ordering'); $product->characteristics = $db->loadObjectList(); $parentProduct = $class->get((int) $product->product_parent_id); $class->checkVariant($product, $parentProduct); } $product_id = (int) $product->product_id; $class->addAlias($product); $alias = $product->alias; } } if ($product_id == 0) { return $this->waitlist(); } $email = !empty($element->email) ? $element->email : ''; $name = !empty($element->name) ? $element->name : ''; $db = JFactory::getDBO(); $sql = 'SELECT waitlist_id FROM ' . hikashop_table('waitlist') . ' WHERE email=' . $db->quote($email) . ' AND product_id=' . (int) $product_id; $db->setQuery($sql); $subscription = $db->loadResult(); if (empty($subscription)) { $sql = 'SELECT count(*) FROM ' . hikashop_table('waitlist') . ' WHERE product_id=' . (int) $product_id; $db->setQuery($sql); $subscriptions = $db->loadResult(); if ($subscriptions < $waitlist_subscribe_limit || $waitlist_subscribe_limit <= 0) { $sql = 'INSERT IGNORE INTO ' . hikashop_table('waitlist') . ' (`product_id`,`date`,`email`,`name`,`product_item_id`) VALUES (' . (int) $product_id . ', ' . time() . ', ' . $db->quote($email) . ', ' . $db->quote($name) . ', ' . (int) $itemId . ');'; $db->setQuery($sql); $db->query(); $app->enqueueMessage(JText::_('WAITLIST_SUBSCRIBE')); $subject = JText::_('WAITLIST_REQUEST'); if (!empty($product->product_name)) { $subject = JText::sprintf('WAITLIST_REQUEST_FOR_PRODUCT', strip_tags($product->product_name)); } $mailClass = hikashop_get('class.mail'); $infos = new stdClass(); $infos->user =& $element; $infos->product =& $product; $mail = $mailClass->get('waitlist_admin_notification', $infos); $mail->subject = $subject; $mail->from_email = $config->get('from_email'); $mail->from_name = $config->get('from_name'); $mail->reply_email = $element->email; if (empty($mail->dst_email)) { $mail->dst_email = array($config->get('from_email')); } $status = $mailClass->sendMail($mail); } else { $app->enqueueMessage(JText::_('WAITLIST_FULL')); } } else { $app->enqueueMessage(JText::_('ALREADY_REGISTER_WAITLIST')); } $app->enqueueMessage(JText::sprintf('CLICK_HERE_TO_GO_BACK_TO_PRODUCT', hikashop_contentLink('product&task=show&cid=' . $product->product_id . '&name=' . $alias . $url_itemid, $product))); $url = JRequest::getVar('redirect_url'); if (!empty($url)) { $app->redirect($url); } else { $this->waitlist(); } }
} if ($this->config->get('dimensions_display', 0) && bccomp($this->element->product_length, 0, 3)) { ?> <p class="hikashop_product_length_main"> <?php echo JText::_('PRODUCT_LENGTH') . ': ' . rtrim(rtrim($this->element->product_length, '0'), ',.') . ' ' . JText::_($this->element->product_dimension_unit); ?> </p> <?php } if ($this->config->get('dimensions_display', 0) && bccomp($this->element->product_height, 0, 3)) { ?> <p class="hikashop_product_height_main"> <?php echo JText::_('PRODUCT_HEIGHT') . ': ' . rtrim(rtrim($this->element->product_height, '0'), ',.') . ' ' . JText::_($this->element->product_dimension_unit); ?> </p> <?php } if ($this->config->get('manufacturer_display', 0) && !empty($this->element->product_manufacturer_id)) { $class = hikashop_get('class.category'); $manufacturer = $class->get($this->element->product_manufacturer_id); $menuClass = hikashop_get('class.menus'); $Itemid = $menuClass->loadAMenuItemId('manufacturer', 'listing'); if (empty($Itemid)) { $Itemid = $menuClass->loadAMenuItemId('', ''); } $categoryClass = hikashop_get('class.category'); $categoryClass->addAlias($manufacturer); echo '<p class="hikashop_product_brand_main">' . JText::_('MANUFACTURER') . ': ' . '<a href="' . hikashop_contentLink('category&task=listing&cid=' . $manufacturer->category_id . '&name=' . $manufacturer->alias . '&Itemid=' . $Itemid, $manufacturer) . '">' . $manufacturer->category_name . '</a> </p>'; }
/** * Plugin that returns the object list for DJ-Mediatools album * * Each object must contain following properties (mandatory): title, description, image * Optional properties: link, target (_blank or _self), alt (alt attribute for image) * * @param object The album params */ public function onAlbumPrepare(&$source, &$params) { // Lets check the requirements $check = $this->onCheckRequirements($source); if (is_null($check) || is_string($check)) { return null; } $app = JFactory::getApplication(); require_once JPATH_ADMINISTRATOR . '/components/com_hikashop/helpers/helper.php'; require_once JPATH_BASE . '/components/com_hikashop/views/product/view.html.php'; $view = new ProductViewProduct(array('base_path' => HIKASHOP_FRONT)); $view->setLayout('listing'); // create params for hikashop view $mparams = new JRegistry(); $mparams->set('show_limit', 0); $mparams->set('from_module', 'djmediatools'); $mparams->set('content_type', 'product'); $mparams->set('add_to_wishlist', 0); $mparams->set('link_to_product_page', 0); $mparams->set('show_vote_product', 0); $mparams->set('display_custom_item_fields', 0); $mparams->set('display_filters', 0); $mparams->set('display_badges', 0); // get options from album $mparams->def('limit', $params->get('max_images')); $mparams->def('content_synchronize', (int) $params->get('plg_hikashop_content_synchronize')); $mparams->def('product_synchronize', $params->get('plg_hikashop_product_synchronize')); $mparams->def('recently_viewed', (int) $params->get('plg_hikashop_recently_viewed')); $mparams->def('selectparentlisting', $params->get('plg_hikashop_selectparentlisting')); $mparams->def('filter_type', $params->get('plg_hikashop_filter_type')); $mparams->def('product_order', $params->get('plg_hikashop_product_order')); $mparams->def('order_dir', $params->get('plg_hikashop_order_dir')); $mparams->def('itemid', $params->get('plg_hikashop_itemid')); $mparams->def('add_to_cart', $params->get('plg_hikashop_add_to_cart')); $mparams->def('show_quantity_field', $params->get('plg_hikashop_show_quantity_field')); $mparams->def('show_out_of_stock', $params->get('plg_hikashop_show_out_of_stock')); $mparams->def('show_price', $params->get('plg_hikashop_show_price')); $mparams->def('random', $mparams->get('product_order') == 'random' ? 1 : 0); $show_price = (bool) $mparams->get('show_price'); $show_addtocart = (bool) $mparams->get('add_to_cart'); $default_image = $params->get('plg_hikashop_image'); /* hikashop authors force me to do it, because their component is not object oriented and there is no other way * to get listing of the products unless we will rewrite the whole component logic, what is nonsens :) */ ob_start(); $view->display(null, $mparams); $js = @$view->js; ob_get_clean(); // we don't need this, just $view object after view rendering //$this->debug($view->row); $slides = array(); foreach ($view->rows as $item) { $slide = (object) array(); $slide->image = $item->file_path; $slide->alt = $item->file_name; if (empty($slide->image)) { $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->product_description); } // if no image found in product description then take default image if (empty($slide->image)) { $slide->image = $default_image; } else { $slide->image = str_replace(JURI::root(true), '', $view->image->uploadFolder_url) . $slide->image; } // if no default image set then don't display this product if (empty($slide->image)) { continue; } $slide->title = $item->product_name; $slide->description = $item->product_description; $slide->canonical = $slide->link = hikashop_contentLink('product&task=show&cid=' . $item->product_id . '&name=' . $item->alias . $view->itemid . $view->category_pathway, $item); $slide->id = $item->product_id . ':' . $item->alias; if ($comments = $params->get('commnets', 0)) { $host = str_replace(JURI::root(true), '', JURI::root()); $host = preg_replace('/\\/$/', '', $host); switch ($comments) { case 1: // jcomments $slide->comments = array('id' => $item->product_id, 'group' => 'com_hikashop'); break; case 2: // disqus $disqus_shortname = $params->get('disqus_shortname', ''); if (!empty($disqus_shortname)) { $slide->comments = array(); $slide->comments['url'] = $host . $slide->link; $slide->comments['identifier'] = $disqus_shortname . '-hikashop-' . $item->product_id; // ?? } break; case 3: // facebook $slide->comments = $host . $slide->link; break; case 4: //komento // not implemented break; } } $view->row =& $item; if ($show_price) { $view->setLayout('listing_price'); $slide->extra = $view->loadTemplate(); } if ($show_addtocart) { if (!isset($slide->extra)) { $slide->extra = ''; } $view->setLayout('add_to_cart_listing'); $slide->extra .= $view->loadTemplate(); } $slides[] = $slide; } return $slides; }
$img = $this->image->getThumbnail(@$row->images[0]->file_path, array('width' => $image_width, 'height' => $image_height), $image_options); if ($img->success) { echo '<img class="hikashop_product_cart_image" title="' . $this->escape(@$row->images[0]->file_description) . '" alt="' . $this->escape(@$row->images[0]->file_name) . '" src="' . $img->url . '"/>'; } ?> </td> <?php } if ($this->params->get('show_cart_product_name', 1)) { ?> <td class="hikashop_cart_module_product_name_value hikashop_cart_value"> <?php if (@$defaultParams['link_to_product_page']) { ?> <a href="<?php echo hikashop_contentLink('product&task=show&cid=' . $row->product_id . '&name=' . $row->alias . $this->url_itemid, $row); ?> " ><?php } ?> <?php echo $row->product_name; ?> <?php if ($this->config->get('show_code')) { ?> <span class="hikashop_product_code_cart"><?php echo $row->product_code; ?> </span><?php }
} foreach ($ids as $k => $v) { ?> <td></td> <?php } ?> </tr> <tr id="hikashop_compare_tr_name"> <td class="hikashop_compare_title_first_column"></td> <?php foreach ($this->elements as $element) { if (!isset($element->alias)) { $element->alias = ''; } $link = hikashop_contentLink('product&task=show&cid=' . $element->product_id . '&name=' . $element->alias . $url_itemid, $element); ?> <td class="hikashop_compare_title_prod_column"> <h2> <a href="<?php echo $link; ?> " title="<?php echo $this->escape($element->product_name); ?> "> <span id="hikashop_product_<?php echo $element->product_id; ?> _name_main" class="hikashop_product_name_main"><?php echo $element->product_name;
function showcart() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getActive(); global $Itemid; if (empty($menu) && !empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } if (isset($menu->params) && is_object($menu->params)) { $cart_type = $menu->params->get('cart_type'); } if (!isset($cart_type) || $cart_type == null || empty($cart_type)) { if (isset($this->params) && is_object($this->params)) { $cart_type = $this->params->get('cart_type', 'cart'); } else { $cart_type = JRequest::getVar('cart_type', 'cart'); } } $image = hikashop_get('helper.image'); $this->assignRef('image', $image); $module = hikashop_get('helper.module'); $module->initialize($this); $database = JFactory::getDBO(); $config =& hikashop_config(); $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); $cart_id = hikashop_getCID(); if ($cart_id == 0) { $cart_id = JRequest::getInt('cart_id', ''); } if (empty($cart_id) || $cart_id == 0) { $cart_id = $app->getUserState(HIKASHOP_COMPONENT . '.' . $cart_type . '_id', 0, 'int'); if ($cart_id == 0) { $session = JFactory::getSession(); $session_id = ''; if ($session->getId()) { $session_id = $session->getId(); } if (hikashop_loadUser() == null) { $filter = 'a.session_id = ' . $database->Quote($session_id); } else { $userInfo = hikashop_loadUser(true); $filter = '(a.user_id = ' . (int) $userInfo->user_cms_id . ' OR a.session_id = ' . $database->Quote($session_id) . ')'; } $query = 'SELECT a.* FROM ' . hikashop_table('cart') . ' AS a WHERE a.cart_type = ' . $database->Quote($cart_type) . ' AND ' . $filter; $database->setQuery($query); $userCarts = $database->loadObjectList(); $ok = 0; $old_modified = 0; foreach ($userCarts as $userCart) { if ((int) $userCart->cart_current == 1) { $cart_id = (int) $userCart->cart_id; $ok = 1; } else { if ($ok == 0) { if ($old_modified <= $userCart->cart_modified) { $cart_id = $userCart->cart_id; $old_modified = $userCart->cart_modified; } } } } } } $popup = hikashop_get('helper.popup'); $this->assignRef('popup', $popup); $query = 'SELECT * FROM ' . hikashop_table('cart') . ' AS a WHERE a.cart_id = ' . $cart_id; $database->setQuery($query); $cartVal = $database->loadObject(); JRequest::setVar('cart_type', $cartVal->cart_type); JRequest::setVar('cart_id', $cart_id); $app->setUserState(HIKASHOP_COMPONENT . '.' . $cartVal->cart_type . '_id', $cart_id, 'int'); $rows = $class->get($cart_id, false, $cartVal->cart_type); if ($cartVal == null) { if ($config->get('enable_multicart', 0)) { global $Itemid; $url = hikashop_contentLink('cart&task=showcarts&cart_type=' . $cart_type . '&Itemid=' . $Itemid); $app->redirect($url); } else { $cartClass = hikashop_get('class.cart'); $cartVal = $cartClass->initCart(); $cartVal->cart_share = 'no'; } } $user = $cartVal->user_id; $confirmedStatus = $config->get('invoice_order_statuses', 'confirmed,shipped'); if (empty($confirmedStatus)) { $confirmedStatus = 'confirmed,shipped'; } $confirmedStatus = explode(',', trim($confirmedStatus, ',')); foreach ($confirmedStatus as &$status) { $status = $database->Quote($status); } unset($status); if ($cartVal->cart_type == 'wishlist' && $user == $cartVal->user_id) { $query = 'SELECT a.*,b.* FROM ' . hikashop_table('order') . ' AS a LEFT JOIN ' . hikashop_table('order_product') . ' AS b ON a.order_id=b.order_id WHERE a.order_status IN (' . implode(',', $confirmedStatus) . ') AND b.order_product_wishlist_id =' . (int) $cart_id; $database->setQuery($query); $buyers = $database->loadObjectList(); foreach ($buyers as $j => $buyer) { foreach ($rows as $k => $row) { if ($row->product_id == $buyer->product_id) { if ($buyer->order_user_id == $user) { $rows[$k]->bought[$j] = JText::_('ORDER_NUMBER') . ": " . $buyer->order_id . ' - ' . $buyer->order_product_quantity . ' ' . JText::_('HIKASHOP_ITEM'); } else { $userClass = hikashop_get('class.user'); $user = $userClass->get($buyer->order_user_id); if (!empty($user->username)) { $rows[$k]->bought[$j] = $user->username . ' - ' . $buyer->order_product_quantity . ' ' . JText::_('HIKASHOP_ITEM'); } else { if (!empty($user->user_email)) { $rows[$k]->bought[$j] = $user->user_email . ' - ' . $buyer->order_product_quantity . ' ' . JText::_('HIKASHOP_ITEM'); } else { $rows[$k]->bought[$j] = JText::_('HKASHOP_USER_ID') . ": " . $buyer->order_user_id . ' - ' . $buyer->order_product_quantity . ' ' . JText::_('HIKASHOP_ITEM'); } } } $rows[$k]->cart_product_quantity -= $buyer->order_product_quantity; if ($rows[$k]->cart_product_quantity < 0) { $rows[$k]->cart_product_quantity = 0; } } } } } if ($cartVal->cart_share == 'registered') { $cartVal->display = 'registered'; } else { if ($cartVal->cart_share == 'public') { $cartVal->display = 'public'; } else { if (in_array($user, explode(',', $cartVal->cart_share))) { $cartVal->display = $cartVal->cart_share; } else { if (JRequest::getString('link', 'link') == $cartVal->cart_share || strlen($cartVal->cart_share) == 20) { $cartVal->display = $cartVal->cart_share; } else { $cartVal->display = 'main'; } } } } if ($cart_type == 'cart') { $cartVal->display = 'main'; } $total = new stdClass(); if (!empty($rows)) { $variants = false; $ids = array(); foreach ($rows as $k => $row) { $ids[] = $row->product_id; if ($row->product_type == 'variant') { $variants = true; foreach ($rows as $k2 => $row2) { if ($row->product_parent_id == $row2->product_id) { $rows[$k2]->variants[] =& $rows[$k]; } } } } if ($variants) { $this->selected_variant_id = 0; $query = 'SELECT a.*,b.* FROM ' . hikashop_table('variant') . ' AS a LEFT 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.characteristic_value ASC'; $database->setQuery($query); $characteristics = $database->loadObjectList(); if (!empty($characteristics)) { foreach ($rows as $k => $row) { $element =& $rows[$k]; $product_id = $row->product_id; if ($row->product_type == 'variant') { continue; } $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; } } } } if (!empty($element->variants)) { $this->addCharacteristics($element, $mainCharacteristics, $characteristics); } if (!empty($element->options)) { foreach ($element->options as $k => $optionElement) { if (!empty($optionElement->variants)) { $this->addCharacteristics($element->options[$k], $mainCharacteristics, $characteristics); } } } } } } $product_quantities = array(); foreach ($rows as $row) { if (empty($product_quantities[$row->product_id])) { $product_quantities[$row->product_id] = (int) @$row->cart_product_quantity; } else { $product_quantities[$row->product_id] += (int) @$row->cart_product_quantity; } } foreach ($rows as $k => $row) { $rows[$k]->cart_product_total_quantity = $product_quantities[$row->product_id]; } $currencyClass->getPrices($rows, $ids, $currency_id, $main_currency, $zone_id, $discount_before_tax); foreach ($rows as $k => $row) { if (!empty($row->variants)) { foreach ($row->variants as $k2 => $variant) { $productClass->checkVariant($rows[$k]->variants[$k2], $row); } } } $cids = array(); foreach ($rows as $k => $row) { $currencyClass->calculateProductPriceForQuantity($rows[$k]); if ($cart_type != 'wishlist') { if ($row->cart_product_quantity == 0) { $rows[$k]->hide = 1; } } else { if ($row->product_type == 'variant' && !empty($row->cart_product_parent_id) && isset($rows[$row->cart_product_parent_id])) { $rows[$row->cart_product_parent_id]->hide = 1; } } $cids[] = (int) $row->product_id; } $total = new stdClass(); $currencyClass->calculateTotal($rows, $total, $currency_id); $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('file_ref_id'); if (!empty($product_files)) { foreach ($rows as $k => $row) { $productClass->addFiles($rows[$k], $product_files); if (in_array($row->product_id, array_keys($product_files))) { $row->images[] = $product_files[$row->product_id]; } elseif (in_array($row->product_parent_id, array_keys($product_files))) { $row->images[] = $product_files[$row->product_parent_id]; } } } $mainIds = array(); foreach ($rows as $product) { if ($product->product_parent_id == '0') { $mainIds[] = (int) $product->product_id; } else { $mainIds[] = (int) $product->product_parent_id; } } $query = 'SELECT a.*, 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 IN(' . implode(',', $mainIds) . ') ORDER BY a.ordering ASC'; $database->setQuery($query); $categories = $database->loadObjectList(); $quantityDisplayType = hikashop_get('type.quantitydisplay'); foreach ($rows as $k => $row) { if ($row->product_parent_id != 0 && $row->cart_product_parent_id != '0') { $row->product_quantity_layout = $rows[$row->cart_product_parent_id]->product_quantity_layout; $row->product_min_per_order = $rows[$row->cart_product_parent_id]->product_min_per_order; $row->product_max_per_order = $rows[$row->cart_product_parent_id]->product_max_per_order; } if (empty($row->product_quantity_layout) || $row->product_quantity_layout == 'inherit') { $categoryQuantityLayout = ''; if (!empty($categories)) { foreach ($categories as $category) { if ($category->product_id == $row->product_id && !empty($category->category_quantity_layout) && $quantityDisplayType->check($category->category_quantity_layout, $app->getTemplate())) { $categoryQuantityLayout = $category->category_quantity_layout; break; } } } } if (!empty($row->product_quantity_layout) && $row->product_quantity_layout != 'inherit') { $qLayout = $row->product_quantity_layout; } elseif (!empty($categoryQuantityLayout) && $categoryQuantityLayout != 'inherit') { $qLayout = $categoryQuantityLayout; } else { $qLayout = $config->get('product_quantity_display', 'show_default'); } $rows[$k]->product_quantity_layout = $qLayout; } } $js = "function checkAll(){\r\n\t\t\tvar toCheck = document.getElementById('hikashop_cart_product_listing').getElementsByTagName('input');\r\n\t\t\tfor (i = 0 ; i < toCheck.length ; i++) {\r\n\t\t\t\tif (toCheck[i].type == 'checkbox') {\r\n\t\t\t\t\ttoCheck[i].checked = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}"; if (!HIKASHOP_PHP5) { $doc =& JFactory::getDocument(); } else { $doc = JFactory::getDocument(); } $doc->addScriptDeclaration("<!--\n" . $js . "\n//-->\n"); $this->assignRef('total', $total); $this->assignRef('cartVal', $cartVal); $this->assignRef('rows', $rows); $this->assignRef('config', $config); $cart = hikashop_get('helper.cart'); $this->assignRef('cart', $cart); $this->assignRef('currencyHelper', $currencyClass); $cart->cartCount(true); $url = $this->init(true); $this->params->set('url', $url); ob_start(); $cart->getJS($url, false); $notice_html = ob_get_clean(); $this->assignRef('notice_html', $notice_html); if (hikashop_level(2)) { $null = null; $fieldsClass = hikashop_get('class.field'); $itemFields = $fieldsClass->getFields('frontcomp', $null, 'item', 'checkout&task=state'); $this->assignRef('itemFields', $itemFields); $this->assignRef('fieldsClass', $fieldsClass); } JHTML::_('behavior.tooltip'); if ($cart_type == 'cart') { $title = JText::_('CARTS'); } else { $title = JText::_('WISHLISTS'); } hikashop_setPageTitle($title); }
<span id="hikashop_product_length_main" class="hikashop_product_length_main"> <?php echo JText::_('PRODUCT_LENGTH') . ': ' . rtrim(rtrim($this->element->product_length, '0'), ',.') . ' ' . JText::_($this->element->product_dimension_unit); ?> <br /> </span> <?php } if ($this->config->get('dimensions_display', 0) && bccomp($this->element->product_height, 0, 3)) { ?> <span id="hikashop_product_height_main" class="hikashop_product_height_main"> <?php echo JText::_('PRODUCT_HEIGHT') . ': ' . rtrim(rtrim($this->element->product_height, '0'), ',.') . ' ' . JText::_($this->element->product_dimension_unit); ?> <br /> </span> <?php } if ($this->config->get('manufacturer_display', 0) && !empty($this->element->product_manufacturer_id)) { $categoryClass = hikashop_get('class.category'); $manufacturer = $categoryClass->get($this->element->product_manufacturer_id); if ($manufacturer->category_published) { $menuClass = hikashop_get('class.menus'); $Itemid = $menuClass->loadAMenuItemId('manufacturer', 'listing'); if (empty($Itemid)) { $Itemid = $menuClass->loadAMenuItemId('', ''); } $categoryClass->addAlias($manufacturer); echo JText::_('MANUFACTURER') . ': ' . '<a href="' . hikashop_contentLink('category&task=listing&cid=' . $manufacturer->category_id . '&name=' . $manufacturer->alias . '&Itemid=' . $Itemid, $manufacturer) . '">' . $manufacturer->category_name . '</a>'; } }