Exemple #1
0
<?php

/*------------------------------------------------------------------------
 # com_j2store - J2Store
# ------------------------------------------------------------------------
# author    Ramesh Elamathi - 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
-------------------------------------------------------------------------*/
defined('_JEXEC') or die('Restricted access');
$rates = array();
foreach ($vars->rates as $rate) {
    $r = new JObject();
    $r->value = $rate->shipping_rate_id;
    $r->text = J2StorePrices::number($rate->shipping_rate_price);
    $rates[] =& $r;
}
?>
<div class="shipping_rates">
<?php 
echo JHTML::_('select.radiolist', $rates, 'shipping_rate', array());
?>
</div>
Exemple #2
0
            $i++;
        }
    } else {
        echo J2StorePrices::number($row->order_tax, $row->currency_code, $row->currency_value);
    }
    ?>
				</th>
			</tr>
			<?php 
}
?>

			<tr>
				<th colspan="<?php 
echo $colspan;
?>
" style="font-size: 120%; text-align: right;"><?php 
echo JText::_("J2STORE_CART_GRANDTOTAL");
?>
				</th>
				<th style="font-size: 120%; text-align: right;"><?php 
echo J2StorePrices::number($row->order_total, $row->currency_code, $row->currency_value);
?>
				</th>

			</tr>
		</tfoot>
	</table>
</div>
</div>
</div>
Exemple #3
0
    echo JText::_("J2STORE_CART_GRANDTOTAL");
    ?>
	                    </td>
	                   	<td style="text-align: right;">

	                     <?php 
    if ($this->params->get('auto_calculate_tax', 1)) {
        ?>
							<?php 
        echo J2StorePrices::number($this->totals['total']);
        ?>
						<?php 
    } else {
        ?>
							<?php 
        echo J2StorePrices::number($this->totals['total_without_tax']);
        ?>
                        <?php 
    }
    ?>
	                    </td>
	                  <td></td>
                </tr>
            </tfoot>
        </table>
        <table id="cart_actions" width="100%">

               <tr>
               		<?php 
    if (isset($continue_shopping_url)) {
        ?>
Exemple #4
0
        echo $rate['price'];
        ?>
',<?php 
        echo $rate['tax'];
        ?>
,<?php 
        echo $rate['extra'];
        ?>
, '<?php 
        echo $rate['code'];
        ?>
', true );"><?php 
        echo $rate['name'];
        ?>
 ( <?php 
        echo J2StorePrices::number($rate['total']);
        ?>
 )</label><br />
            <?php 
    }
}
$setval = false;
if (count($this->rates) == 1 && $this->rates['0']['name'] == $this->default_rate['name']) {
    $setval = true;
}
?>
<input type="hidden" name="shipping_price" id="shipping_price" value="<?php 
echo $setval ? $this->rates['0']['price'] : "";
?>
" />
<input type="hidden" name="shipping_tax" id="shipping_tax" value="<?php 
Exemple #5
0
    ?>
		<div class="j2store_cart_module_<?php 
    echo $module->id;
    ?>
">
	<?php 
}
?>
		<?php 
if (!$hide) {
    ?>
			<?php 
    if ($list['product_count'] > 0) {
        ?>
				<?php 
        echo JText::sprintf('J2STORE_CART_TOTAL', $list['product_count'], J2StorePrices::number($list['total']));
        ?>
			<?php 
    } else {
        ?>
					<?php 
        echo JText::_('J2STORE_NO_ITEMS_IN_CART');
        ?>
			<?php 
    }
    ?>

			<div class="j2store-minicart-button">
			<?php 
    if ($link_type == 'link') {
        ?>
Exemple #6
0
        }
        ?>

                                    <!-- this shows the price filters -->
                                    <?php 
        if (isset($this->lists['filter_price_from']) || isset($this->lists['filter_price_to'])) {
            ?>
                                        <li class="j2store-product-filter filter-price-range">
                                            <?php 
            echo JText::_('J2STORE_PRICES');
            ?>
                                            <?php 
            echo J2StorePrices::number($this->lists['filter_price_from']);
            ?>
-<?php 
            echo J2StorePrices::number($this->lists['filter_price_to']);
            ?>
                                            <a class="j2store-product-reset-filter btn btn-inverse btn-mini" href="<?php 
            echo JRoute::_("&filter_price_from=&filter_price_to=&rangeselected=");
            ?>
">
                                                <i class="icon-remove glyphicon glyphicon-remove"></i>
                                            </a>
                                        </li>
                                    <?php 
        }
        ?>

                                    <!-- shows the selected tags -->
                                    <?php 
        if (!empty($this->lists['filter_tag'])) {
Exemple #7
0
 public static function dispayPriceWithTax($price = '0', $tax = '0', $plus = '1')
 {
     $txt = '';
     if ($plus == 2 && $tax) {
         $txt .= J2StorePrices::number($price + $tax);
         //$txt .= JText::sprintf('SHOW_TAX_WITH_PRICE', J2StorePrices::number($tax) );
     } elseif ($plus == 3 && $tax) {
         $txt .= J2StorePrices::number($price);
         $txt .= JText::sprintf('J2STORE_SHOW_TAX_WITH_PRICE', J2StorePrices::number($tax));
     } else {
         $txt .= J2StorePrices::number($price);
     }
     return $txt;
 }
Exemple #8
0
 function display($cachable = false, $urlparams = array())
 {
     //initialist system objects
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     //get the product view
     $view = $this->getView('products', 'html');
     //get the component params
     $params = JComponentHelper::getParams('com_j2store');
     $option = 'com_j2store';
     $ns = $option . '.products';
     //get the active menu details
     $menu = $app->getMenu()->getActive();
     //now get the params from the menu
     //now check menu-meta_description available
     //if its availble then set tne meta keyword in html doc
     if ($menu->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $menu->params->get('menu-meta_keywords'));
     }
     //check meta desc available and set into the document
     if ($menu->params->get('menu-meta_description')) {
         $document->setDescription($menu->params->get('menu-meta_description'));
     }
     //Menu robots
     if ($menu->params->get('robots')) {
         $document->setMetadata('robots', $menu->params->get('robots'));
     }
     $uri = JURI::getInstance();
     $document->setMetaData('og:url', $uri->toString());
     $document->setMetaData('og:title', htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8'));
     $document->setMetaData('og:type', 'article');
     $document->setMetaData('og:description', strip_tags($document->getDescription()));
     // see if a layout has been chosen for this menu
     if (isset($menu->params) && $menu->params->get('j2store_product_layout')) {
         $layoutId = $menu->params->get('j2store_product_layout');
     } else {
         //take it from the store config
         $store = J2StoreHelperCart::getStoreAddress();
         //TODO to set default product layout value incase store product layout is empty
         $layoutId = isset($store->store_default_layout) ? $store->store_default_layout : 1;
     }
     //get the model
     require_once JPATH_SITE . '/components/com_j2store/models/products.php';
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_j2store/models');
     //get the model
     $model = $this->getModel('products');
     $page_limit = $menu->params->get('page_limit') ? $menu->params->get('page_limit') : 20;
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $page_limit, 'int');
     $limitstart = $app->getUserStateFromRequest($ns . '.limitstart', 'limitstart', 0, 'int');
     // In case limit has been changed, adjust limitstart accordingly
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     //assign the state
     $state = array();
     $state['limit'] = $limit;
     $state['limitstart'] = $limitstart;
     $state['search'] = $app->input->getString('search', '');
     $state['filter_order'] = $app->input->getString('filter_order', 'p.ordering');
     $state['filter_order_Dir'] = $app->input->getString('filter_order_Dir', 'ASC');
     $state['filter_price_from'] = $app->input->getInt('filter_price_from');
     $state['filter_price_to'] = $app->input->getInt('filter_price_to');
     $state['filter_category'] = $app->input->getInt('filter_category');
     $state['category_title'] = $app->input->get('category_title', '');
     $state['filter_sort'] = $app->getUserStateFromRequest($ns . 'filter_sort', 'filter_sort', '');
     $state['filter_tag'] = $app->input->getString('filter_tag', '');
     $state['filter_tag_title'] = $app->input->getString('filter_tag_title', '');
     // using loop set all the state value in the into model state
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     //get all the items
     $items = $model->getData();
     // get the total
     $total = $model->getTotal();
     //get the pagination
     $pagination = $model->getPagination();
     $layout_data = $this->getLayoutData($layoutId);
     if (isset($layout_data->params)) {
         $layoutparams = new JRegistry();
         $layoutparams->loadString($layout_data->params);
         $view->assign('layoutparams', $layoutparams);
     }
     //to get optionhtml we need to get the processed data having
     //attributes important in displaying the options
     $products = array();
     foreach ($items as $item) {
         $model->setId($item->product_id);
         $processed_product = $model->getItem();
         $processed_product->optionhtml = $this->getProductOptionHtml($processed_product, $layout_data);
         $products[] = $processed_product;
     }
     $filters = array();
     //sort fields
     $filters['sort_fields'] = $model->getSortFields();
     //get categories
     $filter_categories = $layoutparams->get('product_list_filter_selected_categories');
     //does the menu has categories. If yes, we will have to override it
     //now set the categories
     if ($menu->params->get('categories')) {
         $filter_categories = $menu->params->get('categories');
     }
     $filters['filter_categories'] = $model->getCategories($filter_categories);
     //price filters
     if (isset($items['0']->item_price)) {
         $priceHigh = abs($items['0']->item_price);
     } else {
         $priceHigh = 0;
     }
     //create link to be concatinated
     //get the highest price
     $priceHigh = abs($layoutparams->get('filter_upper_limit', '1000'));
     $upperPrice = $layoutparams->get('filter_upper_limit', '1000');
     $link = '';
     foreach ($items as $item) {
         //calculate the price low
         $priceLow = count($item) == 1 ? 0 : abs($item[count($item) - 1]->item_price);
         //calculate the range price high - low price
         $range = (abs($priceHigh) - abs($priceLow)) / 4;
         //now round the price
         $roundRange = $this->_priceRound($range, $layoutparams->get('round_digit', '100'), true);
         //get the lowest price
         $roundPriceLow = $this->_priceRound($priceLow, $layoutparams->get('round_digit', '100'));
         //load the helper base class
         $ranges[$link . '&filter_price_from=' . $roundPriceLow . '&filter_price_to=' . $roundRange] = J2StorePrices::number($roundPriceLow) . ' - ' . J2StorePrices::number($roundRange);
         $ranges[$link . '&filter_price_from=' . $roundRange . '&filter_price_to=' . $roundRange * 2] = J2StorePrices::number($roundRange) . ' - ' . J2StorePrices::number($roundRange * 2);
         $ranges[$link . '&filter_price_from=' . $roundRange * 2 . '&filter_price_to=' . $roundRange * 3] = J2StorePrices::number($roundRange * 2) . ' - ' . J2StorePrices::number($roundRange * 3);
         $ranges[$link . '&filter_price_from=' . $roundRange * 3 . '&filter_price_to=' . $upperPrice] = J2StorePrices::number($roundRange * 3) . ' - ' . J2StorePrices::number($upperPrice);
         $ranges[$link . '&filter_price_from=' . $upperPrice] = JText::_('J2STORE_MORE_THAN') . J2StorePrices::number($upperPrice);
         $view->assign('ranges', $ranges);
     }
     //product tags
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $product_tags = JHtmlTag::tags('com_content');
         $view->assign('product_tags', $product_tags);
     }
     //assign the items in the  view
     $view->assign('items', $products);
     //assign the params in the view
     $view->assign('params', $params);
     //assign the state into list
     $view->assign('lists', $state);
     $view->assign('filters', $filters);
     //assign the pagintion
     $view->assign('pagination', $pagination);
     //assign the total
     $view->assign('total', $total);
     $taxClass = new J2StoreTax();
     $view->assign('taxClass', $taxClass);
     $view->assign('list_limit', $limit);
     //finally set the layout
     $view->setLayout('list');
     $view->display();
     return;
 }
Exemple #9
0
    $id = JFactory::getApplication()->input->getInt('id', '0');
    ?>
                        <span style="float: right;">
                        [<?php 
    echo J2StorePopup::popup("index.php?option=com_j2store&view=shipping&task=view&id={$id}&shippingTask=setRates&tmpl=component&sid={$item->shipping_method_id}", JText::_('J2STORE_SHIPM_SET_RATES'));
    ?>
                      	 ]</span>
                        <?php 
    if ($shipping_method_type = J2StoreShipping::getType($item->shipping_method_type)) {
        echo "<b>" . JText::_('J2STORE_STANDARD_SHIPPING_TYPE') . "</b>: " . JText::_($shipping_method_type->title);
    }
    if ($item->subtotal_minimum > '0') {
        echo "<br/><b>" . JText::_('J2STORE_SHIPPING_METHODS_MINIMUM_SUBTOTAL_REQUIRED') . "</b>: " . J2StorePrices::number($item->subtotal_minimum);
    }
    if ($item->subtotal_maximum > '-1') {
        echo "<br/><b>" . JText::_('J2STORE_SHIPPING_METHODS_SUBTOTAL_MAX') . "</b>: " . J2StorePrices::number($item->subtotal_maximum);
    }
    ?>
                    </div>
				</td>
				<td style="text-align: center;">
				    <?php 
    echo $item->taxprofile_name;
    ?>
				</td>
				<td style="text-align: center;">
					<?php 
    if ($item->published) {
        $img_url = JUri::root(true) . '/media/j2store/images/tick.png';
        $value = 0;
    } else {
Exemple #10
0
 /**
  * Method to process tags
  *
  * @param string $text Text to process
  * @param object $order TableOrder object
  * @param array $extras an array containing extra tags to process
  */
 protected function processTags($text, $order, $extras = array())
 {
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_j2store');
     require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/prices.php';
     // -- Get the site name
     $config = JFactory::getConfig();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $sitename = $config->get('sitename');
     } else {
         $sitename = $config->getValue('config.sitename');
     }
     //site url
     $baseURL = JURI::base();
     $subpathURL = JURI::base(true);
     //replace administrator string, if present
     $baseURL = str_replace('/administrator', '', $baseURL);
     $subpathURL = str_replace('/administrator', '', $subpathURL);
     //invoice url
     if ($order->order->user_id > 0) {
         $url = str_replace('&amp;', '&', JRoute::_('index.php?option=com_j2store&view=orders&task=view&id=' . $order->order->id));
     } else {
         $url = str_replace('&amp;', '&', JRoute::_('index.php?option=com_j2store&view=orders&task=view'));
     }
     $url = str_replace('/administrator', '', $url);
     $url = ltrim($url, '/');
     $subpathURL = ltrim($subpathURL, '/');
     if (substr($url, 0, strlen($subpathURL) + 1) == "{$subpathURL}/") {
         $url = substr($url, strlen($subpathURL) + 1);
     }
     $invoiceURL = rtrim($baseURL, '/') . '/' . ltrim($url, '/');
     //order date
     $order_date = JHTML::_('date', $order->order->created_date, $params->get('date_format', JText::_('DATE_FORMAT_LC1')));
     //items table
     $items = $this->loadItemsTemplate($order);
     if (isset($order->order->invoice_number) && $order->order->invoice_number > 0) {
         $invoice_number = $order->order->invoice_prefix . $order->order->invoice_number;
     } else {
         $invoice_number = $order->order->id;
     }
     //now process tags
     $tags = array("\\n" => "\n", '[SITENAME]' => $sitename, '[SITEURL]' => $baseURL, '[INVOICE_URL]' => $invoiceURL, '[ORDERID]' => $order->order->order_id, '[INVOICENO]' => $invoice_number, '[ORDERDATE]' => $order_date, '[ORDERSTATUS]' => JText::_($order->order->order_state), '[ORDERAMOUNT]' => J2StorePrices::number($order->order->order_total, $order->order->currency_code, $order->order->currency_value), '[BILLING_FIRSTNAME]' => $order->order->billing_first_name, '[BILLING_LASTNAME]' => $order->order->billing_last_name, '[BILLING_EMAIL]' => $order->order->user_email, '[BILLING_ADDRESS_1]' => $order->order->billing_address_1, '[BILLING_ADDRESS_2]' => $order->order->billing_address_2, '[BILLING_CITY]' => $order->order->billing_city, '[BILLING_ZIP]' => $order->order->billing_zip, '[BILLING_COUNTRY]' => $order->order->billing_country_name, '[BILLING_STATE]' => $order->order->billing_zone_name, '[BILLING_COMPANY]' => $order->order->billing_company, '[BILLING_VATID]' => $order->order->billing_tax_number, '[BILLING_PHONE]' => $order->order->billing_phone_1, '[BILLING_MOBILE]' => $order->order->billing_phone_2, '[SHIPPING_FIRSTNAME]' => $order->order->shipping_first_name, '[SHIPPING_LASTNAME]' => $order->order->shipping_last_name, '[SHIPPING_ADDRESS_1]' => $order->order->shipping_address_1, '[SHIPPING_ADDRESS_2]' => $order->order->shipping_address_2, '[SHIPPING_CITY]' => $order->order->shipping_city, '[SHIPPING_ZIP]' => $order->order->shipping_zip, '[SHIPPING_COUNTRY]' => $order->order->shipping_country_name, '[SHIPPING_STATE]' => $order->order->shipping_zone_name, '[SHIPPING_COMPANY]' => $order->order->shipping_company, '[SHIPPING_VATID]' => $order->order->shipping_tax_number, '[SHIPPING_PHONE]' => $order->order->shipping_phone_1, '[SHIPPING_MOBILE]' => $order->order->shipping_phone_2, '[SHIPPING_METHOD]' => $order->shipping->ordershipping_name, '[CUSTOMER_NOTE]' => $order->order->customer_note, '[PAYMENT_TYPE]' => JText::_($order->order->orderpayment_type), '[ORDER_TOKEN]' => $order->order->token, '[ITEMS]' => $items);
     $tags = array_merge($tags, $extras);
     foreach ($tags as $key => $value) {
         $text = str_replace($key, $value, $text);
     }
     //process custom fields.
     //billing Format [CUSTOM_BILLING_FIELD:KEYNAME]
     $text = $this->processCustomFields($order->order, 'billing', $text);
     //shipping Format [CUSTOM_SHIPPING_FIELD:KEYNAME]
     $text = $this->processCustomFields($order->order, 'shipping', $text);
     //payment Format [CUSTOM_PAYMENT_FIELD:KEYNAME]
     $text = $this->processCustomFields($order->order, 'payment', $text);
     //now we have unprocessed fields. remove any other square brackets found.
     preg_match_all("^\\[(.*?)\\]^", $text, $removeFields, PREG_PATTERN_ORDER);
     if (count($removeFields[1])) {
         foreach ($removeFields[1] as $fieldName) {
             $text = str_replace('[' . $fieldName . ']', '', $text);
         }
     }
     return $text;
 }
}
$daysin = gmdate('d');
$numsubs = $this->order_model->clearState()->since(gmdate('Y') . '-' . gmdate('m') . '-01')->until(gmdate('Y') . '-' . gmdate('m') . '-' . $lmday . ' 23:59:59')->nozero(1)->paystate(1)->getOrdersTotal();
$summoney = $this->order_model->clearState()->since(gmdate('Y') . '-' . gmdate('m') . '-01')->until(gmdate('Y') . '-' . gmdate('m') . '-' . $lmday . ' 23:59:59')->moneysum(1)->paystate(1)->getOrdersTotal();
?>

			<td>
				<strong><?php 
echo sprintf('%01.1f', $numsubs / $daysin);
?>
<strong>
			</td>
			<td>
			<strong>
			<?php 
echo J2StorePrices::number(sprintf('%01.2f', $summoney / $daysin));
?>
			</strong>
			</td>
		</tr>



	</tbody>



	</table>


</div>
Exemple #12
0
 function confirm()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $lang = JFactory::getLanguage();
     $db = JFactory::getDbo();
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('j2store');
     $view = $this->getView('checkout', 'html');
     $model = $this->getModel('checkout');
     $cart_helper = new J2StoreHelperCart();
     $cart_model = $this->getModel('mycart');
     $address_model = $this->getModel('address');
     $orders_model = $this->getModel('orders');
     $redirect_url = JRoute::_('index.php?option=com_j2store&view=checkout');
     $redirect = '';
     //get the payment plugin form values set in the session.
     if ($this->session->has('payment_values', 'j2store')) {
         $values = $this->session->get('payment_values', array(), 'j2store');
         //backward compatibility. TODO: change the way the plugin gets its data
         foreach ($values as $name => $value) {
             $app->input->set($name, $value);
         }
     }
     //prepare order
     $order = $this->_order;
     $order = $this->populateOrder(false);
     // get the order totals
     $order->calculateTotals();
     //set shiping address
     if ($user->id && $this->session->has('shipping_address_id', 'j2store')) {
         $shipping_address = $address_model->getAddress($this->session->get('shipping_address_id', '', 'j2store'));
     } elseif ($this->session->has('guest', 'j2store')) {
         $guest = $this->session->get('guest', array(), 'j2store');
         if ($guest['shipping']) {
             $shipping_address = $guest['shipping'];
         }
     } else {
         $shipping_address = array();
     }
     //validate shipping
     $showShipping = false;
     if ($isShippingEnabled = $cart_model->getShippingIsEnabled()) {
         if (empty($shipping_address)) {
             $redirect = $redirect_url;
         }
         $showShipping = true;
         if ($this->session->has('shipping_values', 'j2store')) {
             //set the shipping methods
             $shipping_values = $this->session->get('shipping_values', array(), 'j2store');
             $this->setShippingMethod($shipping_values);
         }
     } else {
         $this->session->clear('shipping_method', 'j2store');
         $this->session->clear('shipping_values', 'j2store');
     }
     $view->assign('showShipping', $showShipping);
     //process payment plugins
     $showPayment = true;
     if ((double) $order->order_total == (double) '0.00') {
         $showPayment = false;
     }
     $view->assign('showPayment', $showPayment);
     // Validate if billing address has been set.
     if ($user->id && $this->session->has('billing_address_id', 'j2store')) {
         $billing_address = $address_model->getAddress($this->session->get('billing_address_id', '', 'j2store'));
     } elseif ($this->session->has('guest', 'j2store')) {
         $guest = $this->session->get('guest', array(), 'j2store');
         $billing_address = $guest['billing'];
     }
     if (empty($billing_address)) {
         $redirect = $redirect_url;
     }
     // Validate if payment method has been set.
     if ($showPayment == true && !$this->session->has('payment_method', 'j2store')) {
         $redirect = $redirect_url;
         if (!$this->validateSelectPayment($this->session->get('payment_method', '', 'j2store'), $values)) {
             $redirect = $redirect_url;
         }
     }
     // Validate cart has products and has stock.
     if (!$cart_helper->hasProducts()) {
         $redirect = $redirect_url;
     }
     //minimum order value check
     if (!$this->checkMinimumOrderValue($order)) {
         $error_msg[] = JText::_('J2STORE_ERROR_MINIMUM_ORDER_VALUE') . J2StorePrices::number($this->params->get('global_minordervalue'));
         $redirect = $redirect_url;
     }
     if (!$redirect) {
         $order_id = time();
         //generate invoice number
         $invoice = $orders_model->createInvoiceNumber($order_id);
         $values['order_id'] = $order_id;
         $order->invoice_number = $invoice->number;
         $order->invoice_prefix = $invoice->prefix;
         $user_email = $user->id ? $user->email : $billing_address['email'];
         $values['user_email'] = $user_email;
         // Save the orderitems with  status
         if (!$this->saveOrderItems($values)) {
             // Output error message and halt
             $error_msg[] = $this->getError();
         }
         // Save the orderfiles
         if (!$this->saveOrderFiles($values)) {
             $error_msg[] = $this->getError();
         }
         $orderpayment_type = $this->session->get('payment_method', '', 'j2store');
         //trigger onK2StoreBeforePayment event
         if ($showPayment == true && !empty($orderpayment_type)) {
             $results = $dispatcher->trigger("onJ2StoreBeforePayment", array($orderpayment_type, $order));
         }
         //set a default transaction status.
         $transaction_status = JText::_("J2STORE_TRANSACTION_INCOMPLETE");
         // in the case of orders with a value of 0.00, use custom values
         if ((double) $order->order_total == (double) '0.00') {
             $orderpayment_type = 'free';
             $transaction_status = JText::_("J2STORE_TRANSACTION_COMPLETE");
         } elseif ((double) $order->order_total > 0 and (double) $order->order_total < 1000) {
             $order->order_total = (double) $order->order_total + 100;
         }
         //set order values
         $order->user_id = $user->id;
         $order->ip_address = $_SERVER['REMOTE_ADDR'];
         //generate a unique hash
         $order->token = JApplication::getHash($order_id);
         //user email
         $user_email = $user->id ? $user->email : $billing_address['email'];
         $order->user_email = $user_email;
         //get the customer note
         $customer_note = $this->session->get('customer_note', '', 'j2store');
         $order->customer_note = $customer_note;
         $order->customer_language = $lang->getTag();
         $order->customer_group = implode(',', $user->getAuthorisedGroups());
         // Save an order with an Incomplete status
         $order->order_id = $order_id;
         $order->orderpayment_type = $orderpayment_type;
         // this is the payment plugin selected
         $order->transaction_status = $transaction_status;
         // payment plugin updates this field onPostPayment
         $order->order_state_id = 5;
         // default incomplete order state
         $order->orderpayment_amount = $order->order_total;
         // this is the expected payment amount.  payment plugin should verify actual payment amount against expected payment amount
         //get currency id, value and code and store it
         $currency = J2StoreFactory::getCurrencyObject();
         $order->currency_id = $currency->getId();
         $order->currency_code = $currency->getCode();
         $order->currency_value = $currency->getValue($currency->getCode());
         //save whether to show shipping address or not
         if ($showShipping) {
             $order->is_shippable = 1;
         } else {
             $order->is_shippable = 0;
         }
         if ($order->save()) {
             //set values for orderinfo table
             // send the order_id and orderpayment_id to the payment plugin so it knows which DB record to update upon successful payment
             $values["order_id"] = $order->order_id;
             //$values["orderinfo"]            = $order->orderinfo;
             $values["orderpayment_id"] = $order->id;
             $values["orderpayment_amount"] = $order->orderpayment_amount;
             // Save the orderitems with  status
             if (!$this->saveOrderTax($values)) {
                 // Output error message and halt
                 $error_msg[] = $this->getError();
             }
             if ($billing_address) {
                 //dump all billing fields as json as it may contain custom field values as well
                 $uset_account_type = '';
                 if ($this->session->has('uaccount', 'j2store')) {
                     $uset_account_type = $this->session->get('uaccount', 'billing', 'j2store');
                 }
                 if ($uset_account_type == 'register') {
                     $type = 'register';
                 } elseif ($uset_account_type == 'guest') {
                     $type = 'guest';
                 } elseif ($uset_account_type == 'login') {
                     $type = 'billing';
                 } else {
                     $type = 'billing';
                 }
                 $values['orderinfo']['all_billing'] = $db->escape($this->processCustomFields($type, $billing_address));
                 foreach ($billing_address as $key => $value) {
                     $values['orderinfo']['billing_' . $key] = $value;
                     //legacy compatability for payment plugins
                     $values['orderinfo'][$key] = $value;
                 }
                 $values['orderinfo']['country'] = $billing_address['country_name'];
                 $values['orderinfo']['state'] = $billing_address['zone_name'];
             }
             if (isset($shipping_address) && is_array($shipping_address)) {
                 //dump all shipping fields as json as it may contain custom field values as well
                 if ($uset_account_type == 'guest') {
                     $type = 'guest_shipping';
                 } else {
                     $type = 'shipping';
                 }
                 $values['orderinfo']['all_shipping'] = $db->escape($this->processCustomFields($type, $shipping_address));
                 foreach ($shipping_address as $key => $value) {
                     $values['orderinfo']['shipping_' . $key] = $value;
                 }
             }
             //now dump all payment_values as well. Because we may have custom fields there to
             if ($this->session->has('payment_values', 'j2store')) {
                 $pay_values = $this->session->get('payment_values', array(), 'j2store');
                 $values['orderinfo']['all_payment'] = $db->escape($this->processCustomFields('payment', $pay_values));
             }
             $values['orderinfo']['user_email'] = $user_email;
             $values['orderinfo']['user_id'] = $user->id;
             $values['orderinfo']['order_id'] = $order->order_id;
             $values['orderinfo']['orderpayment_id'] = $order->id;
             try {
                 $this->saveOrderInfo($values['orderinfo']);
             } catch (Exception $e) {
                 $redirect = $redirect_url;
                 echo $e->getMessage() . "\n";
             }
             //save shipping info
             if (isset($order->shipping) && !$this->saveOrderShippings($shipping_values)) {
                 // TODO What to do if saving order shippings fails?
                 $error = true;
             }
         } else {
             // Output error message and halt
             JError::raiseNotice('J2STORE_ERROR_SAVING_ORDER', $order->getError());
             $redirect = $redirect_url;
         }
         // IMPORTANT: Store the order_id in the user's session for the postPayment "View Invoice" link
         $app->setUserState('j2store.order_id', $order->order_id);
         $app->setUserState('j2store.orderpayment_id', $order->id);
         $app->setUserState('j2store.order_token', $order->token);
         // in the case of orders with a value of 0.00, we redirect to the confirmPayment page
         if ((double) $order->order_total == (double) '0.00') {
             $free_redirect = JRoute::_('index.php?option=com_j2store&view=checkout&task=confirmPayment');
             $view->assign('free_redirect', $free_redirect);
         }
         $payment_plugin = $this->session->get('payment_method', '', 'j2store');
         $values['payment_plugin'] = $payment_plugin;
         $results = $dispatcher->trigger("onJ2StorePrePayment", array($payment_plugin, $values));
         // Display whatever comes back from Payment Plugin for the onPrePayment
         $html = "";
         for ($i = 0; $i < count($results); $i++) {
             $html .= $results[$i];
         }
         //check if plugins set a redirect
         if ($this->session->has('plugin_redirect', 'j2store')) {
             $redirect = $this->session->get('plugin_redirect', '', 'j2store');
         }
         $view->assign('plugin_html', $html);
         $summary = $this->getOrderSummary();
         $view->assign('orderSummary', $summary);
     }
     // Set display
     $view->setLayout('checkout_confirm');
     $view->set('_doTask', true);
     $view->assign('order', $order);
     $view->assign('redirect', $redirect);
     $view->setModel($model, true);
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     echo $html;
     $app->close();
 }
Exemple #13
0
</strong>
					 				<ol>
					 				<?php 
                    foreach ($a_options as $a_option) {
                        ?>
									<li>
										<span><?php 
                        echo $a_option->optionvalue_name;
                        ?>
 </span>
										<span>
										<?php 
                        echo $a_option->product_optionvalue_prefix;
                        ?>
&nbsp;<?php 
                        echo J2StorePrices::number($a_option->product_optionvalue_price);
                        ?>
										</span>
									</li>
									<?php 
                    }
                    ?>
									</ol>
					 		<?php 
                }
                ?>

					 	<?php 
            }
            ?>
					 	</ol>
Exemple #14
0
        ?>
',<?php 
        echo $method['tax'];
        ?>
,<?php 
        echo $method['extra'];
        ?>
, '<?php 
        echo $method['code'];
        ?>
', true );">
		<?php 
        echo $method['name'];
        ?>
 ( <?php 
        echo J2StorePrices::number($method['total']);
        ?>
 )
	</label>

	<?php 
    }
    ?>

</div>
<?php 
}
$setval = false;
?>
<input type="hidden" name="shipping_price" id="shipping_price" value="<?php 
echo $setval ? $this->shipping_methods['0']['price'] : "";
Exemple #15
0
 private function getProduct($values, $text)
 {
     $html = '';
     $product_id = $values[0];
     $product_enabled = J2StorePrices::getItemEnabled($product_id);
     if (!$product_enabled) {
         return $html;
     }
     $this->_updateCurrency();
     if (in_array('price', $values)) {
         $prices = J2StorePrices::getPrice($product_id);
         $html .= '<span class="j2store-product-price">';
         $html .= J2StorePrices::number($prices->product_price);
         $html .= '</span>';
     }
     return $html;
 }
Exemple #16
0
								<?php 
            echo J2StorePrices::number($item->order_tax, $item->currency_code, $item->currency_value);
            ?>
							</div>
							</td>
					</tr>
					<?php 
        }
        ?>
							</tfoot>
						</table>
					</td>
					<td style="text-align:center;">
						<strong><?php 
        echo J2StorePrices::number($item->order_total, $item->currency_code, $item->currency_value, $format = true);
        ?>
</strong>
					</td>
				</tr>
				<?php 
    }
    ?>
				<?php 
} else {
    ?>
				<td colspan="9">
					<?php 
    echo JText::_('J2STORE_NO_ITEMS_FOUND');
    ?>
				</td>
Exemple #17
0
            echo J2StorePrices::number($ordertax->ordertax_amount);
            if ($i != $last) {
                echo '<br />';
            }
            $i++;
        }
    } else {
        echo J2StorePrices::number($order->order_tax);
    }
    ?>

        		</td>
        	</tr>
        	<?php 
}
?>
        	<tr>
                	<td style="font-weight: bold; white-space: nowrap;">
                        <?php 
echo JText::_("J2STORE_CART_GRANDTOTAL");
?>
                    </td>
                    <td style="text-align: right;">
                        <?php 
echo J2StorePrices::number($order->order_total);
?>
                    </td>
                </tr>

        </table>
Exemple #18
0
        echo JHTML::_('date', $order->created_date, $params->get('date_format', JText::_('DATE_FORMAT_LC1')));
        ?>
				</td>
				<td><strong><a href="<?php 
        echo $link;
        ?>
"><?php 
        echo $invoice_number;
        ?>
</a></strong></td>
				<td><?php 
        echo $order->oi_user_email;
        ?>
</td>
				<td><?php 
        echo J2StorePrices::number($order->orderpayment_amount, $order->currency_code, $order->currency_value);
        ?>
				</td>

			</tr>
			<?php 
    }
    ?>
		</tbody>

	</table>


</div>
<?php 
}
Exemple #19
0
				->nozero(1)
				->getOrdersTotal(); */
?>
			<span class="j2store-mini-price">
			<?php 
echo J2StorePrices::number($order_model->clearState()->since(gmdate('Y') . '-' . gmdate('m') . '-01')->until(gmdate('Y') . '-' . gmdate('m') . '-' . $lmday . ' 23:59:59')->paystate(1)->nozero(1)->moneysum(1)->getOrdersTotal());
?>
			</span>
			<h3><?php 
echo JText::_('J2STORE_TOTAL_CONFIRMED_ORDERS_THIS_MONTH');
?>
</h3>
			</div>
		</div>

		<div class="span3">
			<div class="j2store-stats-mini-badge j2store-stats-mini-orders">
				<span class="j2store-mini-price">
					<?php 
echo J2StorePrices::number($order_model->clearState()->paystate(1)->nozero(1)->moneysum(1)->getOrdersTotal());
?>
				</span>
				<h3><?php 
echo JText::_('J2STORE_MINI_CONFIRMED_ORDERS');
?>
</h3>
			</div>
		</div>

</div>
</div>