function fetchElement($name, $value, &$node, $control_name) { $fieldName = $control_name . '[' . $name . ']'; $doc = JFactory::getDocument(); $app = JFactory::getApplication(); K2StoreStrapper::addJS(); K2StoreStrapper::addCSS(); $yes = JText::_('K2STORE_YES'); $no = JText::_('K2STORE_NO'); $save_first = JText::_('K2STORE_SAVE_FIRST'); $script = "\n \t\tif(typeof(k2store) == 'undefined') {\n\t\t\tvar k2store = {};\n\t\t}\n\t\tif(typeof(k2store.jQuery) == 'undefined') {\n\t\t\tk2store.jQuery = jQuery.noConflict();\n\t\t}\n \t\t(function(\$) {\n \t\t\$(document).ready(function() {\n \t\t\t\$('#optionselector').autocomplete({\r\n \t\t\t\tsource : function(request, response) {\r\n \t\t\t\t\t\$.ajax({\r\n \t\t\t\t\t\ttype : 'post',\r\n \t\t\t\t\t\turl : 'index.php?option=com_k2store&view=options&task=getOptions',\r\n \t\t\t\t\t\tdata : 'q=' + request.term,\r\n \t\t\t\t\t\tdataType : 'json',\r\n \t\t\t\t\t\tsuccess : function(data) {\r\n \t\t\t\t\t\t\t\$('#optionselector').removeClass('optionsLoading');\r\n \t\t\t\t\t\t\tresponse(\$.map(data, function(item) {\r\n \t\t\t\t\t\t\t\treturn {\r\n \t\t\t\t\t\t\t\t\tlabel: item.option_name+' ('+item.option_unique_name+')',\r\n \t\t\t\t\t\t\t\t\tvalue: item.option_id\r\n \t\t\t\t\t\t\t\t}\r\n \t\t\t\t\t\t\t}));\r\n \t\t\t\t\t\t}\r\n \t\t\t\t\t});\r\n \t\t\t\t},\r\n \t\t\t\tminLength : 2,\r\n \t\t\t\tselect : function(event, ui) {\r\n \t\t\t\t\t\$('<tr><td class=\"addedOption\">' + ui.item.label+ '</td><td><select name=\"plugins[k2storeitem_option][product_option_required]['+ ui.item.value+']\" ><option value=\"0\">{$no}</option><option value=\"1\">{$yes}</option></select></td><td>{$save_first}</td><td><span class=\"optionRemove\" onclick=\"k2store.jQuery(this).parent().parent().remove();\">x</span><input type=\"hidden\" value=\"' + ui.item.value+ '\" name=\"plugins[k2storeitem_option][product_option_ids][]\" /></td></tr>').insertBefore('.a_options');\r\n \t\t\t\t\tthis.value = '';\r\n \t\t\t\t\treturn false;\r\n \t\t\t\t},\r\n \t\t\t\tsearch : function(event, ui) {\r\n \t\t\t\t\t\$('#optionselector').addClass('optionsLoading');\r\n \t\t\t\t}\r\n \t\t\t});\r\n\r\n \t\t});\n \t\t})(k2store.jQuery);\n \t\t"; $doc->addScriptDeclaration($script); $product_id = $app->input->get('cid'); //$lists = $this->_getSelectProfiles($this->name, $this->id,$this->value); $html = ''; $html .= '<table id="attribute_options_table" class="adminlist table table-striped table-bordered k2store">'; $html .= '<thead>'; $html .= '<th>' . JText::_('K2STORE_OPTION_NAME') . '</th>'; $html .= '<th>' . JText::_('K2STORE_OPTION_REQUIRED') . '</th>'; $html .= '<th>' . JText::_('K2STORE_MANAGE_STOCK') . '</th>'; $html .= '<th>' . JText::_('K2STORE_OPTION_REMOVE') . '</th>'; $html .= '</thead>'; if ($product_id) { $html .= $this->_getCurrentOptions($product_id); } $html .= '<tbody>'; $html .= '<tr class="a_options"><td colspan="3">'; $html .= '<label class="attribute_option_label">'; $html .= JText::_('K2STORE_OPTIONFIELD_ADD_OPTIONS'); $html .= '</label>'; $html .= '<input id="optionselector" type="text" value="" />'; $html .= '</td></tr>'; $html .= '<tr><td colspan="3">'; $html .= '<div class="alert alert-block alert-info">'; $html .= JText::_('K2STORE_OPTIONFIELD_ADD_OPTIONS_HELP_TEXT'); $html .= '</div>'; $html .= '</td></tr>'; $html .= '<tr><td colspan="3">'; $html .= K2StorePopup::popup("index.php?option=com_k2store&view=products&task=setpaimport&tmpl=component&product_id={$product_id}", JText::_('K2STORE_IMPORT_PRODUCT_OPTIONS'), array(0)); $html .= '</a>'; $html .= '</td></tr>'; $html .= '</tbody></table>'; return $html; }
# copyright Copyright (C) 2012 Weblogicxindia.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://k2store.org # Technical Support: Forum - http://k2store.org/forum/index.html -------------------------------------------------------------------------*/ // no direct access defined('_JEXEC') or die('Restricted access'); //j3 compatibility if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } require_once JPATH_COMPONENT . '/helpers/utilities.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . '/library/prices.php'; require_once JPATH_ADMINISTRATOR . '/components/com_k2store/helpers/strapper.php'; K2StoreStrapper::addJS(); K2StoreStrapper::addCSS(); jimport('joomla.filesystem.file'); jimport('joomla.html.parameter'); JLoader::register('K2StoreController', JPATH_COMPONENT . DS . 'controllers' . DS . 'controller.php'); JLoader::register('K2StoreModel', JPATH_ADMINISTRATOR . '/components//com_k2store/models/model.php'); JLoader::register('K2StoreView', JPATH_ADMINISTRATOR . '/components//com_k2store/views/view.php'); // Require specific controller if requested $app = JFactory::getApplication(); $controller = $app->input->getWord('view', 'mycart'); $task = $app->input->getWord('task'); if (JFile::exists(JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php')) { require_once JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php'; $classname = 'k2storeController' . $controller; $controller = new $classname(); $controller->execute($task); $controller->redirect();
<?php /*------------------------------------------------------------------------ # mod_k2store_cart - K2Store Cart # ------------------------------------------------------------------------ # author Sasi varna kumar - Weblogicx India http://www.weblogicxindia.com # copyright Copyright (C) 2012 Weblogicxindia.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://k2store.org # Technical Support: Forum - http://k2store.org/forum/index.html -------------------------------------------------------------------------*/ // no direct access defined('_JEXEC') or die('Restricted access'); require_once JPATH_ADMINISTRATOR . '/components/com_k2store/helpers/strapper.php'; K2StoreStrapper::addJS(); $action = JRoute::_('index.php'); ?> <script type="text/javascript"> <!-- if(typeof(k2store) == 'undefined') { var k2store = {}; } if(typeof(k2store.jQuery) == 'undefined') { k2store.jQuery = jQuery.noConflict(); } //--> </script> <style type="text/css"> #k2store_currency {
function display($field, $value, $map, $inside, $options = '', $test = false, $allFields = null, $allValues = null) { if (empty($field->field_options['format'])) { $field->field_options['format'] = "HH:mm"; } $format = $field->field_options['format']; $size = $options . empty($field->field_options['size']) ? '' : ' size="' . $field->field_options['size'] . '"'; $isAdmin = false; if (JFactory::getApplication()->isAdmin()) { $isAdmin = true; } require_once JPATH_ADMINISTRATOR . '/components/com_k2store/helpers/strapper.php'; $timepicker_script = K2StoreStrapper::getTimePickerScript('', $format, $map, $isAdmin); $script = '<script type="text/javascript">' . $timepicker_script . '</script>'; $this->class = $map . '_time'; //$html ='<input class="'.$this->class.'" id="'.$this->prefix.$field->field_namekey.$this->suffix.'" '.$size.' '.$js.' '.$options.' type="'.$this->type.'" name="'.$name.'" value="'.$value.'" />'; $html = parent::display($field, $value, $map, $inside, $options, $test, $allFields, $allValues); return $script . $html; }
public static function getAjaxCart($item) { require_once JPATH_ADMINISTRATOR . '/components/com_k2store/helpers/strapper.php'; K2StoreStrapper::addJS(); K2StoreStrapper::addCSS(); $app = JFactory::getApplication(); $html = ''; JLoader::register("K2StoreViewMyCart", JPATH_SITE . "/components/com_k2store/views/mycart/view.html.php"); $layout = 'addtocart'; $view = new K2StoreViewMyCart(); //$view->_basePath = JPATH_ROOT.DS.'components'.DS.'com_k2store'; $view->addTemplatePath(JPATH_SITE . '/components/com_k2store/views/mycart/tmpl'); $view->addTemplatePath(JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_k2store/mycart'); require_once JPATH_SITE . '/components/com_k2store/models/mycart.php'; $model = new K2StoreModelMyCart(); $product_id = $item->product_id = $item->id; $view->assign('_basePath', JPATH_SITE . DS . 'components' . DS . 'com_k2store'); $view->set('_controller', 'mycart'); $view->set('_view', 'mycart'); $view->set('_doTask', true); $view->set('hidemenu', true); $view->setModel($model, true); $view->setLayout($layout); $view->assign('product_id', $product_id); $config = JComponentHelper::getParams('com_k2store'); $show_tax = $config->get('show_tax_total', '1'); // $show_attributes = $config->get( 'show_product_attributes', 1); $view->assign('show_tax', $show_tax); $view->assign('params', $config); //$view->assign( 'show_attributes', $show_attributes ); $item->product = $product = self::getItemInfo($product_id); $stock = $product->stock; if (isset($stock->min_sale_qty) && $stock->min_sale_qty > 1) { $item->product_quantity = (int) $stock->min_sale_qty; $item->item_minimum_notice = JText::sprintf('K2STORE_MINIMUM_QUANTITY_NOTIFICATION', $item->title, (int) $stock->min_sale_qty); } else { $item->product_quantity = 1; } //get attributes $attributes = $model->getProductOptions($product_id); if (count($attributes) && $product->stock->manage_stock == 1 && K2STORE_PRO == 1 && !$config->get('allow_backorder', 0)) { //get unavailable attribute options $attributes = $model->processAttributeOptions($attributes, $product); //print_r($attributes ); } $item->attributes = $attributes; //get k2store product item $product = self::getItemInfo($product_id); $stock = K2StoreInventory::getStock($product_id); //quantity //get prices $item->prices = K2StorePrices::getPrice($product_id, $item->product_quantity); //base price $item->price = $item->prices->product_baseprice; //tax $t = new K2StoreTax(); //assign tax class to the view. so that we dont have to call it everytime. $view->assign('tax_class', $t); $tax = $t->getProductTax($item->price, $item->product_id); $item->tax = isset($tax) ? $tax : 0; //special price $item->special_price = isset($item->prices->product_specialprice) ? (double) $item->prices->product_specialprice : null; $sp_tax = $t->getProductTax($item->special_price, $item->product_id); $item->sp_tax = isset($sp_tax) ? $sp_tax : 0; //now get the total stock if (K2STORE_PRO == 1) { JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2store/models'); $qtyModel = JModelLegacy::getInstance('ProductQuantities', 'K2StoreModel'); $qtyModel->setState('filter_product', $item->product_id); $item->product_stock = $qtyModel->getQuantityTotal(); } else { $item->product_stock = ''; } $view->assign('attributes', $attributes); $view->assign('product', $product); $view->assign('params', $config); //trigger onBeforeAddtocart plugin event if (!is_object($item->event)) { $item->event = new stdClass(); } $item->event->K2StoreBeforeCartDisplay = ''; $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('k2store'); $results = $dispatcher->trigger("onK2StoreBeforeCartDisplay", array($item)); $item->event->K2StoreBeforeCartDisplay = trim(implode("\n", $results)); $view->assign('item', $item); ob_start(); $view->display(); $html = ob_get_contents(); ob_end_clean(); return $html; }