function showindoptions() { $id = JRequest::getVar("optgrid"); $productid = JRequest::getVar("productid"); $po = new productoption(); $lst = $po->getbygroup($id); display::showindoptions($lst, $id, $productid); }
function getSCSingle($params, $pluginParams, $debugmode = 0) { global $Itemid, $mainframe; $dis = new dis(); // printf("<pre>%s</pre>", print_r($pluginParams,1)); $classsuffix = isset($params['classsfx']) ? $params['classsfx'] : ""; $prodcode = $params['code']; $defaultqty = isset($params['defqty']) ? $params['defqty'] : 1; // default qty set in qty edit box $minqty = isset($params['minqty']) ? $params['minqty'] : 0; $strqties = isset($params['qties']) ? $params['qties'] : null; $checkoos = isset($params['checkoos']) ? $params['checkoos'] : 0; $picname = isset($params['picname']) ? $params['picname'] : ""; $aqties = explode(",", $strqties); $db =& JFactory::getDBO(); $query = "SELECT * FROM #__sc_products WHERE prodcode='{$prodcode}'"; $db->setQuery($query); $product = $db->loadObject(); if (!$product) { $html = "<div class='sccart{$classsuffix}'>"; $str = JText::sprintf("SC_PRODUCT_NOT_FOUND", $prodcode); $html .= $str; $html .= "</div>"; return $html; } if ($product->published == '0') { $html = "<div class='sccart{$classsuffix}'>"; $str = JText::sprintf("SC_PRODUCT_NOT_PUBLISHED", $prodcode); $html .= $str; $html .= "</div>"; return $html; } if (!$db->query()) { echo "<script> alert('" . $db->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } $prodpresentation = ""; if ($pluginParams->get('showproductcodetext')) { $prodpresentation .= "\n<div class='scproduct{$classsuffix}'>#PRODUCTCODETEXT# {$dis->separator}</div>"; } if ($pluginParams->get('showproductcode')) { $prodpresentation .= "\n<div class='scprodcode{$classsuffix}'>#PRODUCTCODE# {$dis->separator}</div>"; } if ($pluginParams->get('showtitle')) { $prodpresentation .= "\n<div class='scshorttext{$classsuffix}'>#SHORTTEXT# {$dis->separator}</div>"; } if ($pluginParams->get('showunitpricetext')) { $prodpresentation .= "\n<div class='scunitpricetext{$classsuffix}'>#UNITPRICETEXT# {$dis->separator}</div>"; } if ($pluginParams->get('showunitprice')) { $prodpresentation .= "\n<div class='scunitprice{$classsuffix}'>#UNITPRICE# {$dis->separator}</div>"; } if ($pluginParams->get('showquantitytext')) { $prodpresentation .= "\n<div class='scqtytext{$classsuffix}'>#QUANTITYTEXT# {$dis->separator}</div>"; } $prodpresentation .= "\n<div class='scqty{$classsuffix}'>#QUANTITY# {$dis->separator}</div>"; $prodpresentation .= "\n#CARTOPTIONS#"; $prodpresentation .= "\n<div class='atczone{$classsuffix}'>#ADDTOCARTBUTTON#</div>"; $html = "\n<div class='sccart{$classsuffix}'>"; $html .= "\n<form name='addtocart{$product->id}' action='index.php' method='post'>"; $amount = number_format($product->unitprice, $dis->decs, $dis->dsep, $dis->tsep); if ($dis->curralign == 1) { $amount = $dis->currency . " " . $amount; } else { $amount = $amount . " " . $dis->currency; } $html .= $prodpresentation; $productoptions = new productoption(); $optionhtml = "<div class='cartoptions{$classsuffix}'>"; if ($pluginParams->get('showcartoptionstitle')) { $optionhtml .= "\n<div class='cartoptionstitle{$classsuffix}'>#CARTOPTIONSTITLE#</div>"; } $hasoptions = 0; $optgroups = new optiongroups(); $optiongroups = $optgroups->getgroups($product->prodcode); if (count($optiongroups)) { foreach ($optiongroups as $optiongroup) { $groupid = $optiongroup->id; $options = new productoption(); $lstoptions = $options->getbygroup($groupid); $show = "optionshow" . $optiongroup->showas; if ($pluginParams->get('showcartoptionstitle')) { $optionhtml .= "\n<div class='cartoptionstitle{$classsuffix}'>{$optiongroup->title}</div>"; } $optionhtml .= $dis->{$show}($lstoptions, $product, $groupid, $classsuffix, $picname); } } else { // product without options - generate id from productcode $id = md5($product->prodcode . $picname); $optionhtml .= "\n<input type='hidden' value='{$id}' name='edtoption' />"; } $optionhtml .= "</div>"; if ($checkoos == 1) { // check for minimum quantitites/ out of stock if ($product->av_qty >= 1) { // product still available $atcbtn = "\n<input type='submit' name='submit' value='" . JText::_('SC_ADD_TO_CART') . "' class='scp_atc{$classsuffix}' />"; } else { // product quantity is 0 $atcbtn = "\n<input type='submit' name='submit' value='" . JText::_('SC_OUT_OF_STOCK') . "' class='scp_atc{$classsuffix}' disabled='disabled' />"; } } else { $atcbtn = "\n<input type='submit' name='submit' value='" . JText::_('SC_ADD_TO_CART') . "' class='scp_atc{$classsuffix}' />"; } $qtyfield = "\n<input type='" . ($pluginParams->get('showquantity') ? 'text' : 'hidden') . "' name='edtqty' value='{$defaultqty}' class='scp_qty{$classsuffix}' />"; if ($strqties) { // specific quantities given $qtyfield = "<select name='edtqty' class='scp_selectqty{$classsuffix}'>"; foreach ($aqties as $key => $value) { $qtyfield .= "<option value='{$value}'>{$value}</option>"; } $qtyfield .= "</select>"; } $html .= "\n<input type='hidden' name='edtprodcode' value='{$product->prodcode}' />"; $html .= "\n<input type='hidden' name='edtshorttext' value='{$product->shorttext}' />"; $html .= "\n<input type='hidden' name='edtunitprice' value='{$product->unitprice}' />"; $html .= "\n<input type='hidden' name='option' value='com_caddy' />"; $html .= "\n<input type='hidden' name='action' value='addtocart' />"; $html .= "\n<input type='hidden' name='picname' value='{$picname}' />"; $html .= "\n<input type='hidden' name='Itemid' value='{$Itemid}' />"; if ($minqty > 0) { // check for minimum quantity in the component $html .= "\n<input type='hidden' name='minqty' value='{$minqty}' />"; } if ($pluginParams->get('stayonpage') == 1) { $html .= "\n<input type='hidden' name='lasturl' value='" . urlencode($_SERVER['REQUEST_URI']) . "' />"; $html .= "\n<input type='hidden' name='stayonpage' value='1' />"; } $html .= "\n</form>"; $html .= "</div>"; //now replace any variables $html = str_replace("#PRODUCTCODETEXT#", JText::_('SC_PRODUCT'), $html); $html = str_replace("#PRODUCTCODE#", $product->prodcode, $html); $html = str_replace("#SHORTTEXT#", stripslashes($product->shorttext), $html); $html = str_replace("#UNITPRICETEXT#", JText::_('SC_PRICE_PER_UNIT'), $html); $html = str_replace("#UNITPRICE#", $amount, $html); $html = str_replace("#QUANTITY#", $qtyfield, $html); $html = str_replace("#QUANTITYTEXT#", JText::_('SC_QUANTITY'), $html); $html = str_replace("#ADDTOCARTBUTTON#", $atcbtn, $html); $html = str_replace("#CARTOPTIONS#", $optionhtml, $html); if (trim($product->options)) { $html = str_replace("#CARTOPTIONSTITLE#", JText::_('SC_OPTIONS'), $html); } else { $html = str_replace("#CARTOPTIONSTITLE#", "", $html); } return $html; }