예제 #1
0
 public function update_inventory()
 {
     $app = JFactory::getApplication();
     $quantity = $app->input->getInt('quantity');
     $availability = $app->input->getInt('availability');
     $manage_stock = $app->input->getInt('manage_stock');
     $variant_id = $app->input->getInt('variant_id');
     $json = array();
     if ($variant_id > 0) {
         F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
         $productquantities = F0FTable::getInstance('Productquantity', 'J2StoreTable')->getClone();
         $productquantities->load(array('variant_id' => $variant_id));
         $productquantities->variant_id = $variant_id;
         $productquantities->quantity = $quantity;
         if (!$productquantities->store()) {
             $json['error'] = "Problem in Save";
         }
         $variants_table = F0FTable::getInstance('Variant', 'J2StoreTable')->getClone();
         $variants_table->load($variant_id);
         $variants_table->availability = $availability;
         $variants_table->manage_stock = $manage_stock;
         if (!$variants_table->store()) {
             $json['error'] = "Problem in Save";
         }
     }
     if (!$json) {
         $json['success'] = 'index.php?option=com_j2store&view=inventories';
     }
     echo json_encode($json);
     $app->close();
 }
예제 #2
0
 protected function _getMe()
 {
     if (empty($this->_row)) {
         F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
         $table = F0FTable::getInstance('Shipping', 'J2StoreTable');
         $table->load(array('element' => $this->_element, 'folder' => 'j2store'));
         $this->_row = $table;
     }
     return $this->_row;
 }
 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;
 }
예제 #4
0
파일: model.php 프로젝트: 01J/topm
 /**
  * Adds to the stack of model table paths in LIFO order.
  *
  * @param   mixed  $path  The directory as a string or directories as an array to add.
  *
  * @return  void
  *
  * @since   12.2
  */
 public static function addTablePath($path)
 {
     F0FTable::addIncludePath($path);
 }
예제 #5
0
 function display($field, $value, $map, $inside, $options = '', $test = false, $allFields = null, $allValues = null)
 {
     $app = JFactory::getApplication();
     $store = J2Store::storeProfile();
     $stateId = $currentZoneId = $store->get('zone_id') > 0 ? $store->get('zone_id') : '';
     $country_id = $store->get('country_id') > 0 ? $store->get('country_id') : '';
     //if no default value was set in the fields, then use the country id set in the store profile.
     if (empty($field->field_default)) {
         $defaultCountry = $country_id;
     }
     if (empty($value)) {
         $value = $field->field_default;
     }
     if ($field->field_options['zone_type'] == 'country') {
         if (isset($defaultCountry)) {
             $field->field_default = $defaultCountry;
         }
         if (empty($value)) {
             $value = $field->field_default;
         }
     } elseif ($field->field_options['zone_type'] == 'zone') {
         $stateId = str_replace(array('[', ']'), array('_', ''), $map);
         $dropdown = '';
         if ($allFields != null) {
             $country = null;
             foreach ($allFields as $f) {
                 if ($f->field_type == 'zone' && !empty($f->field_options['zone_type']) && $f->field_options['zone_type'] == 'country') {
                     $key = $f->field_namekey;
                     if (!empty($allValues->{$key})) {
                         $country = $allValues->{$key};
                     } else {
                         $country = $f->field_default;
                     }
                     break;
                 }
             }
             //no country id, then load it based on the zone default.
             if (empty($country) && isset($field->field_default)) {
                 F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
                 $table = F0FTable::getAnInstance('Zone', 'J2StoreTable');
                 if ($table->load($field->field_default)) {
                     $country = $table->country_id;
                 }
             }
             //still no. Set it to store default.
             if (empty($country)) {
                 $country = $store->get('country_id');
                 if (empty($value)) {
                     $value = $store->get('zone_id');
                 }
             }
             if (!empty($country)) {
                 $countryType = new j2storeCountryType();
                 $countryType->type = 'zone';
                 $countryType->country_id = $country;
                 $countryType->published = true;
                 $dropdown = $countryType->displayZone($map, $value, true);
             }
         }
         $html = '<span id="' . $stateId . '_container">' . $dropdown . '</span>' . '<input type="hidden" id="' . $stateId . '_default_value" name="' . $stateId . '_default_value" value="' . $value . '"/>';
         return $html;
     }
     return parent::display($field, $value, $map, $inside, $options, $test, $allFields, $allValues);
 }
예제 #6
0
 /**
  * Processes the payment form
  * and returns HTML to be displayed to the user
  * generally with a success/failed message
  *
  * @param $data array
  *        	form post data
  * @return string HTML to display
  */
 function _postPayment($data)
 {
     // Process the payment
     $app = JFactory::getApplication();
     $vars = new JObject();
     $html = '';
     $order_id = $app->input->getString('order_id');
     F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
     $order = F0FTable::getInstance('Order', 'J2StoreTable')->getClone();
     if ($order->load(array('order_id' => $order_id))) {
         $bank_information = $this->params->get('moneyorder_information', '');
         if (JString::strlen($bank_information) > 5) {
             $html = '<br />';
             $html .= '<strong>' . JText::_('J2STORE_MONEYORDER_INSTRUCTIONS') . '</strong>';
             $html .= '<br />';
             $html .= $bank_information;
             $order->customer_note = $order->customer_note . $html;
         }
         $order_state_id = $this->params->get('payment_status', 4);
         // DEFAULT: PENDING
         if ($order_state_id == 1) {
             // set order to confirmed and set the payment process complete.
             $order->payment_complete();
         } else {
             // set the chosen order status and force notify customer
             $order->update_status($order_state_id, true);
             // also reduce stock
             $order->reduce_order_stock();
         }
         if ($order->store()) {
             $order->empty_cart();
             $vars->onafterpayment_text = $this->params->get('onafterpayment', '');
             $html = $this->_getLayout('postpayment', $vars);
             // append the article with cash payment information
             $html .= $this->_displayArticle();
         } else {
             $html = $this->params->get('onerrorpayment', '');
             $html .= $order->getError();
         }
     } else {
         // order not found
         $html = $this->params->get('onerrorpayment', '');
     }
     return $html;
 }
예제 #7
0
 /**
  * @param $data     array       form post data
  * @return string   HTML to display
  */
 function _prePayment($data)
 {
     // get component params
     $params = J2Store::config();
     $currency = J2Store::currency();
     // prepare the payment form
     $vars = new JObject();
     $vars->order_id = $data['order_id'];
     $vars->orderpayment_id = $data['orderpayment_id'];
     F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
     $order = F0FTable::getInstance('Order', 'J2StoreTable')->getClone();
     $order->load(array('order_id' => $data['order_id']));
     $currency_values = $this->getCurrency($order);
     $vars->currency_code = $currency_values['currency_code'];
     $vars->orderpayment_amount = $currency->format($order->order_total, $currency_values['currency_code'], $currency_values['currency_value'], false);
     $vars->orderpayment_type = $this->_element;
     $vars->cart_session_id = JFactory::getSession()->getId();
     $vars->display_name = $this->params->get('display_name', 'PAYMENT_PAYPAL');
     $vars->onbeforepayment_text = $this->params->get('onbeforepayment', '');
     $vars->button_text = $this->params->get('button_text', 'J2STORE_PLACE_ORDER');
     $items = $order->getItems();
     $products = array();
     foreach ($items as $item) {
         $desc = $item->orderitem_name;
         //product options
         $options = array();
         if (isset($item->orderitemattributes) && count($item->orderitemattributes)) {
             foreach ($item->orderitemattributes as $attribute) {
                 $options[] = array('name' => JText::_($attribute->orderitemattribute_name), 'value' => $attribute->orderitemattribute_value);
             }
         }
         $desc = str_replace("'", '', $desc);
         $products[] = array('name' => html_entity_decode($desc, ENT_QUOTES, 'UTF-8'), 'options' => $options, 'number' => !empty($item->orderitem_sku) ? $item->orderitem_sku : $item->product_id, 'quantity' => intval($item->orderitem_quantity), 'price' => $currency->format($item->orderitem_finalprice_with_tax / $item->orderitem_quantity, $currency_values['currency_code'], $currency_values['currency_value'], false));
         $item->_description = $desc;
     }
     $handling_cost = $order->order_shipping + $order->order_shipping_tax + $order->order_surcharge;
     $handling_cart = $currency->format($handling_cost, $currency_values['currency_code'], $currency_values['currency_value'], false);
     if ($handling_cart > 0) {
         $products[] = array('name' => JText::_('J2STORE_SHIPPING_AND_HANDLING'), 'options' => array(), 'number' => '', 'quantity' => 1, 'price' => $handling_cart);
     }
     $vars->products = $products;
     //$vars->tax_cart = $currency->format($order->order_tax, $currency_values['currency_code'], $currency_values['currency_value'], false);
     $vars->discount_amount_cart = $currency->format($order->order_discount, $currency_values['currency_code'], $currency_values['currency_value'], false);
     $vars->order = $order;
     $vars->orderitems = $items;
     // set payment plugin variables
     // set payment plugin variables
     if ($this->params->get('sandbox', 0)) {
         $vars->merchant_email = trim($this->_getParam('sandbox_merchant_email'));
     } else {
         $vars->merchant_email = trim($this->_getParam('merchant_email'));
     }
     $rootURL = rtrim(JURI::base(), '/');
     $subpathURL = JURI::base(true);
     if (!empty($subpathURL) && $subpathURL != '/') {
         $rootURL = substr($rootURL, 0, -1 * strlen($subpathURL));
     }
     $vars->post_url = $this->_getPostUrl();
     $vars->return_url = $rootURL . JRoute::_("index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=display");
     $vars->cancel_url = $rootURL . JRoute::_("index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=cancel");
     $vars->notify_url = JURI::root() . "index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=" . $this->_element . "&paction=process&tmpl=component";
     //$vars->currency_code = $this->_getParam( 'currency', 'USD' );
     $orderinfo = $order->getOrderInformation();
     // set variables for user info
     $vars->first_name = $orderinfo->billing_first_name;
     $vars->last_name = $orderinfo->billing_last_name;
     $vars->email = $order->user_email;
     $vars->address_1 = $orderinfo->billing_address_1;
     $vars->address_2 = $orderinfo->billing_address_2;
     $vars->city = $orderinfo->billing_city;
     $vars->country = $this->getCountryById($orderinfo->billing_country_id)->country_name;
     $vars->region = $this->getZoneById($orderinfo->billing_zone_id)->zone_name;
     $vars->postal_code = $orderinfo->billing_zip;
     $vars->invoice = $order->getInvoiceNumber();
     $html = $this->_getLayout('prepayment', $vars);
     return $html;
 }
예제 #8
0
 public function resetCartTable($cart, $session_id, $user_id, $cart_type = 'cart')
 {
     $session = JFactory::getSession();
     if (!empty($cart)) {
         F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
         $keynames = array();
         $keynames['user_id'] = $user_id;
         $keynames['cart_type'] = $cart_type;
         $table = F0FTable::getInstance('Carts', 'J2StoreTable')->getClone();
         if (!$table->load($keynames)) {
             foreach ($cart as $key => $value) {
                 if (property_exists($table, $key)) {
                     $table->set($key, $value);
                 }
             }
             // this is a new cartitem, so set cart_id = 0
             $table->j2store_cart_id = '0';
         }
         //table loaded.
         $table->user_id = $user_id;
         $table->session_id = $session->getId();
         if (!$table->store()) {
             JError::raiseNotice($table->getError());
         } else {
             //now we got the cart id.
             $this->updateCartitemEntry($cart, $table);
         }
     }
 }
예제 #9
0
 /**
  * constructor
  */
 function __construct()
 {
     parent::__construct();
     F0FModel::addIncludePath(JPATH_SITE . '/plugins/j2store/report_itemised/report_itemised/models');
     F0FTable::addIncludePath(JPATH_SITE . '/plugins/j2store/report_itemised/report_itemised/tables');
 }
예제 #10
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
# Technical Support:  Forum - http://j2store.org/forum/index.html
-------------------------------------------------------------------------*/
/** ensure this file is being included by a parent file */
defined('_JEXEC') or die('Restricted access');
F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
class J2User
{
    public static $instance;
    public static function getInstance($properties = null)
    {
        if (!self::$instance) {
            self::$instance = new self($properties);
        }
        return self::$instance;
    }
    function addCustomer($post)
    {
        $app = JFactory::getApplication();
        $db = JFactory::getDBO();
        $user = JFactory::getUser();
        //first save data to the address table
        $row = F0FTable::getAnInstance('Address', 'J2StoreTable');
예제 #11
0
 /**
  * Proceeds the simple payment
  *
  * @param string $resp
  * @param array $submitted_values
  * @return object Message object
  * @access protected
  */
 function _evaluateSimplePaymentResponse($resp, $submitted_values)
 {
     $object = new JObject();
     $object->message = '';
     $html = '';
     $errors = array();
     $return = array();
     $user = JFactory::getUser();
     $config = J2Store::config();
     $transaction_details = $this->_getFormattedTransactionDetails($resp);
     $this->_log($transaction_details, 'Payment Gateway Response');
     // =======================
     // verify & create payment
     // =======================
     $order_id = $submitted_values['VendorTxCode'];
     // check that payment amount is correct for order_id
     F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
     $orderpayment = F0FTable::getInstance('Order', 'J2StoreTable');
     $orderpayment->load(array('order_id' => $order_id));
     if ($orderpayment->order_id == $order_id) {
         $values = array();
         $transaction_id = isset($resp['VPSTxId']) ? $resp['VPSTxId'] : '';
         $orderpayment->transaction_details = $transaction_details;
         $orderpayment->transaction_id = $transaction_id;
         $orderpayment->transaction_status = $resp['Status'];
         //set a default status to it
         $order_state_id = 4;
         // PENDING
         if (isset($resp['Status'])) {
             switch ($resp['Status']) {
                 case 'OK':
                     $order_state_id = 1;
                     // CONFIRMED
                     break;
                 case 'PENDING':
                     $order_state_id = 4;
                     break;
                 case 'NOTAUTHED':
                 case 'MALFORMED':
                 case 'INVALID':
                 case 'REJECTED':
                 case 'AUTHENTICATED':
                 case 'REGISTERED':
                 case 'ERROR':
                     $order_state_id = 3;
                     break;
                 case 'ABORT':
                     $order_state_id = 5;
                     break;
             }
         }
         if ($order_state_id == 1) {
             $orderpayment->payment_complete();
         } else {
             $orderpayment->update_status($order_state_id);
         }
         // save the order
         if (!$orderpayment->store()) {
             $errors[] = $orderpayment->getError();
         } else {
             $orderpayment->empty_cart();
         }
     } else {
         $errors[] = JText::_('J2STORE_SAGEPAY_ORDER_ID_MISMATCH');
     }
     if (empty($errors)) {
         $return['success'] = JText::_($this->params->get('onafterpayment', ''));
         $return['redirect'] = JRoute::_('index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=' . $this->_element . '&paction=display');
     } else {
         $error = count($errors) ? implode("\n", $errors) : '';
         $sitename = $config->get('sitename');
         $subject = JText::sprintf('J2STORE_SAGEPAY_EMAIL_PAYMENT_NOT_VALIDATED_SUBJECT', $sitename);
         $recipients = $this->_getAdmins();
         foreach ($recipients as $receiver) {
             $body = JText::sprintf('J2STORE_SAGEPAY_EMAIL_PAYMENT_FAILED_BODY', $receiver->name, $sitename, JURI::root(), $error, $transaction_details);
             J2Store::email()->sendErrorEmails($receiver->email, $subject, $body);
         }
         $this->_log($error, 'Transaction Errors');
         $return['error'] = $error;
     }
     return $return;
     // ===================
     // end custom code
     // ===================
 }