Example #1
1
 public function sendVouchers($cids)
 {
     $app = JFactory::getApplication();
     $config = JFactory::getConfig();
     $params = J2Store::config();
     $sitename = $config->get('sitename');
     $emailHelper = J2Store::email();
     $mailfrom = $config->get('mailfrom');
     $fromname = $config->get('fromname');
     $failed = 0;
     foreach ($cids as $cid) {
         $voucherTable = F0FTable::getAnInstance('Voucher', 'J2StoreTable')->getClone();
         $voucherTable->load($cid);
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->isHtml(true);
         $mailer->addRecipient($voucherTable->email_to);
         $mailer->setSubject($voucherTable->subject);
         // parse inline images before setting the body
         $emailHelper->processInlineImages($voucherTable->email_body, $mailer);
         $mailer->setBody($voucherTable->email_body);
         //Allow plugins to modify
         J2Store::plugin()->event('BeforeSendVoucher', array($voucherTable, &$mailer));
         if ($mailer->Send() !== true) {
             $this->setError(JText::sprintf('J2STORE_VOUCHERS_SENDING_FAILED_TO_RECEIPIENT', $voucherTable->email_to));
             $failed++;
         }
         J2Store::plugin()->event('AfterSendVoucher', array($voucherTable, &$mailer));
         $mailer = null;
     }
     if ($failed > 0) {
         return false;
     }
     return true;
 }
Example #2
1
 public static function getAdavcedItems()
 {
     if (empty(self::$_items)) {
         $j2params = J2Store::config();
         $order = F0FModel::getTmpInstance('Orders', 'J2StoreModel')->initOrder()->getOrder();
         $module = JModuleHelper::getModule('mod_j2store_cart');
         // Get params and output
         $params = new JRegistry($module->params);
         $items = $order->getItems();
         self::$_items = $items;
     }
     return self::$_items;
 }
Example #3
0
 protected function onBeforeBrowse()
 {
     $db = JFactory::getDbo();
     $config = J2Store::config();
     $installation_complete = $config->get('installation_complete', 0);
     if (!$installation_complete) {
         //installation not completed
         JFactory::getApplication()->redirect('index.php?option=com_j2store&view=postconfig');
     }
     //first check if the currency table has a default records at least.
     $rows = F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->enabled(1)->getList();
     if (count($rows) < 1) {
         //no records found. Dumb default data
         F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->create_currency_by_code('USD', 'USD');
     }
     //update schema
     $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_j2store/sql/xml'));
     $dbInstaller->updateSchema();
     //update cart table
     $cols = $db->getTableColumns('#__j2store_carts');
     $cols_to_delete = array('product_id', 'vendor_id', 'variant_id', 'product_type', 'product_options', 'product_qty');
     foreach ($cols_to_delete as $key) {
         if (array_key_exists($key, $cols)) {
             $db->setQuery('ALTER TABLE #__j2store_carts DROP COLUMN ' . $key);
             try {
                 $db->execute();
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
         }
     }
     return parent::onBeforeBrowse();
 }
Example #4
0
 /**
  *
  * @return unknown_type
  */
 public function display($articleid)
 {
     $html = '';
     if (empty($articleid)) {
         return;
     }
     //try loading language associations
     if (version_compare(JVERSION, '3.3', 'gt')) {
         $id = $this->getAssociatedArticle($articleid);
         if ($id && is_int($id)) {
             $articleid = $id;
         }
     }
     $item = $this->getArticle($articleid);
     $mainframe = JFactory::getApplication();
     // Return html if the load fails
     if (!$item->id) {
         return $html;
     }
     $item->title = JFilterOutput::ampReplace($item->title);
     $item->text = '';
     $item->text = $item->introtext . chr(13) . chr(13) . $item->fulltext;
     $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     $params = $mainframe->getParams('com_content');
     $prepare_content = J2Store::config()->get('prepare_content', 0);
     if ($prepare_content) {
         $html .= JHtml::_('content.prepare', $item->text);
     } else {
         $html .= $item->text;
     }
     return $html;
 }
 /**
  * Method to save data
  * (non-PHPdoc)
  * @see F0FController::save()
  */
 public function save()
 {
     //security check
     JSession::checkToken() or die('Invalid Token');
     $app = JFactory::getApplication();
     $model = $this->getModel('configurations');
     $data = $app->input->getArray($_POST);
     $task = $this->getTask();
     $token = JSession::getFormToken();
     unset($data['option']);
     unset($data['task']);
     unset($data['view']);
     unset($data[$token]);
     if ($task == 'populatedata') {
         $this->getPopulatedData($data);
     }
     $db = JFactory::getDbo();
     $config = J2Store::config();
     $query = 'REPLACE INTO #__j2store_configurations (config_meta_key,config_meta_value) VALUES ';
     jimport('joomla.filter.filterinput');
     $filter = JFilterInput::getInstance(null, null, 1, 1);
     $conditions = array();
     foreach ($data as $metakey => $value) {
         if (is_array($value)) {
             $value = implode(',', $value);
         }
         //now clean up the value
         if ($metakey == 'store_billing_layout' || $metakey == 'store_shipping_layout' || $metakey == 'store_payment_layout') {
             $value = $app->input->get($metakey, '', 'raw');
             $clean_value = $filter->clean($value, 'html');
         } else {
             $clean_value = $filter->clean($value, 'string');
         }
         $config->set($metakey, $clean_value);
         $conditions[] = '(' . $db->q(strip_tags($metakey)) . ',' . $db->q($clean_value) . ')';
     }
     $query .= implode(',', $conditions);
     try {
         $db->setQuery($query);
         $db->execute();
         //update currencies
         F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->updateCurrencies(false);
         $msg = JText::_('J2STORE_CHANGES_SAVED');
     } catch (Exception $e) {
         $msg = $e->getMessage();
         $msgType = 'Warning';
     }
     switch ($task) {
         case 'apply':
             $url = 'index.php?option=com_j2store&view=configuration';
             break;
         case 'populatedata':
             $url = 'index.php?option=com_j2store&view=configuration';
             break;
         case 'save':
             $url = 'index.php?option=com_j2store&view=cpanels';
             break;
     }
     $this->setRedirect($url, $msg, $msgType);
 }
 /**
  * Method to return j2store cart html
  * @param object $item
  * @return string
  */
 public function onDJCatalog2BeforeCart($itemObject, $params, $context)
 {
     if (!defined('F0F_INCLUDED')) {
         include_once JPATH_LIBRARIES . '/f0f/include.php';
     }
     $app = JFactory::getApplication();
     $option = $app->input->getString('option');
     if ($app->isSite() && $option == 'com_djcatalog2') {
         $html = '';
         $params = $this->params;
         $j2params = J2Store::config();
         $cache = JFactory::getCache();
         $cache->clean('com_j2store');
         if (isset($itemObject->id) && !empty($itemObject->id)) {
             $product = F0FTable::getAnInstance('Product', 'J2StoreTable');
             $product->reset();
             if ($product->get_product_by_source('com_djcatalog2', $itemObject->id)) {
                 $image_html = '';
                 if ($option == 'com_djcatalog2' && $context == 'items.items') {
                     $mainimage_width = $this->params->get('list_image_thumbnail_width', 120);
                     $additional_image_width = $this->params->get('list_product_additional_image_width', 80);
                     if ($this->params->get('category_product_options', 1) == 1) {
                         $html = $product->get_product_html();
                     } else {
                         $html = $product->get_product_html('without_options');
                     }
                     $show_image = $this->params->get('category_display_j2store_images', 1);
                     $image_type = $this->params->get('category_image_type', 'thumbnail');
                     //to set enable zoom option in category view
                     if ($this->params->get('category_enable_image_zoom', 1)) {
                         $this->params->set('item_enable_image_zoom', 1);
                         $images = $product->get_product_images_html($image_type, $this->params);
                     } else {
                         $this->params->set('item_enable_image_zoom', 0);
                         $images = $product->get_product_images_html($image_type, $this->params);
                     }
                 } else {
                     $html = $product->get_product_html();
                     //set the image width
                     $mainimage_width = $this->params->get('item_product_main_image_width', 120);
                     $additional_image_width = $this->params->get('item_product_additional_image_width', 100);
                     $show_image = $this->params->get('item_display_j2store_images', 1);
                     $image_type = $this->params->get('item_image_type', 'thumbnail');
                     $images = $product->get_product_images_html($image_type, $this->params);
                 }
                 //custom css to adjust the j2store product images width
                 $content = ".j2store-product-images .j2store-mainimage img ,.j2store-product-images .j2store-thumbnail-image img ,.upsell-product-image img , .cross-sell-product-image img {width:{$mainimage_width}px} .j2store-img-responsive  { width :{$additional_image_width}px;}";
                 JFactory::getDocument()->addStyleDeclaration($content);
                 if ($show_image && $images !== false) {
                     $image_html = $images;
                 }
                 if ($html === false) {
                     $html = '';
                 }
                 $html = $image_html . $html;
             }
         }
     }
     return $html;
 }
Example #7
0
 public function saveOne($metakey, $value)
 {
     $db = JFactory::getDbo();
     $config = J2Store::config();
     $query = 'REPLACE INTO #__j2store_configurations (config_meta_key,config_meta_value) VALUES ';
     jimport('joomla.filter.filterinput');
     $filter = JFilterInput::getInstance(null, null, 1, 1);
     $conditions = array();
     if (is_array($value)) {
         $value = implode(',', $value);
     }
     // now clean up the value
     if ($metakey == 'store_billing_layout' || $metakey == 'store_shipping_layout' || $metakey == 'store_payment_layout') {
         $value = $app->input->get($metakey, '', 'raw');
         $clean_value = $filter->clean($value, 'html');
     } else {
         $clean_value = $filter->clean($value, 'string');
     }
     $config->set($metakey, $clean_value);
     $conditions[] = '(' . $db->q(strip_tags($metakey)) . ',' . $db->q($clean_value) . ')';
     $query .= implode(',', $conditions);
     try {
         $db->setQuery($query);
         $db->execute();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Example #8
0
 public static function addCSS()
 {
     $app = JFactory::getApplication();
     $j2storeparams = J2Store::config();
     $document = JFactory::getDocument();
     if ($app->isAdmin()) {
         // always load namespaced bootstrap
         // $document->addStyleSheet(JURI::root(true).'/media/j2store/css/bootstrap.min.css');
     }
     if (!version_compare(JVERSION, '3.0', 'ge')) {
         // for site side, check if the param is enabled.
         if ($app->isSite() && $j2storeparams->get('load_bootstrap', 1)) {
             $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/bootstrap.min.css');
         }
     }
     // jquery UI css
     $ui_location = $j2storeparams->get('load_jquery_ui', 3);
     switch ($ui_location) {
         case '0':
             // load nothing
             break;
         case '1':
             if ($app->isSite()) {
                 $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/jquery-ui-custom.css');
             }
             break;
         case '2':
             if ($app->isAdmin()) {
                 $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/jquery-ui-custom.css');
             }
             break;
         case '3':
         default:
             $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/jquery-ui-custom.css');
             break;
     }
     if ($app->isAdmin()) {
         $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/j2store_admin.css');
     } else {
         $document->addStyleSheet(JUri::root() . 'media/j2store/css/font-awesome.min.css');
         // Add related CSS to the <head>
         if ($document->getType() == 'html' && $j2storeparams->get('j2store_enable_css')) {
             $template = self::getDefaultTemplate();
             jimport('joomla.filesystem.file');
             // j2store.css
             if (JFile::exists(JPATH_SITE . '/templates/' . $template . '/css/j2store.css')) {
                 $document->addStyleSheet(JURI::root(true) . '/templates/' . $template . '/css/j2store.css');
             } else {
                 $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/j2store.css');
             }
         } else {
             $document->addStyleSheet(JURI::root(true) . '/media/j2store/css/j2store.css');
         }
     }
 }
Example #9
0
 protected function onDisplay($tpl = null)
 {
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $user = JFactory::getUser();
     $view = $this->input->getCmd('view', 'checkout');
     $this->params = J2Store::config();
     $this->currency = J2Store::currency();
     $this->storeProfile = J2Store::storeProfile();
     $this->user = $user;
     return true;
 }
Example #10
0
 public function onBrowse($tpl = null)
 {
     $systemPlugin = JPluginHelper::isEnabled('system', 'j2store');
     if (!$systemPlugin) {
         //System plugin disabled. Manually enable it
         J2Store::plugin()->enableJ2StorePlugin();
     }
     $this->assign('systemPlugin', $systemPlugin);
     $this->assign('cachePlugin', JPluginHelper::isEnabled('system', 'cache'));
     $this->assign('params', J2Store::config());
     return true;
 }
Example #11
0
 public function browse()
 {
     if (parent::browse()) {
         $config = J2Store::config();
         $complete = $config->get('installation_complete', 0);
         if ($complete) {
             JFactory::getApplication()->redirect('index.php?option=com_j2store&view=cpanel', JText::_('J2STORE_POSTCONFIG_STORE_SETUP_DONE_ALREADY'));
         }
         return true;
     }
     return false;
 }
Example #12
0
 public function updateCurrencies($force = false)
 {
     if (extension_loaded('curl')) {
         $data = array();
         $db = JFactory::getDbo();
         $store = J2Store::config();
         //sanity check
         if ($store->get('config_currency_auto', 1) != 1) {
             return;
         }
         //update the default currency
         $query = $db->getQuery(true);
         $query->update('#__j2store_currencies')->set('currency_value =' . $db->q('1.00000'))->set('modified_on=' . $db->q(date('Y-m-d H:i:s')))->where('currency_code=' . $db->q($store->get('config_currency')));
         $db->setQuery($query);
         try {
             $db->execute();
         } catch (Exception $e) {
             $this->setError($e->getMessage());
         }
         $query = $db->getQuery(true);
         $query->select('*')->from('#__j2store_currencies')->where('currency_code !=' . $db->q($store->get('config_currency')));
         if ($force) {
             $nullDate = JFactory::getDbo()->getNullDate();
             $query->where('(modified_on=' . $db->q(date('Y-m-d H:i:s', strtotime('-1 day'))) . ' OR modified_on=' . $db->q($nullDate) . ')');
         }
         $db->setQuery($query);
         $rows = $db->loadAssocList();
         foreach ($rows as $result) {
             $data[] = $store->get('config_currency') . $result['currency_code'] . '=X';
         }
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         $content = curl_exec($curl);
         curl_close($curl);
         $lines = explode("\n", trim($content));
         foreach ($lines as $line) {
             $currency = JString::substr($line, 4, 3);
             $value = JString::substr($line, 11, 6);
             if ((double) $value) {
                 $query = $db->getQuery(true);
                 $query->update('#__j2store_currencies')->set('currency_value =' . $db->q((double) $value))->set('modified_on=' . $db->q(date('Y-m-d H:i:s')))->where('currency_code=' . $db->q($currency));
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
 }
Example #13
0
 public function checkAttachmentPathExists()
 {
     $error = false;
     JLoader::import('joomla.filesystem.folder');
     JLoader::import('joomla.filesystem.file');
     $params = J2Store::config();
     $root = $params->get('attachmentfolderpath');
     $folder = JPATH_ROOT . '/' . $root;
     if (empty($folder) || !JFolder::exists($folder)) {
         //in case, the attachment path is outside the root
         if (!JFolder::exists($root)) {
             $error = true;
         }
     }
     return $error;
 }
Example #14
0
 /**
  * Executes before rendering the page for the Add task.
  *
  * @param   string  $tpl  Subtemplate to use
  *
  * @return  boolean  Return true to allow rendering of the page
  */
 protected function onAdd($tpl = null)
 {
     $id = $this->input->getInt('id');
     $this->order = F0FTable::getAnInstance('Order', 'J2StoreTable');
     $this->order->load($id);
     $this->item = $this->order;
     $this->fieldClass = J2Store::getSelectableBase();
     $this->params = J2Store::config();
     $this->currency = J2Store::currency();
     $this->taxes = $this->order->getOrderTaxrates();
     $this->shipping = $this->order->getOrderShippingRate();
     $this->coupons = $this->order->getOrderCoupons();
     $this->vouchers = $this->order->getOrderVouchers();
     $this->orderinfo = $this->order->getOrderInformation();
     $this->orderhistory = $this->order->getOrderHistory();
     parent::onAdd();
 }
Example #15
0
 /**
  * Public constructor. Initialises the protected members as well.
  *
  * @param array $config
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     $isPro = defined('J2STORE_PRO') ? J2STORE_PRO : 0;
     JLoader::import('joomla.application.component.helper');
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/helpers/j2store.php';
     $params = J2Store::config();
     $dlid = $params->get('downloadid', '');
     $this->extraQuery = null;
     // If I have a valid Download ID I will need to use a non-blank extra_query in Joomla! 3.2+
     if (preg_match('/^([0-9]{1,}:)?[0-9a-f]{32}$/i', $dlid)) {
         // Even if the user entered a Download ID in the Core version. Let's switch his update channel to Professional
         $isPro = true;
         $this->extraQuery = 'dlid=' . $dlid;
     }
     $this->updateSiteName = 'J2Store ' . ($isPro ? 'Professional' : 'Core');
     $this->updateSite = 'http://cdn.j2store.org/j2store' . ($isPro ? '' : 'core') . '.xml';
 }
Example #16
0
 public function alert($type, $title, $message)
 {
     $html = '';
     //check if this alert to be shown.
     $params = J2Store::config();
     if ($params->get($type, 0)) {
         return $html;
     }
     //message not hidden
     $url = JRoute::_('index.php?option=com_j2store&view=cpanels&task=notifications&message_type=' . $type . '&' . JSession::getFormToken() . '=1');
     $html .= '<div class="user-notifications ' . $type . ' alert alert-block">';
     $html .= '<h3>' . $title . '</h3>';
     $html .= '<p>' . $message . '</p>';
     $html .= '<br />';
     $html .= '<a class="btn btn-danger" href="' . $url . '">' . JText::_('J2STORE_GOT_IT_AND_HIDE') . '</a>';
     $html .= '</div>';
     return $html;
 }
Example #17
0
 protected function onRead($tpl = null)
 {
     /* JRequest::setVar('hidemainmenu', true);
     		$model = $this->getModel('Products');
     		$product_id = $this->input->getInt('id', 0);
     		if(!$product_id) return false;
     		
     		$product = F0FTable::getAnInstance('Product', 'J2StoreTable')->get_product_by_id($product_id);
     		if($product === false) return false;
     				
     		$model->getProduct($product);
     		$this->product = $product;
     		//process tax
     		$this->taxModel = F0FModel::getTmpInstance('TaxProfiles', 'J2StoreModel');
     		$this->params = J2Store::config();
      */
     $this->params = J2Store::config();
     return true;
 }
Example #18
0
 public function history()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     if ($id > 0) {
         $view = $this->getThisView();
         if ($model = $this->getThisModel()) {
             // Push the model into the view (as default)
             $view->setModel($model, true);
         }
         $voucher = F0FTable::getAnInstance('Voucher', 'J2StoreTable');
         $voucher->load($id);
         $view->assign('voucher', $voucher);
         $voucher_history = $model->getVoucherHistory();
         $view->assign('vouchers', $voucher_history);
         $view->assign('params', J2Store::config());
     }
     $view->setLayout('history');
     $view->display();
 }
Example #19
0
 public function history()
 {
     $app = JFactory::getApplication();
     $coupon_id = $app->input->getInt('coupon_id');
     $view = $this->getThisView();
     if ($coupon_id > 0) {
         if ($model = $this->getThisModel()) {
             // Push the model into the view (as default)
             $view->setModel($model, true);
         }
         $coupon = F0FTable::getAnInstance('Coupon', 'J2StoreTable');
         $coupon->load($coupon_id);
         $view->assign('coupon', $coupon);
         $coupon_history = $model->getCouponHistory();
         $view->assign('coupon_history', $coupon_history);
         $view->assign('params', J2Store::config());
         $view->assign('currency', J2Store::currency());
     }
     $view->setLayout('history');
     $view->display();
 }
Example #20
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 #21
0
 public function printShipping()
 {
     $app = JFactory::getApplication();
     $order_id = $this->input->getString('order_id');
     $view = $this->getThisView();
     if ($model = $this->getThisModel()) {
         // Push the model into the view (as default)
         $view->setModel($model, true);
     }
     $order = F0FTable::getInstance('Order', 'J2StoreTable');
     $order->load(array('order_id' => $order_id));
     $orderinfo = F0FTable::getAnInstance('Orderinfo', 'J2StoreTable');
     $orderinfo->load(array('order_id' => $order_id));
     $error = false;
     $view->assign('orderinfo', $orderinfo);
     $view->assign('item', $order);
     $view->assign('params', J2Store::config());
     $view->assign('error', $error);
     $view->setLayout('print_shipping');
     $view->display();
 }
Example #22
0
<?php

/**
 * @package J2Store
* @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org
* @license GNU GPL v3 or later
*/
// No direct access to this file
defined('_JEXEC') or die;
JHTML::_('behavior.modal');
$this->params = J2Store::config();
$plugin_title_html = J2Store::plugin()->eventWithHtml('AddMyProfileTab');
$plugin_content_html = J2Store::plugin()->eventWithHtml('AddMyProfileTabContent', array($this->orders));
?>
<div class="j2store">
	<div class="j2store-order j2store-myprofile">
		<h3><?php 
echo JText::_('J2STORE_MYPROFILE');
?>
</h3>
		 <div class="tabbable tabs">
         	   <ul class="nav nav-tabs">
                  <li class="active">
	                  	<a href="#orders-tab" data-toggle="tab"><i class="fa fa-th-large"></i>
	                  		 <?php 
echo JText::_('J2STORE_MYPROFILE_ORDERS');
?>
	                  	</a>
                 </li>
                 	<?php 
if ($this->params->get('download_area', 1)) {
Example #23
0
    ?>
</th>
	</thead>
	<tbody>
		<?php 
    foreach ($this->orders as $item) {
        ?>
		<?php 
        $order = F0FTable::getInstance('Order', 'J2StoreTable');
        $order->load(array('order_id' => $item->order_id));
        ?>
		<tr>
			<td><?php 
        $tz = JFactory::getConfig()->get('offset');
        $date = JFactory::getDate($item->created_on, $tz);
        $order_date = $date->format(J2Store::config()->get('date_format', JText::_('DATE_FORMAT_LC1')), true);
        echo $order_date;
        ?>
			</td>
			<td><?php 
        if ($item->invoice_number && !empty($item->invoice_prefix)) {
            $invoice = $item->invoice_prefix . $item->invoice_number;
        } else {
            $invoice = $item->j2store_order_id;
        }
        echo $invoice;
        ?>
</td>
			<td><?php 
        echo $currency->format($order->get_formatted_grandtotal());
        ?>
Example #24
0
 public static function getDateLocalisation($as_array = false)
 {
     //add localisation
     $params = J2Store::config();
     $language = JFactory::getLanguage()->getTag();
     if ($params->get('jquery_ui_localisation', 0) && strpos($language, 'en') === false) {
         $doc = JFactory::getDocument();
         $doc->addScript('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/i18n/jquery-ui-i18n.min.js');
         //set the language default
         $tag = explode('-', $language);
         if (isset($tag[0]) && JString::strlen($tag[0]) == 2) {
             $script = "";
             $script .= "(function(\$) { \$.datepicker.setDefaults(\$.datepicker.regional['{$tag[0]}']); })(j2store.jQuery);";
             $doc->addScriptDeclaration($script);
         }
     }
     //localisation
     $currentText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_CURRENT_TEXT'));
     $closeText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_CLOSE_TEXT'));
     $timeOnlyText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_CHOOSE_TIME'));
     $timeText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_TIME'));
     $hourText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_HOUR'));
     $minuteText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_MINUTE'));
     $secondText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_SECOND'));
     $millisecondText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_MILLISECOND'));
     $timezoneText = addslashes(JText::_('J2STORE_TIMEPICKER_JS_TIMEZONE'));
     if ($as_array) {
         $localisation = array('currentText' => $currentText, 'closeText' => $closeText, 'timeOnlyTitle' => $timeOnlyText, 'timeText' => $timeText, 'hourText' => $hourText, 'minuteText' => $minuteText, 'secondText' => $secondText, 'millisecText' => $millisecondText, 'timezoneText' => $timezoneText);
     } else {
         $localisation = "\n\t\t\tcurrentText: '{$currentText}',\n\t\t\tcloseText: '{$closeText}',\n\t\t\ttimeOnlyTitle: '{$timeOnlyText}',\n\t\t\ttimeText: '{$timeText}',\n\t\t\thourText: '{$hourText}',\n\t\t\tminuteText: '{$minuteText}',\n\t\t\tsecondText: '{$secondText}',\n\t\t\tmillisecText: '{$millisecondText}',\n\t\t\ttimezoneText: '{$timezoneText}'\n\t\t\t";
     }
     return $localisation;
 }
Example #25
0
 function getCategoryFolder()
 {
     $params = J2Store::config();
     static $folder = null;
     if (empty($folder)) {
         $category = $params->get('attachmentfolderpath');
         if (empty($category)) {
             $folder = '';
         } else {
             $folder = $category;
             JLoader::import('joomla.filesystem.folder');
             if (!JFolder::exists($folder)) {
                 $folder = JPATH_ROOT . '/' . $folder;
                 if (!JFolder::exists($folder)) {
                     $folder = '';
                 }
             }
         }
         if (empty($folder)) {
             return $folder;
         }
         $subfolder = $this->getState('folder', '');
         if (!empty($subfolder)) {
             // Clean and check subfolder
             $subfolder = JPath::clean($subfolder);
             if (strpos($subfolder, '..') !== false) {
                 JError::raiseError(20, 'Use of relative paths not permitted');
                 // don't translate
                 jexit();
             }
             // Find the parent path to our subfolder
             $parent = JPath::clean(@realpath($folder . '/' . $subfolder . '/..'));
             $parent = trim(str_replace(JPath::clean($folder), '', $parent), '/\\');
             $folder = JPath::clean($folder . '/' . $subfolder);
             // Calculate the full path to the subfolder
             $this->setState('parent', $parent);
             $this->setState('folder', $subfolder);
         } else {
             $this->setState('parent', null);
             $this->setState('folder', '');
         }
     }
     return $folder;
 }
Example #26
0
 public function getProductImages($event, $option, $item, $params)
 {
     $return = '';
     $image_location = $this->params->get('item_image_placement', 'default');
     $show_image = $this->params->get('item_display_j2store_images', 1);
     if ($image_location != $event || !$show_image || (!isset($item->id) || $item->id < 1)) {
         return $return;
     }
     if (strpos($option, 'com_content.article') !== false) {
         $image_type = $this->params->get('item_image_type', 'thumbnail');
         $j2params = J2Store::config();
         $placement = $j2params->get('addtocart_placement', 'default');
         if ($placement == 'default' || $placement == 'both') {
             $product = F0FTable::getAnInstance('Product', 'J2StoreTable')->getClone();
             if ($product->get_product_by_source('com_content', $item->id)) {
                 $images = $product->get_product_images_html($image_type, $this->params);
                 if ($images !== false) {
                     $return = $images;
                 }
             }
         }
     }
     return $return;
 }
Example #27
0
 function getContinueShoppingUrl()
 {
     $params = J2Store::config();
     $type = $params->get('config_continue_shopping_page', 'previous');
     $item = new JObject();
     $item->type = $type;
     switch ($type) {
         case 'previous':
         default:
             $item->url = '';
             break;
         case 'menu':
             $url = '';
             //get the menu item id
             $menu_itemid = $params->get('continue_shopping_page_menu', '');
             if (empty($menu_itemid)) {
                 $item->url = '';
                 $item->type = 'previous';
             } else {
                 $application = JFactory::getApplication();
                 $menu = $application->getMenu('site');
                 $menu_item = $menu->getItem($menu_itemid);
                 if (is_object($menu_item)) {
                     // we have the menu item. See if language associations are there
                     JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
                     try {
                         $associations = MenusHelper::getAssociations($menu_item->id);
                     } catch (Exception $e) {
                         $associations = array();
                     }
                     //get the current language code
                     $tag = JFactory::getLanguage()->getTag();
                     if (isset($associations[$tag])) {
                         $cmenu = $menu->getItem($associations[$tag]);
                     } else {
                         $cmenu = $menu_item;
                     }
                     $link = JRoute::_($cmenu->link . '&Itemid=' . $cmenu->id, false);
                     if (JURI::isInternal($link)) {
                         $url = $link;
                     }
                 }
                 if (empty($url)) {
                     $item->url = '';
                     $item->type = 'previous';
                 } else {
                     $item->url = $url;
                 }
             }
             break;
         case 'url':
             $custom_url = $params->get('config_continue_shopping_page_url', '');
             if (empty($custom_url)) {
                 $item->url = '';
                 $item->type = 'previous';
             } else {
                 $item->url = $custom_url;
             }
             break;
     }
     //allow plugins to alter the checkout link.
     //This allows 3rd-party developers to create different checkout steps for j2store
     //Example. The plugin can return a completely different link
     J2Store::plugin()->event('GetContinueShoppingUrl', array(&$item));
     return $item;
 }
Example #28
0
 /**
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _prePayment($data)
 {
     // get component params
     $params = J2Store::config();
     $currency = J2Store::currency();
     // prepare the payment form
     $vars = new JObject();
     $vars->order_id = $data['order_id'];
     $vars->orderpayment_id = $data['orderpayment_id'];
     F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
     $order = F0FTable::getInstance('Order', 'J2StoreTable')->getClone();
     $order->load(array('order_id' => $data['order_id']));
     $currency_values = $this->getCurrency($order);
     $vars->currency_code = $currency_values['currency_code'];
     $vars->orderpayment_amount = $currency->format($order->order_total, $currency_values['currency_code'], $currency_values['currency_value'], false);
     $vars->orderpayment_type = $this->_element;
     $vars->cart_session_id = JFactory::getSession()->getId();
     $vars->display_name = $this->params->get('display_name', 'PAYMENT_PAYPAL');
     $vars->onbeforepayment_text = $this->params->get('onbeforepayment', '');
     $vars->button_text = $this->params->get('button_text', 'J2STORE_PLACE_ORDER');
     $items = $order->getItems();
     $products = array();
     foreach ($items as $item) {
         $desc = $item->orderitem_name;
         //product options
         $options = array();
         if (isset($item->orderitemattributes) && count($item->orderitemattributes)) {
             foreach ($item->orderitemattributes as $attribute) {
                 $options[] = array('name' => JText::_($attribute->orderitemattribute_name), 'value' => $attribute->orderitemattribute_value);
             }
         }
         $desc = str_replace("'", '', $desc);
         $products[] = array('name' => html_entity_decode($desc, ENT_QUOTES, 'UTF-8'), 'options' => $options, 'number' => !empty($item->orderitem_sku) ? $item->orderitem_sku : $item->product_id, 'quantity' => intval($item->orderitem_quantity), 'price' => $currency->format($item->orderitem_finalprice_with_tax / $item->orderitem_quantity, $currency_values['currency_code'], $currency_values['currency_value'], false));
         $item->_description = $desc;
     }
     $handling_cost = $order->order_shipping + $order->order_shipping_tax + $order->order_surcharge;
     $handling_cart = $currency->format($handling_cost, $currency_values['currency_code'], $currency_values['currency_value'], false);
     if ($handling_cart > 0) {
         $products[] = array('name' => JText::_('J2STORE_SHIPPING_AND_HANDLING'), 'options' => array(), 'number' => '', 'quantity' => 1, 'price' => $handling_cart);
     }
     $vars->products = $products;
     //$vars->tax_cart = $currency->format($order->order_tax, $currency_values['currency_code'], $currency_values['currency_value'], false);
     $vars->discount_amount_cart = $currency->format($order->order_discount, $currency_values['currency_code'], $currency_values['currency_value'], false);
     $vars->order = $order;
     $vars->orderitems = $items;
     // set payment plugin variables
     // set payment plugin variables
     if ($this->params->get('sandbox', 0)) {
         $vars->merchant_email = trim($this->_getParam('sandbox_merchant_email'));
     } else {
         $vars->merchant_email = trim($this->_getParam('merchant_email'));
     }
     $rootURL = rtrim(JURI::base(), '/');
     $subpathURL = JURI::base(true);
     if (!empty($subpathURL) && $subpathURL != '/') {
         $rootURL = substr($rootURL, 0, -1 * strlen($subpathURL));
     }
     $vars->post_url = $this->_getPostUrl();
     $vars->return_url = $rootURL . JRoute::_("index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=display");
     $vars->cancel_url = $rootURL . JRoute::_("index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=cancel");
     $vars->notify_url = JURI::root() . "index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=process&tmpl=component";
     //$vars->currency_code = $this->_getParam( 'currency', 'USD' );
     $orderinfo = $order->getOrderInformation();
     // set variables for user info
     $vars->first_name = $orderinfo->billing_first_name;
     $vars->last_name = $orderinfo->billing_last_name;
     $vars->email = $order->user_email;
     $vars->address_1 = $orderinfo->billing_address_1;
     $vars->address_2 = $orderinfo->billing_address_2;
     $vars->city = $orderinfo->billing_city;
     $vars->country = $this->getCountryById($orderinfo->billing_country_id)->country_name;
     $vars->region = $this->getZoneById($orderinfo->billing_zone_id)->zone_name;
     $vars->postal_code = $orderinfo->billing_zip;
     $vars->invoice = $order->getInvoiceNumber();
     $html = $this->_getLayout('prepayment', $vars);
     return $html;
 }
Example #29
0
        ?>
	                </div>
	            </div>
	            <?php 
    }
    ?>
	            <?php 
    echo JHtml::_('bootstrap.endTab');
    $tab_count++;
}
?>
 </form>
</div>

<?php 
$zone_id = J2Store::config()->get('zone_id', 0);
?>
<script type="text/javascript">
	jQuery("#continue_shopping_page").on('change',function(){
		if(this.value == 'previous'){
			jQuery("#continue_shopping_url").closest('.control-group').hide();
			jQuery("#continue_shopping_menu").closest('.control-group').hide();
		}

		if(this.value =='menu'){
			jQuery("#continue_shopping_menu").closest('.control-group').show();
			jQuery("#continue_shopping_url").closest('.control-group').hide();
		}

		if(this.value == 'url'){
			jQuery("#continue_shopping_url").closest('.control-group').show();
Example #30
0
 public function getTotalCouponDiscount($coupon_info, $items)
 {
     $app = JFactory::getApplication();
     $params = J2Store::config();
     $session = JFactory::getSession();
     $cart_helper = J2Store::cart();
     $discount_total = 0;
     if ($session->has('coupon', 'j2store')) {
         $var = 'orderitem_finalprice_without_tax';
         if (!$params->get('config_discount_before_tax', 1)) {
             //discount applied after tax
             $var = 'orderitem_finalprice_without_tax';
         }
         if (!$coupon_info->product) {
             $sub_total = 0;
             foreach ($items as $item) {
                 $sub_total += $item->{$var};
             }
         } else {
             $sub_total = 0;
             foreach ($items as $item) {
                 if (in_array($item->product_id, $coupon_info->product)) {
                     $sub_total += $item->{$var};
                 }
             }
         }
         if ($coupon_info->value_type == 'F') {
             $coupon_info->value = min($coupon_info->value, $sub_total);
         }
         $product_array2 = array();
         foreach ($items as $item) {
             $discount = 0;
             if (!$coupon_info->product) {
                 $status = true;
             } else {
                 if (in_array($item->product_id, $coupon_info->product)) {
                     $status = true;
                 } else {
                     $status = false;
                 }
             }
             if ($status) {
                 if ($coupon_info->value_type == 'F') {
                     $discount = $coupon_info->value * ($item->{$var} / $sub_total);
                 } elseif ($coupon_info->value_type == 'P') {
                     $discount = $item->{$var} / 100 * $coupon_info->value;
                 }
             }
             $discount_total += $discount;
         }
         if ($coupon_info->free_shipping && $session->has('shipping_values', 'j2store')) {
             $shipping = $session->get('shipping_values', array(), 'j2store');
             $shipping_cost = $shipping['shipping_price'] + $shipping['shipping_extra'] + $shipping['shipping_tax'];
             $discount_total += $shipping_cost;
         }
     }
     return $discount_total;
 }