private static function getProductDetail($id) { $component = JComponentHelper::getComponent("com_redshop"); if (!isset($component->id)) { JError::raiseError('500', 'redShop Component is not installed'); } if (!defined('TABLE_PREFIX')) { require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/redshop.cfg.php'; } require_once JPATH_SITE . '/components/com_redshop/helpers/helper.php'; $objhelper = new redhelper(); $producthelper = new producthelper(); $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $id); if (count($ItemData) > 0) { $pItemid = $ItemData->id; } else { $pItemid = $objhelper->getItemid($id); } $link = JRoute::_('index.php?option=com_redshop&view=product&pid=' . $id . '&Itemid=' . $pItemid); $product = $producthelper->getProductById($id); $product->product_price = $producthelper->getProductPrice($id); $product->link = $link; return $product; }
function renderLayout() { if ($this->config['module_mode'] !== 'normal') { $this->render_portal_mode($this->config['module_mode']); } else { $renderer = new NSP_GK4_Layout_Parts(); // detecting mode - com_content or K2 $k2_mode = false; $rs_mode = false; $vm_mode = false; $producthelper = ''; $redhelper = ''; //check the source if ($this->config["data_source"] == 'k2_categories' || $this->config["data_source"] == 'k2_articles' || $this->config["data_source"] == 'all_k2_articles' || $this->config["data_source"] == 'k2_tags') { if ($this->config['k2_categories'] != -1) { $k2_mode = true; } else { // exception when K2 is not installed $this->content = array("ID" => array(), "alias" => array(), "CID" => array(), "title" => array(), "text" => array(), "date" => array(), "date_publish" => array(), "author" => array(), "cat_name" => array(), "cat_alias" => array(), "hits" => array(), "news_amount" => 0, "rating_sum" => 0, "rating_count" => 0, "plugins" => ''); } } else { if ($this->config["data_source"] == 'redshop_categories' || $this->config["data_source"] == 'redshop_products' || $this->config["data_source"] == 'all_redshop_products') { if ($this->config['redshop_categories'] != -1 && file_exists(JPATH_ROOT . DS . 'components' . DS . 'com_redshop')) { $rs_mode = true; $producthelper = new producthelper(); $redhelper = new redhelper(); } else { // exception when RedSHOP is not installed $this->content = array("ID" => array(), "CID" => array(), "title" => array(), "text" => array(), "date" => array(), "date_publish" => array(), "price" => array(), "discount_price" => array(), "discount_start" => array(), "discount_end" => array(), "tax" => array(), "cat_name" => array(), "manufacturer" => array(), "manufacturer_id" => array(), "product_image" => array(), "news_amount" => array()); } } elseif ($this->config["data_source"] == 'vm_categories' || $this->config["data_source"] == 'vm_products') { if ($this->config['vm_categories'] != -1) { $vm_mode = true; } else { // exception when VirtueMart is not installed $this->content = array("ID" => array(), "CID" => array(), "title" => array(), "text" => array(), "date" => array(), "date_publish" => array(), "price" => array(), "price_currency" => array(), "discount_amount" => array(), "discount_is_percent" => array(), "discount_start" => array(), "discount_end" => array(), "tax" => array(), "cat_name" => array(), "manufacturer" => array(), "manufacturer_id" => array(), "product_image" => array(), "news_amount" => 0); } } } // tables which will be used in generated content $news_list_tab = array(); $news_html_tab = array(); // Generating content $uri =& JURI::getInstance(); $li_counter = 0; $news_k2_store = ''; $news_header = ''; $news_image = ''; $news_readmore = ''; $news_textt = ''; $news_infoo = ''; $news_infoo2 = ''; // for ($i = 0; $i < count($this->content["ID"]); $i++) { if ($i < $this->config['news_column'] * $this->config['news_rows'] * $this->config['news_full_pages']) { // GENERATING NEWS CONTENT if ($k2_mode == FALSE && $rs_mode == FALSE && $vm_mode == FALSE) { // GENERATING HEADER if ($this->config['news_header_enabled'] == 1) { $news_header = $renderer->header($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i]); } // GENERATING IMAGE if ($this->config['news_image_enabled'] == 1) { $news_image = $renderer->image($this->config, $uri, $this->content['ID'][$i], $this->content['IID'][$i], $this->content['CID'][$i], $this->content['text'][$i], $this->content['title'][$i], $this->content['images'][$i]); } // GENERATING READMORE if ($this->config['news_readmore_enabled'] == 1) { $news_readmore = $renderer->readMore($this->config, $this->content['ID'][$i], $this->content['CID'][$i]); } // GENERATING TEXT if ($this->config['news_text_enabled'] == 1) { $news_textt = $renderer->text($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['text'][$i], $news_readmore); } // GENERATE NEWS INFO if ($this->config['news_info_enabled'] == 1) { $news_infoo = $renderer->info($this->config, $this->content['catname'][$i], $this->content['CID'][$i], $this->content['author'][$i], $this->content['email'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['hits'][$i], $this->content['ID'][$i], $this->content['rating_count'][$i], $this->content['rating_sum'][$i]); } // GENERATE NEWS INFO2 if ($this->config['news_info2_enabled'] == 1) { $news_infoo2 = $renderer->info($this->config, $this->content['catname'][$i], $this->content['CID'][$i], $this->content['author'][$i], $this->content['email'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['hits'][$i], $this->content['ID'][$i], $this->content['rating_count'][$i], $this->content['rating_sum'][$i], 2); } } else { if ($rs_mode == FALSE && $vm_mode == FALSE && $k2_mode == TRUE) { // GENERATING HEADER if ($this->config['news_header_enabled'] == 1) { $news_header = $renderer->header_k2($this->config, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['title'][$i]); } // GENERATING IMAGE if ($this->config['news_image_enabled'] == 1) { $news_image = $renderer->image_k2($this->config, $uri, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['text'][$i], $this->content['title'][$i]); } // GENERATING READMORE if ($this->config['news_readmore_enabled'] == 1) { $news_readmore = $renderer->readMore_k2($this->config, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i]); } // GENERATING TEXT if ($this->config['news_text_enabled'] == 1) { $news_textt = $renderer->text_k2($this->config, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['text'][$i], $news_readmore); } // GENERATE NEWS INFO if ($this->config['news_info_enabled'] == 1) { $news_infoo = $renderer->info_k2($this->config, $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['author'][$i], $this->content['author_id'][$i], $this->content['email'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['hits'][$i], $this->content['ID'][$i], $this->content['alias'][$i], $this->content['comments'], $this->content['rating_count'][$i], $this->content['rating_sum'][$i]); } // GENERATE NEWS INFO2 if ($this->config['news_info2_enabled'] == 1) { $news_infoo2 = $renderer->info_k2($this->config, $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['author'][$i], $this->content['author_id'][$i], $this->content['email'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['hits'][$i], $this->content['ID'][$i], $this->content['alias'][$i], $this->content['comments'], $this->content['rating_count'][$i], $this->content['rating_sum'][$i], 2); } // GENERATE STORE BLOCK $news_k2_store = $renderer->store_k2($this->config, $this->content['ID'][$i], $this->content['plugins'][$i], $this->k2store_params); } else { if ($rs_mode == TRUE && $vm_mode == FALSE && $k2_mode == FALSE) { $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $this->content['ID'][$i]); $id = $this->content['ID'][$i]; $cid = $producthelper->getCategoryProduct($this->content['ID'][$i]); $Itemid = $redhelper->getItemid($this->content['ID'][$i]); $product = $producthelper->getProductById($this->content['ID'][$i]); // GENERATING HEADER if ($this->config['news_header_enabled'] == 1) { $news_header = $renderer->header_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i], $Itemid); } // GENERATING IMAGE if ($this->config['news_image_enabled'] == 1) { $news_image = $renderer->image_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['product_image'][$i], $this->content['title'][$i], $Itemid); } // GENERATING READMORE if ($this->config['news_readmore_enabled'] == 1) { $news_readmore = $renderer->readMore_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $Itemid); } // GENERATING TEXT if ($this->config['news_text_enabled'] == 1) { $news_textt = $renderer->text_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['text'][$i], $news_readmore, $Itemid); } // GENERATE NEWS INFO if ($this->config['news_info_enabled'] == 1) { $news_infoo = $renderer->info_rs($this->config, $this->content['ID'][$i], $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['manufacturer'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $Itemid, $this->content['manufacturer_id'][$i], 1); } // GENERATE NEWS INFO2 if ($this->config['news_info2_enabled'] == 1) { $news_infoo2 = $renderer->info_rs($this->config, $this->content['ID'][$i], $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['manufacturer'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $Itemid, $this->content['manufacturer_id'][$i], 2); } // COMPUTE PRICE DEPENDS OF USER ID $user =& JFactory::getUser(); $price = $producthelper->getProductPrice($this->content['ID'][$i], $this->config['rs_price_with_vat'], $user->id); $price = $producthelper->getProductFormattedPrice($price, true); if ($this->config['rs_add_to_cart'] == 1) { $addToCart = $producthelper->replaceCartTemplate($this->content['ID'][$i], 0, 0, 0, "", false, array(), 0, 0, 0); $addToCart = str_replace('&', '&', $addToCart); if ($this->config['rs_show_default_cart_button'] == 0) { $btnCode = '<a class=\'nspAddToCart\' onclick="if(displayAddtocartForm(\'addtocart_prd_' . $this->content['ID'][$i]; $btnCode .= '\',\'' . $id . '\',\'0\',\'0\', \'user_fields_form\'))'; $btnCode .= '{checkAddtocartValidation(\'addtocart_prd_' . $id . '\',\'' . $id . '\',\'0\',\'0\', \'user_fields_form\',\'0\',\'0\',\'0\');}"><span style=\'cursor: pointer;\' id=\'pdaddtocartprd' . $id . '\' title=\'\' class=\'\'>' . JText::_('MOD_NEWS_PRO_GK4_ADD_TO_CART') . '</span></a>'; $addToCart = preg_replace('/\\<img.*?\\>/i', $btnCode, $addToCart); } } // GET THE CURRENCY $bool = preg_match('/[^0-9]/u', $price, $currency); $currency = $currency[0]; $bool = preg_match('/[0-9]+/u', $price, $price); $price = $price[0]; // GENERATE RedSHOP STORE INFO $news_rs_store = $renderer->store_rs($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $price, $this->content['discount_start'][$i], $this->content['discount_end'][$i], $this->content['tax'][$i], $this->content['discount_price'][$i], $currency, $Itemid, $addToCart); } else { if ($vm_mode == TRUE) { // GENERATING HEADER if ($this->config['news_header_enabled'] == 1) { $news_header = $renderer->header_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i]); } // GENERATING IMAGE if ($this->config['news_image_enabled'] == 1) { $news_image = $renderer->image_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['product_image'][$i], $this->content['title'][$i]); } // GENERATING READMORE if ($this->config['news_readmore_enabled'] == 1) { $news_readmore = $renderer->readMore_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i]); } // GENERATING TEXT if ($this->config['news_text_enabled'] == 1) { $news_textt = $renderer->text_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['text'][$i], $news_readmore); } // GENERATE NEWS INFO if ($this->config['news_info_enabled'] == 1) { $news_infoo = $renderer->info_vm($this->config, $this->content['ID'][$i], $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['manufacturer'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['comments']); } // GENERATE NEWS INFO2 if ($this->config['news_info2_enabled'] == 1) { $news_infoo2 = $renderer->info_vm($this->config, $this->content['ID'][$i], $this->content['cat_name'][$i], $this->content['CID'][$i], $this->content['manufacturer'][$i], $this->config['date_publish'] == TRUE ? $this->content['date_publish'][$i] : $this->content['date'][$i], $this->content['comments'], 2); } $news_vm_store = $renderer->store_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['price'][$i], $this->content['price_currency'][$i], $this->content['discount_amount'][$i], true, $this->content['discount_start'][$i], $this->content['discount_end'][$i], $this->content['tax'][$i], $this->content['manufacturer_id'][$i]); } } } } // PARSING PLUGINS if ($this->config['parse_plugins'] == TRUE) { $news_textt = JHtml::_('content.prepare', $news_textt); } // CLEANING PLUGINS if ($this->config['clean_plugins'] == TRUE) { $news_textt = preg_replace("/(\\{.+?\\}.+?\\{.+?})|(\\{.+?\\})/", "", $news_textt); } // GENERATE CONTENT FOR TAB $news_generated_content = ''; // initialize variable // for ($j = 1; $j < 7; $j++) { if ($this->config['wrapContent'] == 1 && $this->config['news_image_order'] == 1) { if ($j == 2) { $news_generated_content .= '<div class="gkArtContentWrap">'; } } if ($this->config['news_header_order'] == $j) { $news_generated_content .= $news_header; } if ($this->config['news_image_order'] == $j) { $news_generated_content .= $news_image; } if ($this->config['news_text_order'] == $j) { $news_generated_content .= $news_textt; } if ($this->config['news_info_order'] == $j) { $news_generated_content .= $news_infoo; } if ($this->config['news_info2_order'] == $j) { $news_generated_content .= $news_infoo2; } if ($this->config['news_rs_store_enabled'] != 'disabled') { if ($rs_mode != FALSE && $this->config['news_rs_store_order'] == $j) { $news_generated_content .= $news_rs_store; } if ($vm_mode != FALSE && $this->config['news_rs_store_order'] == $j) { $news_generated_content .= $news_vm_store; } if ($k2_mode != FALSE && $this->config['news_rs_store_order'] == $j) { $news_generated_content .= $news_k2_store; } } } // if ($this->config['news_content_readmore_pos'] != 'after') { $news_generated_content .= $news_readmore; } if ($this->config['wrapContent'] == 1 && $this->config['news_image_order'] == 1) { $news_generated_content .= '</div>'; } // creating table with news content array_push($news_html_tab, $news_generated_content); } else { if ($k2_mode == FALSE && $vm_mode == FALSE) { array_push($news_list_tab, $renderer->lists($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i], $this->content['text'][$i], $li_counter % 2, $li_counter)); } elseif ($k2_mode == TRUE) { array_push($news_list_tab, $renderer->lists_k2($this->config, $this->content['ID'][$i], $this->content['alias'][$i], $this->content['CID'][$i], $this->content['cat_alias'][$i], $this->content['title'][$i], $this->content['text'][$i], $li_counter % 2, $li_counter)); } else { array_push($news_list_tab, $renderer->lists_vm($this->config, $this->content['ID'][$i], $this->content['CID'][$i], $this->content['title'][$i], $this->content['text'][$i], $li_counter % 2, $li_counter)); } // $li_counter++; } } /** GENERATING FINAL XHTML CODE START **/ // create instances of basic Joomla! classes $document = JFactory::getDocument(); $uri = JURI::getInstance(); // add stylesheets to document header if ($this->config["useCSS"] == 1) { $document->addStyleSheet($uri->root() . 'modules/mod_news_pro_gk4/interface/css/style.css', 'text/css'); } // add script to the document header if ($this->config['useScript'] == 1) { $document->addScript($uri->root() . 'modules/mod_news_pro_gk4/interface/scripts/engine.js'); } // init $headData variable $headData = false; // add scripts with automatic mode to document header if ($this->config['useScript'] == 2) { // getting module head section datas unset($headData); $headData = $document->getHeadData(); // generate keys of script section $headData_keys = array_keys($headData["scripts"]); // set variable for false $engine_founded = false; // searching phrase mootools in scripts paths if (array_search($uri->root() . 'modules/mod_news_pro_gk4/interface/scripts/engine.js', $headData_keys) > 0) { $engine_founded = true; } // if engine doesn't exists in the head section if (!$engine_founded) { // add new script tag connected with mootools from module $document->addScript($uri->root() . 'modules/mod_news_pro_gk4/interface/scripts/engine.js'); } } // require JModuleHelper::getLayoutPath('mod_news_pro_gk4', 'content'); require JModuleHelper::getLayoutPath('mod_news_pro_gk4', 'default'); } }
$product_userfileds = $extraField->list_all_user_fields($userfieldArr[$ui], 12, '', '', 0, $product->product_id); $ufield .= $product_userfileds[1]; if ($product_userfileds[1] != "") { $count_no_user_field++; } $template_userfield = str_replace('{' . $userfieldArr[$ui] . '_lbl}', $product_userfileds[0], $template_userfield); $template_userfield = str_replace('{' . $userfieldArr[$ui] . '}', $product_userfileds[1], $template_userfield); } if ($ufield != "") { $hidden_userfield = "<div style='display:none;'><form method='post' action='' id='user_fields_form_" . $product->product_id . "' name='user_fields_form_" . $product->product_id . "'>" . $template_userfield . "</form></div>"; } } } $prddata_add = $prddata_add . $hidden_userfield; /************** end user fields ***************************/ $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $product->product_id); if (count($ItemData) > 0) { $pItemid = $ItemData->id; } else { $pItemid = $objhelper->getItemid($product->product_id); } $prddata_add = str_replace("{product_id_lbl}", JText::_('COM_REDSHOP_PRODUCT_ID_LBL'), $prddata_add); $prddata_add = str_replace("{product_id}", $product->product_id, $prddata_add); $prddata_add = str_replace("{product_number_lbl}", JText::_('COM_REDSHOP_PRODUCT_NUMBER_LBL'), $prddata_add); $product_number_output = '<span id="product_number_variable' . $product->product_id . '">' . $product->product_number . '</span>'; $prddata_add = str_replace("{product_number}", $product_number_output, $prddata_add); $product_volume_unit = '<span class="product_unit_variable">' . DEFAULT_VOLUME_UNIT . "3" . '</span>'; $strToInsert = $producthelper->redunitDecimal($product->product_volume) . " " . $product_volume_unit; $prddata_add = str_replace("{product_size}", $strToInsert, $prddata_add); $product_unit = '<span class="product_unit_variable">' . DEFAULT_VOLUME_UNIT . '</span>'; $strToInsert = $producthelper->redunitDecimal($product->product_length) . " " . $product_unit;
/** * Method to add product in cart * * @return void */ public function add() { $app = JFactory::getApplication(); $option = JRequest::getVar('option'); $post = JRequest::get('post'); $parent_accessory_productid = $post['product_id']; $Itemid = JRequest::getVar('Itemid'); $producthelper = new producthelper(); $redhelper = new redhelper(); $Itemid = $redhelper->getCartItemid(); $model = $this->getModel('cart'); // Call add method of modal to store product in cart session $userfiled = JRequest::getVar('userfiled'); JPluginHelper::importPlugin('redshop_product'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeAddProductToCart', array(&$post)); $result = $this->_carthelper->addProductToCart($post); if (is_bool($result) && $result) { } else { $errmsg = $result ? $result : JText::_("COM_REDSHOP_PRODUCT_NOT_ADDED_TO_CART"); if (AJAX_CART_BOX == 1) { echo "`0`" . $errmsg; die; } else { $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $post['product_id']); if (count($ItemData) > 0) { $prdItemid = $ItemData->id; } else { $prdItemid = $redhelper->getItemid($post['product_id']); } $link = JRoute::_("index.php?option=" . $option . "&view=product&pid=" . $post["product_id"] . "&Itemid=" . $prdItemid, false); $app->Redirect($link, $errmsg); } } $session = JFactory::getSession(); $cart = $session->get('cart'); if (isset($cart['AccessoryAsProduct'])) { $attArr = $cart['AccessoryAsProduct']; if (ACCESSORY_AS_PRODUCT_IN_CART_ENABLE) { $data['accessory_data'] = $attArr[0]; $data['acc_quantity_data'] = $attArr[1]; $data['acc_attribute_data'] = $attArr[2]; $data['acc_property_data'] = $attArr[3]; $data['acc_subproperty_data'] = $attArr[4]; if (isset($data['accessory_data']) && ($data['accessory_data'] != "" && $data['accessory_data'] != 0)) { $accessory_data = explode("@@", $data['accessory_data']); $acc_quantity_data = explode("@@", $data['acc_quantity_data']); $acc_attribute_data = explode("@@", $data['acc_attribute_data']); $acc_property_data = explode("@@", $data['acc_property_data']); $acc_subproperty_data = explode("@@", $data['acc_subproperty_data']); for ($i = 0; $i < count($accessory_data); $i++) { $accessory = $producthelper->getProductAccessory($accessory_data[$i]); $post = array(); $post['parent_accessory_product_id'] = $parent_accessory_productid; $post['product_id'] = $accessory[0]->child_product_id; $post['quantity'] = $acc_quantity_data[$i]; $post['category_id'] = 0; $post['sel_wrapper_id'] = 0; $post['attribute_data'] = $acc_attribute_data[$i]; $post['property_data'] = $acc_property_data[$i]; $post['subproperty_data'] = $acc_subproperty_data[$i]; $result = $this->_carthelper->addProductToCart($post); $cart = $session->get('cart'); if (is_bool($result) && $result) { } else { $errmsg = $result ? $result : JText::_("COM_REDSHOP_PRODUCT_NOT_ADDED_TO_CART"); if (JError::isError(JError::getError())) { $error = JError::getError(); $errmsg = $error->message; } if (AJAX_CART_BOX == 1) { echo "`0`" . $errmsg; die; } else { $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $post['product_id']); if (count($ItemData) > 0) { $prdItemid = $ItemData->id; } else { $prdItemid = $redhelper->getItemid($post['product_id']); } $link = JRoute::_("index.php?option=" . $option . "&view=product&pid=" . $post["product_id"] . "&Itemid=" . $prdItemid, false); $app->Redirect($link, $errmsg); } } } } } if (!DEFAULT_QUOTATION_MODE || DEFAULT_QUOTATION_MODE && SHOW_QUOTATION_PRICE) { $this->_carthelper->carttodb(); } $this->_carthelper->cartFinalCalculation(); unset($cart['AccessoryAsProduct']); } else { if (!DEFAULT_QUOTATION_MODE || DEFAULT_QUOTATION_MODE && SHOW_QUOTATION_PRICE) { $this->_carthelper->carttodb(); } $this->_carthelper->cartFinalCalculation(); } if (!$userfiled) { if (AJAX_CART_BOX == 1 && isset($post['ajax_cart_box'])) { $link = JRoute::_('index.php?option=' . $option . '&view=cart&ajax_cart_box=' . $post['ajax_cart_box'] . '&tmpl=component&Itemid=' . $Itemid, false); $app->Redirect($link); } else { if (ADDTOCART_BEHAVIOUR == 1) { $link = JRoute::_('index.php?option=' . $option . '&view=cart&Itemid=' . $Itemid, false); $app->Redirect($link); } else { $link = JRoute::_($_SERVER['HTTP_REFERER'], false); if ($cart['notice_message'] != "") { $msg = $cart['notice_message'] . "<br>"; } $msg .= JTEXT::_('COM_REDSHOP_PRODUCT_ADDED_TO_CART'); $app->Redirect($link, $msg); } } } else { $link = JRoute::_('index.php?option=' . $option . '&view=product&pid=' . $post['p_id'] . '&Itemid=' . $Itemid, false); $app->Redirect($link); } }
public function getItemid($product_id = '', $cat_id = 0) { $producthelper = new producthelper(); $catDetailmenu = false; if ($cat_id) { $sql = "SELECT id FROM #__menu " . "WHERE published=1 " . "AND `link` LIKE '%com_redshop%' " . "AND `link` LIKE '%view=category%' " . "AND ( link LIKE '%cid=" . (int) $cat_id . "' OR link LIKE '%cid=" . (int) $cat_id . "&%' ) " . "ORDER BY 'ordering'"; $this->_db->setQuery($sql); if ($Itemid = $this->_db->loadResult()) { $catDetailmenu = true; return $Itemid; } } $sql = "SELECT category_id \tFROM " . $this->_table_prefix . "product_category_xref cx WHERE product_id = '{$product_id}'"; $this->_db->setQuery($sql); $cats = $this->_db->loadObjectList(); for ($i = 0; $i < count($cats); $i++) { $cat = $cats[$i]; $sql = "SELECT id FROM #__menu " . "WHERE published=1 " . "AND `link` LIKE '%com_redshop%' " . "AND `link` LIKE '%view=category%' " . "AND ( link LIKE '%cid=" . (int) $cat->category_id . "' OR link LIKE '%cid=" . (int) $cat->category_id . "&%' ) " . "ORDER BY 'ordering'"; $this->_db->setQuery($sql); if ($Itemid = $this->_db->loadResult()) { return $Itemid; } } $option = JRequest::getVar('option'); if ($option != 'com_redshop') { if (!$catDetailmenu) { $sql = "SELECT id FROM #__menu " . "WHERE published=1 " . "AND `link` LIKE '%com_redshop%' " . "AND `link` LIKE '%view=category%' " . "ORDER BY 'ordering'"; $this->_db->setQuery($sql); if ($Itemid = $this->_db->loadResult()) { return $Itemid; } } $Itemidlist = $producthelper->getMenuInformation(); if (count($Itemidlist) == 1) { $Itemid = $Itemidlist->id; return $Itemid; } } $Itemid = intval(JRequest::getVar('Itemid')); return $Itemid; }
/** * Go to nav Product * * @return void */ public function gotonavproduct() { $producthelper = new producthelper(); $objhelper = new redhelper(); $post = JRequest::get('post'); $cid = $producthelper->getCategoryProduct($post['pid']); $ItemData = $producthelper->getMenuInformation(0, 0, '', 'product&pid=' . $post['pid']); if (count($ItemData) > 0) { $pItemid = $ItemData->id; } else { $pItemid = $objhelper->getItemid($product->product_id, $cid); } $link = JRoute::_('index.php?option=com_redshop&view=product&pid=' . $post['pid'] . '&cid=' . $cid . '&Itemid=' . $pItemid, false); $this->setRedirect($link); }