Example #1
0
 public function onBeforeDispatch()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         $layout = new JLayoutFile('joomla.sidebars.submenu');
         $layout->addIncludePaths(JPATH_ADMINISTRATOR . '/components/com_j2store/layouts');
     }
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/strapper.php';
     J2StoreStrapper::addJS();
     J2StoreStrapper::addCSS();
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/j2store.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/popup.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/select.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/j2html.php';
     return parent::onBeforeDispatch();
 }
Example #2
0
 public function get_product_price_html($type = 'price')
 {
     $html = '';
     if (empty($this->j2store_product_id)) {
         return $html;
     }
     //ok. We have a product.
     $view = $this->get_view();
     $product = $this->get_product();
     $model = F0FModel::getTmpInstance('Products', 'J2StoreModel');
     $view->setModel($model, true);
     $model->setState('task', 'read');
     J2StoreStrapper::addJS();
     J2StoreStrapper::addCSS();
     $params = J2Store::config();
     switch ($type) {
         case 'price':
         default:
             $params->set('show_base_price', 1);
             $params->set('show_price_field', 1);
             break;
         case 'saleprice':
             $params->set('show_base_price', 0);
             $params->set('show_price_field', 1);
             break;
         case 'regularprice':
             $params->set('show_base_price', 1);
             $params->set('show_price_field', 0);
             break;
     }
     $view->assign('product', $product);
     $view->assign('params', $params);
     $view->setLayout('item_price');
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
Example #3
0
<?php

/*------------------------------------------------------------------------
# mod_j2store_cart - J2 Store Cart
# ------------------------------------------------------------------------
# author    Sasi varna kumar - Weblogicx India http://www.weblogicxindia.com
# copyright Copyright (C) 2014 - 19 Weblogicxindia.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://j2store.org
# Technical Support:  Forum - http://j2store.org/forum/index.html
-------------------------------------------------------------------------*/
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/strapper.php';
J2StoreStrapper::addJS();
$action = JRoute::_('index.php');
?>
<script type="text/javascript">
<!--
if(typeof(j2store) == 'undefined') {
	var j2store = {};
}
if(typeof(j2store.jQuery) == 'undefined') {
	j2store.jQuery = jQuery.noConflict();
}

//-->
</script>

<style type="text/css">
#j2store_currency {
Example #4
0
 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_j2store/helpers/strapper.php';
     $timepicker_script = J2StoreStrapper::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;
 }
Example #5
0
//j3 compatibility
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
JLoader::register('J2StoreController', JPATH_ADMINISTRATOR . '/components/com_j2store/controllers/controller.php');
JLoader::register('J2StoreView', JPATH_ADMINISTRATOR . '/components/com_j2store/views/view.php');
JLoader::register('J2StoreModel', JPATH_ADMINISTRATOR . '/components/com_j2store/models/model.php');
require_once JPATH_SITE . '/components/com_j2store/helpers/utilities.php';
require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/base.php';
require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/toolbar.php';
require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/version.php';
require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/strapper.php';
$version = new J2StoreVersion();
$version->load_version_defines();
J2StoreStrapper::addJS();
J2StoreStrapper::addCSS();
//handle live update
require_once JPATH_ADMINISTRATOR . '/components/com_j2store/liveupdate/liveupdate.php';
if ($app->input->getCmd('view', '') == 'liveupdate') {
    LiveUpdate::handleRequest();
    return;
}
/*
 * Make sure the user is authorized to view this page
*/
$controller = $app->input->getWord('view', 'cpanel');
if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_j2store/controllers/' . $controller . '.php') && $controller != 'countries' && $controller != 'zones' && $controller != 'country' && $controller != 'zone' && $controller != 'taxprofiles' && $controller != 'taxprofile' && $controller != 'taxrates' && $controller != 'taxrate' && $controller != 'geozones' && $controller != 'geozone' && $controller != 'geozonerules' && $controller != 'geozonerule' && $controller != 'storeprofiles' && $controller != 'storeprofile' && $controller != 'lengths' && $controller != 'length' && $controller != 'weights' && $controller != 'weight' && $controller != 'currencies' && $controller != 'currency' && $controller != 'emailtemplates' && $controller != 'emailtemplate' && $controller != 'orderstatuses' && $controller != 'orderstatus' && $controller != 'layouts' && $controller != 'layout') {
    require_once JPATH_ADMINISTRATOR . '/components/com_j2store/controllers/' . $controller . '.php';
    $classname = 'J2StoreController' . ucwords($controller);
    $controller = new $classname();
} else {
            ?>
          <b><?php 
            echo JText::_($option['option_name']);
            ?>
:</b><br />
          <input type="text" name="product_option[<?php 
            echo $option['productoption_id'];
            ?>
]" value="<?php 
            echo $option['optionvalue'];
            ?>
" class="j2store_time" />
        </div>
        <br />
        <?php 
            $localisation = json_encode(J2StoreStrapper::getDateLocalisation(true));
            ?>
        <script type="text/javascript">
        (function($) {
          $(document).ready(function(){
            var loc = JSON.parse('<?php 
            echo $localisation;
            ?>
');
            $('.j2store_time').timepicker({timeFormat: 'HH:mm', loc});            
          });
        })(j2store.jQuery);
        </script>
        <?php 
        }
        ?>
            ?>
:</b><br />
          <input type="text" name="product_option[<?php 
            echo $option['productoption_id'];
            ?>
]" value="<?php 
            echo $option['optionvalue'];
            ?>
" class="<?php 
            echo $element_datetime;
            ?>
" />
        </div>
        <br />
        <?php 
            J2StoreStrapper::addDateTimePicker($element_datetime, $option['option_params']);
            ?>
                 
        <?php 
        }
        ?>

        <?php 
        if ($option['type'] == 'time') {
            ?>
        <!-- time -->
        <div id="option-<?php 
            echo $option['productoption_id'];
            ?>
" class="option">
          <?php 
Example #8
0
 public static function getAjaxCart($item, $values = array())
 {
     $app = JFactory::getApplication();
     if (is_array($values) && !count($values)) {
         $values = $app->input->getArray($_REQUEST);
     }
     //load javascript files
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/strapper.php';
     J2StoreStrapper::addJS();
     J2StoreStrapper::addCSS();
     $html = '';
     JLoader::register("J2StoreViewMyCart", JPATH_SITE . "/components/com_j2store/views/mycart/view.html.php");
     $layout = 'addtocart';
     $view = new J2StoreViewMyCart();
     $view->addTemplatePath(JPATH_SITE . '/components/com_j2store/views/mycart/tmpl');
     $view->addTemplatePath(JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_j2store/mycart');
     require_once JPATH_SITE . '/components/com_j2store/models/mycart.php';
     $model = new J2StoreModelMyCart();
     $product_id = $item->product_id = $item->id;
     $view->assign('_basePath', JPATH_SITE . '/components/com_j2store');
     $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_j2store');
     $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 );
     //get j2store fields
     $item->product = $product = self::getItemInfo($product_id);
     $item->attribs = $product->product->attribs;
     //quantity
     if (isset($product->min_sale_qty) && $product->min_sale_qty > 1 && J2STORE_PRO == 1) {
         $item->product_quantity = (int) $product->min_sale_qty;
         $item->item_minimum_notice = JText::sprintf('J2STORE_MINIMUM_QUANTITY_NOTIFICATION', $product->product_name, (int) $product->min_sale_qty);
     } else {
         $item->product_quantity = 1;
     }
     //get attributes
     $attributes = $model->getProductOptions($product_id);
     if (count($attributes) && $product->manage_stock == 1 && J2STORE_PRO == 1 && !$config->get('allow_backorder', 0)) {
         //get unavailable attribute options
         $attributes = $model->processAttributeOptions($attributes, $product);
         //print_r($attributes );
     }
     //get prices
     $item->prices = J2StorePrices::getPrice($product_id, $item->product_quantity);
     //tax
     $t = new J2StoreTax();
     //assign tax class to the view. so that we dont have to call it everytime.
     $view->assign('tax_class', $t);
     if (isset($item->prices->product_specialprice) && $item->prices->product_specialprice > 0) {
         $item->special_price = $item->prices->product_specialprice;
     } elseif (isset($item->prices->product_customer_groupprice) && $item->prices->product_customer_groupprice >= 0) {
         $item->special_price = $item->prices->product_customer_groupprice;
     } else {
         $item->special_price = null;
     }
     $sp_tax = $t->getProductTax($item->special_price, $item->product_id);
     $item->sp_tax = isset($sp_tax) ? $sp_tax : 0;
     if ($item->special_price) {
         //we have an offer
         $item->price = $item->prices->product_baseprice;
     } else {
         $item->price = $item->prices->product_price;
     }
     $tax = $t->getProductTax($item->price, $item->product_id);
     $item->tax = isset($tax) ? $tax : 0;
     //now get the total stock
     if (J2STORE_PRO == 1 && $product->manage_stock == 1) {
         JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/models');
         $qtyModel = JModelLegacy::getInstance('ProductQuantities', 'J2StoreModel');
         $qtyModel->setState('filter_product', $item->product_id);
         if ($config->get('show_option_stock', 0)) {
             $qtyModel->setState('filter_productid', $item->product_id);
             $item->option_stock = $qtyModel->getList();
         }
         $item->product_stock = $qtyModel->getQuantityTotal();
     } else {
         $item->product_stock = '';
     }
     //item sku
     $item->product_sku = $product->item_sku;
     $view->assign('product', $product);
     $view->assign('attributes', $attributes);
     $view->assign('params', $config);
     $view->assign('item', $item);
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
Example #9
0
    /**
     * Add the list JS code.
     *
     * @return void
     */
    private function listJs()
    {
        // Add JS once
        if (is_null(self::$listJs)) {
            self::$listJs = true;
            // Includes the ajax add to cart js.
            J2StoreStrapper::addJs();
            // Watch quantity input and update add to cart button data.
            $doc = JFactory::getDocument();
            $doc->addScriptDeclaration('jQuery(document).ready(function ($) {
			$(document).on(\'change\', \'input[name=product_qty]\', function () {
				var productId = $(this).data(\'product_id\'),
				q = $(this).val();
				$(\'a[data-product_id=\' + productId + \']\').data(\'product_qty\', q);
			});
		});
		');
        }
    }