Exemplo n.º 1
0
 protected function onAdd($tpl = null)
 {
     $app = JFactory::getApplication();
     JRequest::setVar('hidemainmenu', true);
     $model = $this->getModel();
     $this->item = $model->runMyBehaviorFlag(true)->getItem();
     $this->currency = J2Store::currency();
     $this->form_prefix = $this->input->getString('form_prefix', '');
     $this->product_source_view = $this->input->getString('product_source_view', 'article');
     $this->product_types = JHtml::_('select.genericlist', $model->getProductTypes(), $this->form_prefix . '[product_type]', array(), 'value', 'text', $this->item->product_type);
     if ($this->item->j2store_product_id) {
         //manufacturers
         $this->manufacturers = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[manufacturer_id]')->value($this->item->manufacturer_id)->setPlaceHolders(array('' => JText::_('J2STORE_SELECT_OPTION')))->hasOne('Manufacturers')->setRelations(array('fields' => array('key' => 'j2store_manufacturer_id', 'name' => array('company'))))->getHtml();
         //vendor
         $this->vendors = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[vendor_id]')->value($this->item->vendor_id)->setPlaceHolders(array('' => JText::_('J2STORE_SELECT_OPTION')))->hasOne('Vendors')->setRelations(array('fields' => array('key' => 'j2store_vendor_id', 'name' => array('first_name', 'last_name'))))->getHtml();
         //tax profiles
         $this->taxprofiles = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[taxprofile_id]')->value($this->item->taxprofile_id)->setPlaceHolders(array('' => JText::_('J2STORE_NOT_TAXABLE')))->hasOne('Taxprofiles')->setRelations(array('fields' => array('key' => 'j2store_taxprofile_id', 'name' => 'taxprofile_name')))->getHtml();
     }
     if ($this->item->j2store_product_id > 0) {
         $this->product_filters = F0FTable::getAnInstance('ProductFilter', 'J2StoreTable')->getFiltersByProduct($this->item->j2store_product_id);
     } else {
         $this->product_filters = array();
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * This method runs before the $data is saved to the $table. Return false to
  * stop saving.
  *
  * @param   array     &$data   The data to save
  * @param   F0FTable  &$table  The table to save the data to
  *
  * @return  boolean  Return false to prevent saving, true to allow it
  */
 protected function onBeforeSave(&$data, &$table)
 {
     if (!empty($data['currency_code'])) {
         $data['currency_numeric_code'] = J2Store::currency()->getCurrenciesNumericCode($data['currency_code']);
     }
     return true;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 /**
  * Create a price input field with dynamic data
  *
  * @param  string  $name
  * @param  string  $currency symbol
  * @param  string  $value
  * @param  array   $options
  * @param object   A table record
  * @return string
  */
 public static function price_with_data($prefix, $primary_key, $name, $value = null, $options = array(), $data)
 {
     $optionvalue = JArrayHelper::toString($options);
     $symbol = J2Store::currency()->getSymbol();
     // return price input
     $html = '';
     $html .= '<div class="input-prepend">';
     if (!empty($symbol)) {
         $html .= '<span class="add-on">' . $symbol . '</span>';
     }
     $html .= '<input type="text" name="' . $prefix . $name . '" value="' . $value . '"  ' . $optionvalue . '    />';
     $html .= '</div>';
     J2Store::plugin()->event('PriceInputWithData', array($prefix, $primary_key, $name, $value, $options, &$html, $data));
     return $html;
 }
Exemplo n.º 5
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->email = $app->input->getString('email_id');
     $this->item = F0FModel::getTmpInstance('Customers', 'J2StoreModel')->getAddressesByemail($this->email);
     $task = $app->input->getString('task');
     $this->currency = J2Store::currency();
     if ($task == 'viewOrder' && $this->email) {
         $this->addresses = F0FModel::getTmpInstance('Addresses', 'J2StoreModel')->email($this->email)->getList();
         $this->orders = F0FModel::getTmpInstance('Orders', 'J2StoreModel')->user_email($this->email)->getList();
     }
     JToolbarHelper::title(JTEXT::_('J2STORE_CUSTOMER_VIEW'));
     JToolbarHelper::cancel();
     return parent::display($tpl);
     //return true;
 }
Exemplo n.º 6
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();
 }
Exemplo n.º 7
0
 /**
  * Displays the view
  *
  * @param   string  $tpl  The template to use
  *
  * @return  boolean|null False if we can't render anything
  */
 protected function onDisplay($tpl = null)
 {
     $view = $this->input->getCmd('view', 'cpanel');
     if (in_array($view, array('cpanel', 'cpanels'))) {
         return;
     }
     // Load the model
     $model = $this->getModel();
     $app = JFactory::getApplication();
     $state = array();
     $state['search'] = $app->input->getString('search', $model->getState('search', ''));
     $state['since'] = $app->input->get('since', $model->getState('since', ''));
     $state['until'] = $app->input->get('until', $model->getState('until', ''));
     $state['orderstate'] = $app->input->get('orderstate', $model->getState('orderstate', 0));
     $state['user_id'] = $app->input->getInt('user_id', $model->getState('user_id', 0));
     $state['coupon_code'] = $app->input->getString('coupon_code', $model->getState('coupon_code', ''));
     $state['moneysum'] = $app->input->getString('moneysum', '');
     $state['frominvoice'] = $app->input->getString('frominvoice', $model->getState('frominvoice', ''));
     $state['toinvoice'] = $app->input->getString('toinvoice', $model->getState('toinvoice', ''));
     $state['paykey'] = $app->input->getString('paykey', '');
     $state['filter_order'] = $app->input->getString('filter_order', 'order_id');
     $state['filter_order_Dir'] = $app->input->getString('filter_order_Dir', 'DESC');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     // ...ordering
     /* $this->lists->set('order', $model->getState('filter_order', 'id', 'cmd'));
     		$this->lists->set('order_Dir', $model->getState('filter_order_Dir', 'DESC', 'cmd'));
      */
     // Assign data to the view
     $this->items = $model->getOrderList();
     $this->pagination = $model->getPagination();
     // Pass page params on frontend only
     if (F0FPlatform::getInstance()->isFrontend()) {
         $params = JFactory::getApplication()->getParams();
         $this->params = $params;
     }
     $state = $model->getState();
     $this->state = $state;
     $this->currency = J2Store::currency();
     return true;
 }
Exemplo n.º 8
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();
 }
 function _prePayment($data)
 {
     $app = JFactory::getApplication();
     $currency = J2Store::currency();
     // Prepare the payment form
     $vars = new JObject();
     $vars->url = JRoute::_("index.php?option=com_j2store&view=checkout");
     $vars->order_id = $data['order_id'];
     $vars->orderpayment_id = $data['orderpayment_id'];
     $vars->orderpayment_type = $this->_element;
     F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
     $order = F0FTable::getInstance('Order', 'J2StoreTable');
     $order->load($data['orderpayment_id']);
     $twpg_amount = round($order->order_total, 2);
     $bankHandler = new Ubrir(array('shopId' => $this->params->get('twpg_id', 'PLG_J2STORE_PAYMENT_UBRIR'), 'order_id' => $data['order_id'], 'sert' => $this->params->get('twpg_sert', 'PLG_J2STORE_PAYMENT_UBRIR'), 'amount' => $twpg_amount, 'approve_url' => JURI::root() . 'plugins/j2store/payment_ubrir/payment_ubrir/tmpl/result.php?id=' . $data['order_id'], 'cancel_url' => JURI::root() . 'plugins/j2store/payment_ubrir/payment_ubrir/tmpl/result.php?id=' . $data['order_id'], 'decline_url' => JURI::root() . 'plugins/j2store/payment_ubrir/payment_ubrir/tmpl/result.php?id=' . $data['order_id']));
     $response_order = $bankHandler->prepare_to_pay();
     if (!empty($response_order)) {
         $db =& JFactory::getDBO();
         $sql = " UPDATE #__j2store_orders \n\t\tSET `transaction_id` = " . $response_order->OrderID[0] . ", `transaction_details` = '" . $response_order->SessionID[0] . "'\n\t\tWHERE `order_id` = " . $data['order_id'];
         $db->setQuery($sql);
         if (!$db->query()) {
             exit('error_1101');
         }
     } else {
         exit('error_1102');
     }
     $out = '';
     $twpg_url = $response_order->URL[0] . '?orderid=' . $response_order->OrderID[0] . '&sessionid=' . $response_order->SessionID[0];
     $out .= '<p>Данный заказ необходимо оплатить одним из методов, приведенных ниже: </p> <INPUT TYPE="button" value="Оплатить Visa" onclick="document.location = \'' . $twpg_url . '\'">';
     if ($this->params->get('two', 'PLG_J2STORE_PAYMENT_UBRIR') == 0) {
         // если активны два процессинга, то работаем еще и с Uniteller
         $out .= ' <INPUT TYPE="button" onclick="document.forms.uniteller.submit()" value="Оплатить MasterCard">';
         include dirname(__FILE__) . "/payment_ubrir/library/include/uni_form.php";
     }
     return $out;
 }
Exemplo n.º 10
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;
$currency = J2Store::currency();
$doc = JFactory::getDocument();
$doc->addStyleSheet(JUri::root() . 'media/j2store/css/font-awesome.min.css');
?>

<?php 
if (isset($this->orders) && count($this->orders)) {
    ?>
<table class="table table-bordered table-striped">
	<thead>
		<th><?php 
    echo JText::_('J2STORE_ORDER_DATE');
    ?>
</th>
		<th><?php 
    echo JText::_('J2STORE_INVOICE_NO');
    ?>
</th>
		<th><?php 
    echo JText::_('J2STORE_ORDER_AMOUNT');
    ?>
</th>
Exemplo n.º 11
0
 function getCurrency($order, $convert = false)
 {
     $results = array();
     $convert = false;
     $currencyObject = J2Store::currency();
     $currency_code = $order->currency_code;
     $currency_value = $order->currency_value;
     //accepted currencies
     $currencies = $this->getAcceptedCurrencies();
     if (!in_array($order->currency_code, $currencies)) {
         $default_currency = 'USD';
         if ($currencyObject->has($default_currency)) {
             $currencyObject->set($default_currency);
             $currency_code = $default_currency;
             $currency_value = $currencyObject->getValue($default_currency);
             $convert = true;
         }
     }
     $results['currency_code'] = $currency_code;
     $results['currency_value'] = $currency_value;
     $results['convert'] = $convert;
     return $results;
 }
Exemplo n.º 12
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->j2store_shippingmethod_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>: " . J2Store::currency()->format($item->subtotal_minimum);
    }
    if ($item->subtotal_maximum > '-1') {
        echo "<br/><b>" . JText::_('J2STORE_SHIPPING_METHODS_SUBTOTAL_MAX') . "</b>: " . J2Store::currency()->format($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 {
Exemplo n.º 13
0
 function saveOrder()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $lang = JFactory::getLanguage();
     $session = JFactory::getSession();
     $params = J2Store::config();
     //cart id
     $this->cart_id = F0FModel::getTmpInstance('Carts', 'J2StoreModel')->getCartId();
     //	if(!isset($this->order_id) || empty($this->order_id) || $this->is_update != 1) {
     //	$this->order_id = time().$this->cart_id;
     //	}
     //set order values
     $this->user_id = $user->id;
     $this->ip_address = $_SERVER['REMOTE_ADDR'];
     $this->customer_note = $session->get('customer_note', '', 'j2store');
     $this->customer_language = $lang->getTag();
     //$this->customer_group = implode(',', JAccess::getGroupsByUser($user->id, false));
     $this->customer_group = implode(',', JAccess::getAuthorisedViewLevels($user->id, false));
     //set a default order status.
     $default_order_state = 5;
     $this->order_state_id = $default_order_state;
     //get currency id, value and code and store it
     $currency = J2Store::currency();
     $this->currency_id = $currency->getId();
     $this->currency_code = $currency->getCode();
     $this->currency_value = $currency->getValue($currency->getCode());
     $this->is_including_tax = $params->get('config_including_tax', 0);
     //sanity check for user email
     if (empty($this->user_email)) {
         if ($user->id) {
             $user_email = $user->email;
         } else {
             $guest = $session->get('guest', array(), 'j2store');
             $billing_address = isset($guest['billing']) ? $guest['billing'] : array();
             $user_email = isset($billing_address['email']) ? $billing_address['email'] : '';
         }
         $this->user_email = $user_email;
     }
     //trigger on before save
     J2Store::plugin()->event('BeforeSaveOrder', array(&$this));
     if ($this->is_update == 1) {
         //trigger on before update
         J2Store::plugin()->event('BeforeUpdateOrder', array(&$this));
     } else {
         //trigger on before create a new order
         J2Store::plugin()->event('BeforeCreateNewOrder', array(&$this));
     }
     try {
         if ($this->store()) {
             if (!isset($this->order_id) || empty($this->order_id) || !isset($this->is_update) || $this->is_update != 1) {
                 $this->order_id = time() . $this->j2store_order_id;
                 //generate invoice number
                 $this->generateInvoiceNumber();
                 //generate a unique hash
                 $this->token = JApplicationHelper::getHash($this->order_id);
                 //save again so that the unique order id is saved.
                 $this->store();
             }
             //saved.
             //save all related tables as well
             $this->saveOrderItems();
             $this->saveOrderInfo();
             $this->saveOrderShipping();
             $this->saveOrderTax();
             $this->saveOrderCoupons();
             $this->saveOrderVouchers();
             $this->saveOrderDiscount();
             $this->saveOrderFiles();
             //trigger on before save
             J2Store::plugin()->event('AfterSaveOrder', array(&$this));
             if ($this->is_update == 1) {
                 $this->add_history(JText::_('J2STORE_ORDER_UPDATED_BY_CUSTOMER'));
                 //trigger on before update
                 J2Store::plugin()->event('AfterUpdateOrder', array(&$this));
             } else {
                 $this->add_history(JText::_('J2STORE_NEW_ORDER_CREATED'));
                 //trigger on before update
                 J2Store::plugin()->event('AfterCreateNewOrder', array(&$this));
             }
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
         return false;
     }
     return $this;
 }
Exemplo n.º 14
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
  */
 public function processTags($text, $order, $extras = array())
 {
     $app = JFactory::getApplication();
     $params = J2Store::config();
     $currency = J2Store::currency();
     $order_model = F0FModel::getTmpInstance('Orders', 'J2StoreModel');
     // -- 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
     $url = str_replace('&amp;', '&', JRoute::_('index.php?option=com_j2store&view=myprofile'));
     $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->created_on, $params->get('date_format', JText::_('DATE_FORMAT_LC1')));
     $tz = JFactory::getConfig()->get('offset');
     $date = JFactory::getDate($order->created_on, $tz);
     $order_date = $date->format($params->get('date_format', JText::_('DATE_FORMAT_LC1')), true);
     //items table
     $items = $order_model->loadItemsTemplate($order);
     $invoice_number = $order->getInvoiceNumber();
     //now process tags
     $orderinfo = $order->getOrderInformation();
     $shipping = $order->getOrderShippingRate();
     $ordercoupon = $order->getOrderCoupons();
     $status = F0FModel::getTmpInstance('Orderstatuses', 'J2StoreModel')->getItem($order->order_state_id);
     $coupon_code = '';
     if ($ordercoupon) {
         $coupon_code = $ordercoupon[0]->coupon_code;
     }
     $orderinfo->billing_country_name = F0FModel::getTmpInstance('Countries', 'J2StoreModel')->getItem($orderinfo->billing_country_id)->country_name;
     $orderinfo->shipping_country_name = F0FModel::getTmpInstance('Countries', 'J2StoreModel')->getItem($orderinfo->shipping_country_id)->country_name;
     $orderinfo->billing_zone_name = F0FModel::getTmpInstance('Zones', 'J2StoreModel')->getItem($orderinfo->billing_zone_id)->zone_name;
     $orderinfo->shipping_zone_name = F0FModel::getTmpInstance('Zones', 'J2StoreModel')->getItem($orderinfo->shipping_zone_id)->zone_name;
     $tags = array("\\n" => "\n", '[SITENAME]' => $sitename, '[SITEURL]' => $baseURL, '[INVOICE_URL]' => $invoiceURL, '[ORDERID]' => $order->order_id, '[INVOICENO]' => $invoice_number, '[ORDERDATE]' => $order_date, '[ORDERSTATUS]' => JText::_($status->orderstatus_name), '[ORDERAMOUNT]' => $currency->format($order->get_formatted_grandtotal(), $order->currency_code, $order->currency_value), '[CUSTOMER_NAME]' => $orderinfo->billing_first_name . ' ' . $orderinfo->billing_last_name, '[BILLING_FIRSTNAME]' => $orderinfo->billing_first_name, '[BILLING_LASTNAME]' => $orderinfo->billing_last_name, '[BILLING_EMAIL]' => $order->user_email, '[BILLING_ADDRESS_1]' => $orderinfo->billing_address_1, '[BILLING_ADDRESS_2]' => $orderinfo->billing_address_2, '[BILLING_CITY]' => $orderinfo->billing_city, '[BILLING_ZIP]' => $orderinfo->billing_zip, '[BILLING_COUNTRY]' => $orderinfo->billing_country_name, '[BILLING_STATE]' => $orderinfo->billing_zone_name, '[BILLING_COMPANY]' => $orderinfo->billing_company, '[BILLING_VATID]' => $orderinfo->billing_tax_number, '[BILLING_PHONE]' => $orderinfo->billing_phone_1, '[BILLING_MOBILE]' => $orderinfo->billing_phone_2, '[SHIPPING_FIRSTNAME]' => $orderinfo->shipping_first_name, '[SHIPPING_LASTNAME]' => $orderinfo->shipping_last_name, '[SHIPPING_ADDRESS_1]' => $orderinfo->shipping_address_1, '[SHIPPING_ADDRESS_2]' => $orderinfo->shipping_address_2, '[SHIPPING_CITY]' => $orderinfo->shipping_city, '[SHIPPING_ZIP]' => $orderinfo->shipping_zip, '[SHIPPING_COUNTRY]' => $orderinfo->shipping_country_name, '[SHIPPING_STATE]' => $orderinfo->shipping_zone_name, '[SHIPPING_COMPANY]' => $orderinfo->shipping_company, '[SHIPPING_VATID]' => $orderinfo->shipping_tax_number, '[SHIPPING_PHONE]' => $orderinfo->shipping_phone_1, '[SHIPPING_MOBILE]' => $orderinfo->shipping_phone_2, '[SHIPPING_METHOD]' => JText::_($shipping->ordershipping_name), '[SHIPPING_TYPE]' => JText::_($shipping->ordershipping_name), '[SHIPPING_TRACKING_ID]' => $shipping->ordershipping_tracking_id, '[CUSTOMER_NOTE]' => $order->customer_note, '[PAYMENT_TYPE]' => JText::_($order->orderpayment_type), '[ORDER_TOKEN]' => $order->token, '[TOKEN]' => $order->token, '[COUPON_CODE]' => $coupon_code, '[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($orderinfo, 'billing', $text);
     //shipping Format [CUSTOM_SHIPPING_FIELD:KEYNAME]
     $text = $this->processCustomFields($orderinfo, 'shipping', $text);
     //payment Format [CUSTOM_PAYMENT_FIELD:KEYNAME]
     $text = $this->processCustomFields($orderinfo, '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);
         }
     }
     J2Store::plugin()->event('AfterProcessTags', array($text, $order, $tags));
     return $text;
 }
Exemplo n.º 15
0
 public function getPriceRanges($items)
 {
     //get the active menu details
     $menu = JFactory::getApplication()->getMenu()->getActive();
     $params = F0FModel::getTmpInstance('Products', 'J2StoreModel')->getMergedParams();
     $ranges = array();
     $currency = J2Store::currency();
     //price filters
     if (isset($items['0']->pricing->price)) {
         $priceHigh = abs($items['0']->pricing->price);
     } else {
         $priceHigh = 0;
     }
     //create link to be concatinated
     //get the highest price
     $priceHigh = abs($params->get('list_price_filter_upper_limit', '1000'));
     $link = '';
     $priceLow = 0;
     $range = 0;
     if (count($items)) {
         foreach ($items as $item) {
             //$item->pricing->price
             //calculate the price low
             $priceLow = count($item) == 1 ? 0 : abs($item[count($item) - 1]->pricing->price);
             //calculate the range price high - low price
             $range = (abs($priceHigh) - abs($priceLow)) / 4;
             //now round the price
             $roundRange = F0FModel::getTmpInstance('Products', 'J2StoreModel')->_priceRound($range, $params->get('list_price_round_digit', '100'), true);
             //get the lowest price
             $roundPriceLow = F0FModel::getTmpInstance('Products', 'J2StoreModel')->_priceRound($priceLow, $params->get('list_price_round_digit', '100'));
         }
     }
     $ranges['max_price'] = $priceHigh;
     $ranges['min_price'] = $priceLow;
     $ranges['range'] = $range;
     return $ranges;
 }
Exemplo n.º 16
0
 function setpaimport()
 {
     $app = JFactory::getApplication();
     $model = $this->getThisModel();
     $view = $this->getThisView();
     $view->setModel($model, true);
     $product_id = $app->input->getInt('product_id', 0);
     if ($product_id) {
         $product_type = $app->input->getString('product_type', 'simple');
         $model->setState('product_type', $product_type);
         $product_list = $model->getProductList();
         $products = array();
         foreach ($product_list as $item) {
             // run the getItem again
             unset($product);
             if (isset($item->has_options) && $item->has_options) {
                 $product = F0FModel::getTmpInstance('Products', 'J2StoreModel')->runMyBehaviorFlag(true)->getItem($item->j2store_product_id);
                 $products[] = $product;
             }
         }
         $items = F0FModel::getTmpInstance('Productoptions', 'J2StoreModel')->getList();
         $total = F0FModel::getTmpInstance('Productoptions', 'J2StoreModel')->getTotal();
         $pagination = F0FModel::getTmpInstance('Productoptions', 'J2StoreModel')->getPagination();
         $view->assign('model', $model);
         $view->assign('state', $model->getState());
         $view->assign('products', $products);
         $row = F0FModel::getTmpInstance('Products', 'J2StoreModel')->getItem($product_id);
         $view->assign('row', $row);
         $view->assign('productHelper', J2Store::product());
         $view->assign('currency', J2Store::currency());
         //$view->assign('lists',$lists);
         $view->assign('total', $total);
         $view->assign('product_id', $product_id);
     }
     $view->setLayout('paimport');
     $view->display();
 }
Exemplo n.º 17
0
 protected function onDisplay($tpl = null)
 {
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $view = $this->input->getCmd('view', 'cpanel');
     $params = J2Store::config();
     J2Store::utilities()->nocache();
     $this->currency = J2Store::currency();
     $this->store = J2Store::storeProfile();
     if (in_array($view, array('cpanel', 'cpanels'))) {
         return;
     }
     $country_id = $this->input->getInt('country_id');
     if (isset($country_id)) {
         $session->set('billing_country_id', $country_id, 'j2store');
         $session->set('shipping_country_id', $country_id, 'j2store');
     } elseif ($session->has('shipping_country_id', 'j2store')) {
         $country_id = $session->get('shipping_country_id', '', 'j2store');
     } else {
         $country_id = $this->store->get('country_id');
     }
     $zone_id = $this->input->getInt('zone_id');
     if (isset($zone_id)) {
         $session->set('billing_zone_id', $zone_id, 'j2store');
         $session->set('shipping_zone_id', $zone_id, 'j2store');
     } elseif ($session->has('shipping_zone_id', 'j2store')) {
         $zone_id = $session->get('shipping_zone_id', '', 'j2store');
     } else {
         $zone_id = $this->store->get('zone_id');
     }
     $postcode = $this->input->getString('postcode');
     if (isset($postcode)) {
         $session->set('shipping_postcode', $postcode, 'j2store');
     } elseif ($session->has('shipping_postcode', 'j2store')) {
         $postcode = $session->get('shipping_postcode', '', 'j2store');
     } else {
         $postcode = $this->store->get('zip');
     }
     $this->country_id = $country_id;
     $this->zone_id = $zone_id;
     $this->postcode = $postcode;
     if ($params->get('hide_shipping_untill_address_selection', 1) == 0) {
         $session->set('billing_country_id', $country_id, 'j2store');
         $session->set('shipping_country_id', $country_id, 'j2store');
         $session->set('billing_zone_id', $zone_id, 'j2store');
         $session->set('shipping_zone_id', $zone_id, 'j2store');
         $session->set('shipping_postcode', $postcode, 'j2store');
         $session->set('force_calculate_shipping', 1, 'j2store');
     }
     // Load the model
     $model = $this->getModel();
     $items = $model->getItems();
     //plugin trigger
     $this->before_display_cart = '';
     $before_results = J2Store::plugin()->event('BeforeDisplayCart', array($items));
     foreach ($before_results as $result) {
         $this->before_display_cart .= $result;
     }
     //trigger plugin events
     $i = 0;
     $onDisplayCartItem = array();
     foreach ($items as $item) {
         ob_start();
         J2Store::plugin()->event('DisplayCartItem', array($i, $item));
         $cartItemContents = ob_get_contents();
         ob_end_clean();
         if (!empty($cartItemContents)) {
             $onDisplayCartItem[$i] = $cartItemContents;
         }
         $i++;
     }
     $this->onDisplayCartItem = $onDisplayCartItem;
     $order = F0FModel::getTmpInstance('Orders', 'J2StoreModel')->populateOrder($items)->getOrder();
     $order->validate_order_stock();
     $this->order = $order;
     $this->items = $order->getItems();
     foreach ($this->items as $item) {
         if (isset($item->orderitemattributes) && count($item->orderitemattributes)) {
             foreach ($item->orderitemattributes as &$attribute) {
                 if ($attribute->orderitemattribute_type == 'file') {
                     unset($table);
                     $table = F0FTable::getInstance('Upload', 'J2StoreTable');
                     if ($table->load(array('mangled_name' => $attribute->orderitemattribute_value))) {
                         $attribute->orderitemattribute_value = $table->original_name;
                     }
                 }
             }
         }
     }
     $this->taxes = $order->getOrderTaxrates();
     $this->shipping = $order->getOrderShippingRate();
     $this->coupons = $order->getOrderCoupons();
     $this->vouchers = $order->getOrderVouchers();
     $this->taxModel = F0FModel::getTmpInstance('TaxProfiles', 'J2StoreModel');
     //do we have shipping methods
     $this->shipping_methods = $session->get('shipping_methods', array(), 'j2store');
     $this->shipping_values = $session->get('shipping_values', array(), 'j2store');
     $this->checkout_url = $model->getCheckoutUrl();
     $this->continue_shopping_url = $model->getContinueShoppingUrl();
     $this->after_display_cart = '';
     $results = J2Store::plugin()->event('AfterDisplayCart', array($order));
     foreach ($results as $result) {
         $this->after_display_cart .= $result;
     }
     // Pass page params on frontend only
     if (F0FPlatform::getInstance()->isFrontend()) {
         $this->params = $params;
     }
     return true;
 }
Exemplo n.º 18
0
 /**
  * Method to get rates from the USPS shipping API
  *
  * @param array $address
  * @return array rates array
  */
 private function getRates($address, $order)
 {
     $rates = array();
     $status = true;
     $shipping_status = false;
     //first check if shippable items are in cart
     $products = $order->getItems();
     if ($order->isShippingEnabled() === false) {
         return $rates;
     }
     $currencyObject = J2Store::currency();
     $store_address = J2Store::config();
     $domestic_services = $this->params->get('domestic_services');
     $inernational_services = $this->params->get('international_services');
     $quote_data = array();
     $method_data = array();
     $cart_weight_total = $order->getTotalShippingWeight();
     $weightObject = J2Store::weight();
     $weight = $weightObject->convert($cart_weight_total, $store_address->get('config_weight_class_id'), $this->params->get('usps_weight_class_id'));
     $weight = $weight < 0.1 ? 0.1 : $weight;
     $pounds = floor($weight);
     $ounces = round(16 * ($weight - $pounds), 2);
     // max 5 digits
     $postcode = str_replace(' ', '', $address->postal_code);
     //get country data
     if ($address->country_isocode_2 == 'US') {
         $xml = '<RateV4Request USERID="' . $this->usps_username . '">';
         $xml .= '	<Package ID="1">';
         $xml .= '		<Service>ALL</Service>';
         $xml .= '		<ZipOrigination>' . substr($this->params->get('usps_postcode'), 0, 5) . '</ZipOrigination>';
         $xml .= '		<ZipDestination>' . substr($postcode, 0, 5) . '</ZipDestination>';
         $xml .= '		<Pounds>' . $pounds . '</Pounds>';
         $xml .= '		<Ounces>' . $ounces . '</Ounces>';
         // Prevent common size mismatch error from USPS (Size cannot be Regular if Container is Rectangular for some reason)
         if ($this->params->get('usps_container') == 'RECTANGULAR' && $this->params->get('usps_size') == 'REGULAR') {
             $this->params->set('usps_container', 'VARIABLE');
         }
         $xml .= '		<Container>' . $this->params->get('usps_container') . '</Container>';
         $xml .= '		<Size>' . $this->params->get('usps_size') . '</Size>';
         $xml .= '		<Width>' . $this->params->get('usps_width') . '</Width>';
         $xml .= '		<Length>' . $this->params->get('usps_length') . '</Length>';
         $xml .= '		<Height>' . $this->params->get('usps_height') . '</Height>';
         // Calculate girth based on usps calculation
         $xml .= '		<Girth>' . round((double) $this->params->get('usps_length') + (double) $this->params->get('usps_width') * 2 + (double) $this->params->get('usps_height') * 2, 1) . '</Girth>';
         $xml .= '		<Machinable>' . ($this->params->get('usps_machinable') ? 'true' : 'false') . '</Machinable>';
         $xml .= '	</Package>';
         $xml .= '</RateV4Request>';
         $request = 'API=RateV4&XML=' . urlencode($xml);
     } else {
         $countries = $this->getCountries();
         if (isset($countries[$address->country_isocode_2])) {
             $xml = '<IntlRateV2Request USERID="' . $this->usps_username . '">';
             $xml .= '	<Package ID="1">';
             $xml .= '		<Pounds>' . $pounds . '</Pounds>';
             $xml .= '		<Ounces>' . $ounces . '</Ounces>';
             $xml .= '		<MailType>All</MailType>';
             $xml .= '		<GXG>';
             $xml .= '		  <POBoxFlag>N</POBoxFlag>';
             $xml .= '		  <GiftFlag>N</GiftFlag>';
             $xml .= '		</GXG>';
             $xml .= '		<ValueOfContents>' . $order->order_subtotal . '</ValueOfContents>';
             $xml .= '		<Country>' . $countries[$address->country_isocode_2] . '</Country>';
             // Intl only supports RECT and NONRECT
             if ($this->params->get('usps_container') == 'VARIABLE') {
                 $this->params->set('usps_container', 'NONRECTANGULAR');
             }
             $xml .= '		<Container>' . $this->params->get('usps_container') . '</Container>';
             $xml .= '		<Size>' . $this->params->get('usps_size') . '</Size>';
             $xml .= '		<Width>' . $this->params->get('usps_width') . '</Width>';
             $xml .= '		<Length>' . $this->params->get('usps_length') . '</Length>';
             $xml .= '		<Height>' . $this->params->get('usps_height') . '</Height>';
             $xml .= '		<Girth>' . $this->params->get('usps_girth') . '</Girth>';
             $xml .= '		<CommercialFlag>N</CommercialFlag>';
             $xml .= '	</Package>';
             $xml .= '</IntlRateV2Request>';
             $request = 'API=IntlRateV2&XML=' . urlencode($xml);
         } else {
             $status = false;
         }
     }
     if ($status) {
         $result = $this->_sendRequest($request);
         $handling = $this->params->get('handling', '0');
         if ($result) {
             if ($this->params->get('show_debug')) {
                 $this->_log("USPS DATA SENT: " . urldecode($request));
                 $this->_log("USPS DATA RECV: " . $result);
             }
             $dom = new DOMDocument('1.0', 'UTF-8');
             $dom->loadXml($result);
             $rate_response = $dom->getElementsByTagName('RateV4Response')->item(0);
             $intl_rate_response = $dom->getElementsByTagName('IntlRateV2Response')->item(0);
             $error = $dom->getElementsByTagName('Error')->item(0);
             $firstclasses = array('First-Class Mail Parcel', 'First-Class Mail Large Envelope', 'First-Class Mail Letter', 'First-Class Mail Postcards');
             if ($rate_response || $intl_rate_response) {
                 if ($address->country_isocode_2 == 'US') {
                     $allowed = array(0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 16, 17, 18, 19, 22, 23, 25, 27, 28, 30, 31, 55, 56, 62, 63);
                     $package = $rate_response->getElementsByTagName('Package')->item(0);
                     $postages = $package->getElementsByTagName('Postage');
                     if ($postages->length) {
                         foreach ($postages as $postage) {
                             $classid = $postage->getAttribute('CLASSID');
                             if (in_array($classid, $allowed)) {
                                 if ($classid == '0') {
                                     $mailservice = $postage->getElementsByTagName('MailService')->item(0)->nodeValue;
                                     foreach ($firstclasses as $k => $firstclass) {
                                         if ($firstclass == $mailservice) {
                                             $classid = $classid . $k;
                                             break;
                                         }
                                     }
                                     if (in_array('usps_domestic_' . $classid, $domestic_services)) {
                                         $cost = $postage->getElementsByTagName('Rate')->item(0)->nodeValue;
                                         $price = $currencyObject->convert($cost, 'USD', $store_address->get('config_currency'));
                                         $rate = array();
                                         $rate['name'] = $postage->getElementsByTagName('MailService')->item(0)->nodeValue;
                                         $rate['code'] = 'usps.' . $classid;
                                         $rate['price'] = $price;
                                         $rate['extra'] = (double) $handling;
                                         $rate['total'] = $rate['price'] + $rate['extra'];
                                         $rate['tax'] = "0.00";
                                         $rate['element'] = $this->_element;
                                         $rates[] = $rate;
                                     }
                                 } elseif (in_array('usps_domestic_' . $classid, $domestic_services)) {
                                     $cost = $postage->getElementsByTagName('Rate')->item(0)->nodeValue;
                                     $price = $currencyObject->convert($cost, 'USD', $store_address->get('config_currency'));
                                     $rate = array();
                                     $rate['name'] = $postage->getElementsByTagName('MailService')->item(0)->nodeValue;
                                     $rate['code'] = 'usps.' . $classid;
                                     $rate['price'] = $price;
                                     $rate['extra'] = (double) $handling;
                                     $rate['total'] = $rate['price'] + $rate['extra'];
                                     $rate['tax'] = "0.00";
                                     $rate['element'] = $this->_element;
                                     $rates[] = $rate;
                                 }
                             }
                         }
                     } else {
                         $error = $package->getElementsByTagName('Error')->item(0);
                         $method_data = array('code' => 'usps', 'title' => JText::_('usps_error_text'), 'quote' => $quote_data, 'error' => $error->getElementsByTagName('Description')->item(0)->nodeValue);
                     }
                 } else {
                     $allowed = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
                     $package = $intl_rate_response->getElementsByTagName('Package')->item(0);
                     $services = $package->getElementsByTagName('Service');
                     if (isset($inernational_services) && !empty($inernational_services)) {
                         foreach ($services as $service) {
                             $id = $service->getAttribute('ID');
                             if (in_array($id, $allowed) && in_array('usps_international_' . $id, $inernational_services)) {
                                 $title = $service->getElementsByTagName('SvcDescription')->item(0)->nodeValue;
                                 if ($this->params->get('usps_display_time')) {
                                     $title .= ' (' . JText::_('usps_text_eta') . ' ' . $service->getElementsByTagName('SvcCommitments')->item(0)->nodeValue . ')';
                                 }
                                 $cost = $service->getElementsByTagName('Postage')->item(0)->nodeValue;
                                 $price = $currencyObject->convert($cost, 'USD', $store_address->get('config_currency'));
                                 $rate = array();
                                 $rate['name'] = $title;
                                 $rate['code'] = 'usps.' . $id;
                                 $rate['price'] = $price;
                                 $rate['extra'] = (double) $handling;
                                 $rate['total'] = $rate['price'] + $rate['extra'];
                                 $rate['tax'] = "0.00";
                                 $rate['element'] = $this->_element;
                                 $rates[] = $rate;
                             }
                         }
                     }
                 }
             } elseif ($error) {
                 $method_data = array('code' => 'usps', 'title' => JText::_('usps_error_text'), 'quote' => $quote_data, 'error' => $error->getElementsByTagName('Description')->item(0)->nodeValue);
             }
         }
     }
     if (count($rates)) {
         //if the shipping is taxable, calculate it here.
         $tax_class_id = $this->params->get('usps_tax_class_id', '');
         if ($tax_class_id) {
             $j2tax = F0FModel::getTmpInstance('TaxProfiles', 'J2StoreModel');
             $newRates = array();
             foreach ($rates as $rate) {
                 $newRate = array();
                 $newRate['name'] = JText::_($rate['name']);
                 $newRate['code'] = $rate['code'];
                 $newRate['price'] = $rate['price'];
                 $newRate['extra'] = $rate['extra'];
                 $taxrates = $j2tax->getTaxwithRates($newRate['price'] + $newRate['extra'], $tax_class_id);
                 if (isset($taxrates->taxtotal)) {
                     $shipping_method_tax_total = $taxrates->taxtotal;
                 }
                 $newRate['tax'] = round($shipping_method_tax_total, 2);
                 $newRate['total'] = $newRate['price'] + $newRate['extra'] + $newRate['tax'];
                 $newRate['element'] = $rate['element'];
                 $newRates[] = $newRate;
             }
             unset($rates);
             $rates = $newRates;
         }
     }
     return $rates;
 }
Exemplo n.º 19
0
 public function displayPrice($price, $product, $params = array())
 {
     $currency = J2Store::currency();
     if (empty($params)) {
         $params = J2Store::config();
     }
     $this->reset_tax_text();
     //if no tax profile id found, just return the price.
     if (!$product->taxprofile_id) {
         $text = $currency->format($price);
     } else {
         switch ($params->get('price_display_options', 1)) {
             case '1':
             default:
                 //Price only
                 $text = $currency->format($this->get_price_excluding_tax($price, $product->taxprofile_id));
                 break;
             case '2':
                 //product including tax
                 $amount = $this->get_price_including_tax($price, $product->taxprofile_id);
                 $text = $currency->format($amount);
                 break;
         }
     }
     //allow plugins to modify the price display
     J2Store::plugin()->event('DisplayPlace', array(&$text, $product));
     return $text;
 }
Exemplo n.º 20
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;
$rates = array();
foreach ($vars->rates as $rate) {
    $r = new JObject();
    $r->value = $rate->shipping_rate_id;
    $r->text = J2Store::currency()->format($rate->shipping_rate_price);
    $rates[] =& $r;
}
?>
<div class="shipping_rates">
<?php 
echo JHTML::_('select.radiolist', $rates, 'shipping_rate', array());
?>
</div>
Exemplo n.º 21
0
 /**
  * Get formatted totals for an order
  * Since 3.2
  * @return array Totals as an associative array
  */
 public function get_formatted_order_totals()
 {
     $total_rows = array();
     $currency = J2Store::currency();
     $params = J2Store::config();
     $items = $this->getItems();
     $taxes = $this->getOrderTaxrates();
     $shipping = $this->getOrderShippingRate();
     //subtotal
     $total_rows['subtotal'] = array('label' => JText::_('J2STORE_CART_SUBTOTAL'), 'value' => $currency->format($this->get_formatted_subtotal($params->get('checkout_price_display_options', 1), $items), $this->currency_code, $this->currency_value));
     //shipping
     if (!empty($shipping->ordershipping_name)) {
         $total_rows['shipping'] = array('label' => JText::_(stripslashes($shipping->ordershipping_name)), 'value' => $currency->format($this->order_shipping, $this->currency_code, $this->currency_value));
     }
     //shipping tax
     if ($this->order_shipping_tax > 0) {
         $total_rows['shipping_tax'] = array('label' => JText::_('J2STORE_ORDER_SHIPPING_TAX'), 'value' => $currency->format($this->order_shipping_tax, $this->currency_code, $this->currency_value));
     }
     //fees
     foreach ($this->get_fees() as $fee) {
         $total_rows['fee_' . F0FInflector::underscore($fee->name)] = array('label' => JText::_($fee->name), 'value' => $currency->format($this->get_formatted_fees($fee, $params->get('checkout_price_display_options', 1)), $this->currency_code, $this->currency_value));
     }
     //surcharge @depreicated.
     if ($this->order_surcharge > 0) {
         $total_rows['surcharge'] = array('label' => JText::_('J2STORE_CART_SURCHARGE'), 'value' => $currency->format($this->order_surcharge, $this->currency_code, $this->currency_value));
     }
     //discount
     foreach ($this->getOrderDiscounts() as $discount) {
         if ($discount->discount_amount > 0) {
             $link = '';
             if ($discount->discount_type == 'coupon') {
                 $label = JText::sprintf('J2STORE_COUPON_TITLE', $discount->discount_title);
                 $link = '<a class="j2store-remove remove-icon" href="javascript:void(0)" onClick="jQuery(\'#j2store-cart-form #j2store-cart-task\').val(\'removeCoupon\'); jQuery(\'#j2store-cart-form\').submit();" >X</a>';
             } elseif ($discount->discount_type == 'voucher') {
                 $label = JText::sprintf('J2STORE_VOUCHER_TITLE', $discount->discount_title);
                 $link = '<a class="j2store-remove remove-icon" href="javascript:void(0)" onClick="jQuery(\'#j2store-cart-form #j2store-cart-task\').val(\'removeVoucher\'); jQuery(\'#j2store-cart-form\').submit();" >X</a>';
             } else {
                 $label = JText::sprintf('J2STORE_DISCOUNT_TITLE', $discount->discount_title);
             }
             $label .= J2Store::plugin()->eventWithHtml('AfterDisplayDiscountTitle', array($this, $discount));
             $value = $currency->format($this->get_formatted_discount($discount, $params->get('checkout_price_display_options', 1)), $this->currency_code, $this->currency_value);
             $value .= J2Store::plugin()->eventWithHtml('AfterDisplayDiscountAmount', array($this, $discount));
             $total_rows[$discount->discount_code . F0FInflector::underscore($discount->discount_title)] = array('label' => $label, 'link' => $link, 'value' => $value);
         }
     }
     //taxes
     if (isset($taxes) && count($taxes)) {
         $label = '';
         foreach ($taxes as $tax) {
             $label = '';
             if ($params->get('checkout_price_display_options', 1)) {
                 $label .= JText::sprintf('J2STORE_CART_TAX_INCLUDED_TITLE', $tax->ordertax_title, floatval($tax->ordertax_percent) . '%');
             } else {
                 $label .= JText::sprintf('J2STORE_CART_TAX_EXCLUDED_TITLE', $tax->ordertax_title, floatval($tax->ordertax_percent) . '%');
             }
             $value = $currency->format($tax->ordertax_amount, $this->currency_code, $this->currency_value);
             $total_rows['tax_' . F0FInflector::underscore($tax->ordertax_title)] = array('label' => $label, 'value' => $value);
         }
     }
     //refund
     if ($this->order_refund) {
         $total_rows['refund'] = array('label' => JText::_('J2STORE_CART_REFUND'), 'value' => $currency->format($this->order_refund, $this->currency_code, $this->currency_value));
     }
     $total_rows['grandtotal'] = array('label' => JText::_('J2STORE_CART_GRANDTOTAL'), 'value' => $currency->format($this->get_formatted_grandtotal(), $this->currency_code, $this->currency_value));
     //allow plugins to modify
     J2Store::plugin()->event('GetFormattedOrderTotals', array($this, $total_rows));
     return $total_rows;
 }
Exemplo n.º 22
0
<?php

/**
 * @package J2Store
 * @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org
 * @license GNU GPL v3 or later
 *
 * Bootstrap 2 layout of products
 */
// No direct access
defined('_JEXEC') or die;
JFactory::getDocument()->addScript(JURI::root(true) . '/media/j2store/js/filter.js');
$currency = J2Store::currency()->getSymbol();
$catid = JFactory::getApplication()->input->get('catid', array(), 'Array');
$session = JFactory::getSession();
$session_manufacturer_ids = $session->get('manufacturer_ids', array(), 'j2store');
$session_vendor_ids = $session->get('vendor_ids', array(), 'j2store');
$session_productfilter_ids = $session->get('productfilter_ids', array(), 'j2store');
$currency = $this->currency->getSymbol();
$catid = JFactory::getApplication()->input->get('catid', array(), 'Array');
$default_catid = '';
if (!empty($this->filters['filter_categories']) && count($this->filters['filter_categories'])) {
    ?>
		<?php 
    $default_catid = $this->filters['filter_categories'][0]->id;
    ?>
	<?php 
}
$filter_catid = isset($this->filter_catid) ? $this->filter_catid : '';
?>
Exemplo n.º 23
0
 /**
  * Prepares parameters for the payment processing
  *
  * @param object $data Post variables
  * @param string $auth_net_login_id
  * @param string $auth_net_tran_key
  * @return array
  * @access protected
  */
 function _getProcessVars($data, $order)
 {
     // joomla info
     $user = JFactory::getUser();
     $j2store_params = J2Store::config();
     $sage_userid = $user->id;
     $sage_card_holder = $data['cardholder'];
     $sage_card_num = str_replace(" ", "", str_replace("-", "", $data['cardnum']));
     //get start date
     //   if($data['cartstart']) {                                                                         // "5424000000000015";
     //		$sage_card_start_date              = $this->_getFormattedCardExprDate('my', $data['cardstart'] ); // "1209";
     //	}
     $sage_card_exp_date = $this->_getFormattedCardExprDate('my', $data['cardexp']);
     // "1209";
     $sage_cvv = $data['cardcvv'];
     //"";
     $sage_card_type = $data['cardtype'];
     //"";
     // order info
     $orderinfo = $order->getOrderInformation();
     if (!empty($orderinfo->billing_first_name)) {
         $sage_fname = $orderinfo->billing_first_name;
         //"Charles D.";
         $sage_lname = $orderinfo->billing_last_name;
         // "Gaulle";
         $sage_address1 = $orderinfo->billing_address_1;
         $sage_address2 = $orderinfo->billing_address_2;
         //"342 N. Main Street #150";
         $sage_city = $orderinfo->billing_city;
         //"Ft. Worth";
         $sage_state = substr($this->getZoneById($orderinfo->billing_zone_id)->zone_code, 0, 2);
         //"TX";
         $sage_zip = $orderinfo->billing_zip;
         //"12345";
         $sage_country = $this->getCountryById($orderinfo->billing_country_id)->country_isocode_2;
         // "US";
         $sage_phone = !empty($orderinfo->billing_phone_1) ? $orderinfo->billing_phone_1 : $orderinfo->billing_phone_2;
     } else {
         $sage_fname = $orderinfo->shipping_first_name;
         //"Charles D.";
         $sage_lname = $orderinfo->shipping_last_name;
         // "Gaulle";
         $sage_address1 = $orderinfo->shipping_address_1;
         $sage_address2 = $orderinfo->shipping_address_2;
         //"342 N. Main Street #150";
         $sage_city = $orderinfo->shipping_city;
         //"Ft. Worth";
         $sage_state = substr($this->getZoneById($orderinfo->shipping_zone_id)->zone_code, 0, 2);
         //TX
         $sage_zip = $orderinfo->shipping_zip;
         //"12345";
         $sage_country = $this->getCountryById($orderinfo->shipping_country_id)->country_isocode_2;
         // "US";
         $sage_phone = !empty($orderinfo->shipping_phone_1) ? $orderinfo->shipping_phone_1 : $orderinfo->shipping_phone_2;
     }
     $sage_useremail = $order->user_email;
     $sagepay_email = $this->login_id;
     $sagepay_pass = $this->tran_key;
     $currency_values = $this->getCurrency($order);
     $amount = J2Store::currency()->format($order->order_total, $currency_values['currency_code'], $currency_values['currency_value'], false);
     $basket = "";
     //total lines in the cart
     $basket .= "1:";
     //name of the product
     $basket .= $order->order_id . ":";
     //qty
     $basket .= "1:";
     //single item value
     $basket .= $amount . ":";
     //single item tax
     $basket .= ":";
     //single item total
     $basket .= $amount . ":";
     //Line total
     $basket .= $amount;
     // basket format	4:Pioneer NSDV99 DVD-Surround Sound System:1:424.68:74.32:499.00: 499.00
     $shipping_country = $this->getCountryById($orderinfo->shipping_country_id)->country_isocode_2;
     // put all values into an array
     $sagepay_values = array("VPSProtocol" => "3.0", "TxType" => "PAYMENT", "AccountType" => "E", "Apply3DSecure" => "0", "Vendor" => $sagepay_email, "VendorTxCode" => $order->order_id, "Amount" => $amount, "Currency" => $currency_values['currency_code'], "Description" => $order->order_id, "CardHolder" => $sage_card_holder, "CardNumber" => $sage_card_num, "ExpiryDate" => $sage_card_exp_date, "CV2" => $sage_cvv, "CardType" => $sage_card_type, "BillingSurname" => $sage_lname, "BillingFirstnames" => $sage_fname, "BillingAddress1" => $sage_address1, "BillingAddress2" => $sage_address2, "BillingCity" => $sage_city, "BillingPostCode" => $sage_zip, "BillingCountry" => $sage_country, "BillingPhone" => $sage_phone, "DeliverySurname" => $orderinfo->shipping_last_name, "DeliveryFirstnames" => $orderinfo->shipping_first_name, "DeliveryAddress1" => $orderinfo->shipping_address_1, "DeliveryCity" => $orderinfo->shipping_city, "DeliveryPostCode" => $orderinfo->shipping_zip, "DeliveryCountry" => $shipping_country, "CustomerEMail" => $sage_useremail, "Basket" => $basket, "GiftAidPayment" => "0", "ClientIPAddress" => $_SERVER['REMOTE_ADDR']);
     if ($sage_country == 'US') {
         $sagepay_values["BillingState"] = $sage_state;
     }
     if ($shipping_country == 'US') {
         $sagepay_values["DeliveryState"] = substr($this->getZoneById($orderinfo->shipping_zone_id)->zone_code, 0, 2);
     }
     //add optional fields
     //  if($this->partner_id) {
     //		$sagepay_values["ReferrerID"] =$this->partner_id;
     //	}
     //    if($sage_card_start_date) {
     //		$sagepay_values["StartDate"] =$sage_card_start_date;
     //	}
     //   if($data['cardissue']) {
     //		$sagepay_values["IssueNumber"] =$data['cardissue'];
     //	}
     return $sagepay_values;
 }
Exemplo n.º 24
0
 public function export($data = array(), $auto = false)
 {
     $app = JFactory::getApplication();
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('j2store');
     $currency = J2Store::currency();
     if ($auto) {
         //trigger the plugin event
         $results = $dispatcher->trigger("onJ2StoreBeforeOrderExport", array());
         if (is_array($results) && count($results)) {
             $data = array_merge($data, $results[0]);
         }
     }
     $paystate = '';
     //order status filter
     if (isset($data['export_status']) && is_array($data['export_status'])) {
         $paystate = implode(',', $data['export_status']);
     }
     /* 	$rows = $this->clearState()
     		->frominvoice($data['export_from'])
     		->toinvoice($data['export_to'])
     		->since($data['export_from_date'])
     		->until($data['export_to_date'])
     		->paystate($paystate)
     		->getOrdersExport(); */
     $rows = $this->getOrderList();
     if (count($rows) > 0) {
         //process the totals
         $max = 1;
         $new_orders = array();
         foreach ($rows as $key => $order) {
             $orderTable = F0FTable::getAnInstance('Order', 'J2StoreTable')->getClone();
             $orderTable->load($order->j2store_order_id);
             $orderitems = $orderTable->getItems();
             $new_order = array();
             $all_values = JArrayHelper::fromObject($order);
             $new_order = array_merge($new_order, $all_values);
             $new_order['billing_country_name'] = $order->billingcountry_name;
             $new_order['shipping_country_name'] = $order->shippingcountry_name;
             $new_order['billing_zone_name'] = $order->billingzone_name;
             $new_order['shipping_zone_name'] = $order->shippingzone_name;
             $processed_variables = array();
             $processed_variables['invoice'] = $order->invoice;
             $processed_variables['order_id'] = $order->order_id;
             $processed_variables['created_on'] = $order->created_on;
             $processed_variables['customer_name'] = $order->billing_first_name . ' ' . $order->billing_last_name;
             $processed_variables['customer_email'] = $order->user_email;
             $processed_variables['currency_code'] = $order->currency_code;
             $processed_variables['order_subtotal'] = $currency->format($order->order_subtotal, $order->currency_code, $order->currency_value, false);
             $processed_variables['order_tax'] = $currency->format($order->order_tax, $order->currency_code, $order->currency_value, false);
             $processed_variables['order_shipping'] = $currency->format($order->order_shipping, $order->currency_code, $order->currency_value, false);
             $processed_variables['order_shipping_tax'] = $currency->format($order->order_shipping_tax, $order->currency_code, $order->currency_value, false);
             $processed_variables['order_surcharge'] = $currency->format($order->order_surcharge, $order->currency_code, $order->currency_value, false);
             $processed_variables['order_discount'] = $currency->format($order->order_discount, $order->currency_code, $order->currency_value, false);
             $processed_variables['order_total'] = $currency->format($order->order_total, $order->currency_code, $order->currency_value, false);
             $new_order = array_merge($processed_variables, $new_order);
             $new_order['orderstatus_name'] = JText::_($order->orderstatus_name);
             $new_order['orderpayment_type'] = JText::_($order->orderpayment_type);
             //now process order items
             $i = 1;
             //$new_order['orderitems'] = $orderitems;
             foreach ($orderitems as $item) {
                 //prepare the array
                 $new_order['product_id_' . $i] = $item->product_id;
                 //$new_order['product_type_'.$i] =$item->product_type;
                 $new_order['product_sku_' . $i] = $item->orderitem_sku;
                 $new_order['product_name_' . $i] = $item->orderitem_name;
                 $new_order['product_options_' . $i] = $this->getItemDescription($item);
                 $new_order['product_quantity_' . $i] = $item->orderitem_quantity;
                 $new_order['product_tax_' . $i] = $currency->format($item->orderitem_tax, $order->currency_code, $order->currency_value, false);
                 $new_order['product_total_with_tax_' . $i] = $currency->format($item->orderitem_finalprice_with_tax, $order->currency_code, $order->currency_value, false);
                 $new_order['product_total_without_tax_' . $i] = $currency->format($item->orderitem_finalprice_without_tax, $order->currency_code, $order->currency_value, false);
                 $i++;
             }
             //unset variables
             $unset_variables = array('billingcountry_name', 'billingzone_name', 'shippingcountry_name', 'shippingzone_name', 'invoice_prefix', 'invoice_number', 'order_state', 'orderstatus_cssclass', 'all_billing', 'all_shipping', 'all_payment', 'j2store_order_id', 'user_email');
             $this->formatCustomFields('billing', $new_order['all_billing'], $new_order);
             $this->formatCustomFields('shipping', $new_order['all_shipping'], $new_order);
             $this->formatCustomFields('payment', $new_order['all_payment'], $new_order);
             foreach ($unset_variables as $var) {
                 unset($new_order[$var]);
             }
             $new_orders[] = JArrayHelper::toObject($new_order);
         }
         return $new_orders;
     }
     return true;
 }
Exemplo n.º 25
0
 function setcurrency()
 {
     //no cache
     J2Store::utilities()->clear_cache();
     J2Store::utilities()->nocache();
     $app = JFactory::getApplication();
     $currency = J2Store::currency();
     $post = $app->input->getArray($_POST);
     if (isset($post['currency_code'])) {
         $currency->set($post['currency_code']);
     }
     //get the redirect
     if (isset($post['redirect'])) {
         $url = base64_decode($post['redirect']);
     } else {
         $url = 'index.php';
     }
     $app->redirect($url);
 }