Пример #1
0
 /**
  * Render view.
  *
  * @param   array  $tpl  An optional associative array of configuration settings.
  *
  * @since   1.0
  * @return   null
  */
 public function display($tpl = null)
 {
     $user = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     require_once JPATH_SITE . '/components/com_quick2cart/helpers/media.php';
     // create object of media helper class
     $this->media = new qtc_mediaHelper();
     $model = $this->getModel('cartcheckout');
     $input = JFactory::getApplication()->input;
     $layout = $input->get('layout', '');
     // Send to joomla's registration of guest ckout is off
     if ($layout == 'cancel' || $layout == 'orderdetails') {
         $input->set('remote', 1);
         $sacontroller = new quick2cartController();
         $sacontroller->execute('clearcart');
     } else {
         $params = $this->params = JComponentHelper::getParams('com_quick2cart');
         $guestcheckout = $params->get('guest');
         if ($guestcheckout == 0 && !$user->id) {
             $itemid = $input->get('Itemid');
             // $uri=JRoute::_('index.php?option=com_quick2cart&view=cartcheckout&Itemid=' . $itemid,false);
             $rurl = 'index.php?option=com_quick2cart&view=cartcheckout&Itemid=' . $itemid;
             $returnurl = base64_encode($rurl);
             $mainframe->redirect(JRoute::_('index.php?option=com_users&return=' . $returnurl, false), $msg);
         }
         // GETTING CART ITEMS
         JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models');
         //			$cartmodel = new Quick2cartModelcart;
         //		$cart = $cartmodel->getCartitems();
         // Amol change
         $cartCheckoutModel = new Quick2cartModelcartcheckout();
         $cart = $cartCheckoutModel->getCheckoutCartitemsDetails();
         // Amol change end
         $this->cart = $cart;
         $session = JFactory::getSession();
         $cops = $session->get('coupon');
         if (!empty($cops)) {
             // Check for expiry
             $cop_array = array();
             foreach ($cops as $cop) {
                 $valid_coupan = $model->getcoupon($cop['code']);
                 if (!empty($valid_coupan)) {
                     $cop_array[] = $cop;
                 }
             }
             $this->coupon = $cop_array;
         } else {
             $this->coupon = array();
         }
         $user = JFactory::getUser();
         if ($user->id != 0) {
             $userdata = $model->userdata();
             $this->userdata = $userdata;
         }
         if ($layout == 'payment') {
             $orders_site = '1';
             $orderid = $session->get('order_id');
             $comquick2cartHelper = new comquick2cartHelper();
             $order = $comquick2cartHelper->getorderinfo($orderid);
             if (!empty($order)) {
                 if (is_array($order)) {
                     $this->orderinfo = $order['order_info'];
                     $this->orderitems = $order['items'];
                 } elseif ($order == 0) {
                     $this->undefined_orderid_msg = 1;
                 }
                 // $payhtml = $model->getpayHTML($order['order_info'][0]->processor,$orderid);
                 JLoader::import('payment', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models');
                 $paymodel = new Quick2cartModelpayment();
                 $payhtml = $paymodel->getHTML($order['order_info'][0]->processor, $orderid);
                 $this->payhtml = $payhtml[0];
             } else {
                 $this->undefined_orderid_msg = 1;
             }
             $orders_site = '1';
             $this->orders_site = $orders_site;
             // Make cart empty
             JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models');
             $Quick2cartModelcart = new Quick2cartModelcart();
             $Quick2cartModelcart->empty_cart();
         } else {
             // START Q2C Sample development
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('system');
             // Call the plugin and get the result
             $result = $dispatcher->trigger('OnBeforeq2cCheckoutCartDisplay');
             $beforecart = '';
             if (!empty($result)) {
                 $beforecart = $result[0];
             }
             $this->beforecart = $beforecart;
             $result = $dispatcher->trigger('OnAfterq2cCheckoutCartDisplay');
             $aftercart = '';
             if (!empty($result)) {
                 $aftercart = $result[0];
             }
             $this->aftercart = $aftercart;
             // END Q2C Sample development
             // Q2C Sample development - ADD TAB in ckout page
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('system');
             $result = $dispatcher->trigger('qtcaddTabOnCheckoutPage', array($this->cart));
             $this->addTab = '';
             $this->addTabPlace = '';
             if (!empty($result)) {
                 $this->addTab = $result[0];
                 $this->addTabPlace = !empty($result[0]['tabPlace']) ? $result[0]['tabPlace'] : '';
             }
             // END - Q2C Sample development - ADD TAB in ckout page
             // Trigger plg to add plg after shipping tab
             // GETTING country
             $country = $this->get("Country");
             $this->country = $country;
         }
         // Getting GETWAYS
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('payment');
         // $params->get( 'gateways' ) = array('0' => 'paypal','1'=>'Payu');
         if (!is_array($params->get('gateways'))) {
             $gateway_param[] = $params->get('gateways');
         } else {
             $gateway_param = $params->get('gateways');
         }
         if (!empty($gateway_param)) {
             $gateways = $dispatcher->trigger('onTP_GetInfo', array($gateway_param));
         }
         $this->gateways = $gateways;
     }
     $this->_setToolBar();
     parent::display($tpl);
 }
Пример #2
0
 /**
  *	This function palce the order
  *	@return
  * 		0  = Unable to insert order
  * 		-1 = Email is already Registered.Please Login
  * 		-2 = session expire (cart empty- if someone on ckout page in one tab and logged out from other tab)
  * */
 function store()
 {
     $user = JFactory::getUser();
     $buildadsession = JFactory::getSession();
     $jinput = JFactory::getApplication()->input;
     $data = $jinput->post;
     $orderId = $data->get('order_id', '', "RAW");
     // while placing order
     if (empty($orderId)) {
         $data = $this->recalculateData($data);
         //session expire
         if ($data === -2) {
             return -2;
         }
     }
     // GET BILLING AND SHIPPING ADDRESS
     $bill = $data->get('bill', array(), "ARRAY");
     $ship = $data->get('ship', array(), "ARRAY");
     $qtc_guest_regis = $data->get('qtc_guest_regis', '', "STRING");
     if (!$user->id) {
         $user->id = 0;
         //Register a new User if Checkout Method is Register
         if (!empty($qtc_guest_regis) && $qtc_guest_regis != "guest") {
             $regdata['user_name'] = $bill['email1'];
             $regdata['user_email'] = $bill['email1'];
             JLoader::import('registration', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models');
             $Quick2cartModelregistration = new Quick2cartModelregistration();
             $mesage = $Quick2cartModelregistration->store($regdata);
             if ($mesage) {
                 $user = JFactory::getUser();
                 $userid = $user->id;
             } else {
                 return -1;
             }
         }
     }
     $row = new stdClass();
     $params = JComponentHelper::getParams('com_quick2cart');
     $isAllowedZeroPriceOrder = $params->get('orderWithZeroPrice', 0);
     // Edit from 1page ckout
     if (empty($orderId)) {
         if (empty($isAllowedZeroPriceOrder)) {
             // if FINAL orderPRICE <=0 THEN DONT ALLOW FOR ORDER
             //if ($data->get('final_amt_pay_inputbox') <= 0 || $data->get('total_amt_inputbox') <= 0 || !isset($data->get('gateways')))
             if ($data->get('final_amt_pay_inputbox') <= 0) {
                 return 0;
             }
         }
     }
     // Place order
     $timestamp = date("Y-m-d H:i:s");
     // Get the IP Address
     if (!empty($_SERVER['REMOTE_ADDR'])) {
         $ip = $_SERVER['REMOTE_ADDR'];
     } else {
         $ip = 'unknown';
     }
     $row->payee_id = $user->id;
     $row->user_info_id = $user->id;
     $row->name = $bill['fnam'];
     $row->email = $bill['email1'];
     if (empty($orderId)) {
         //vm:DONT UPDATE THESE THING WHILE UPDATING ORDER (1-PAGE-CKOUT)
         $row->amount = $data->get('final_amt_pay_inputbox');
         $row->original_amount = $data->get('total_amt_inputbox');
         $row->order_tax = $data->get('orderTax', 0);
         $order_tax_details = $data->get('order_tax_details', '');
         $row->order_tax_details = isset($order_tax_details) ? $order_tax_details : json_encode(array());
         $row->order_shipping = $data->get('qtcOrderShipcharges', '', "STRING");
         $order_shipping_details = $data->get('order_shipping_details', '', "STRING");
         //  order level : Save shipping msg for order level shipping method
         $row->order_shipping_details = isset($order_shipping_details) ? $order_shipping_details : json_encode(array());
         $row->coupon_code = $data->get('cop');
     }
     //	$row->coupon_discount 		= $dis_totalamt;//$cdiscount;
     $comment = $data->get('comment', '', 'RAW');
     $row->customer_note = $comment ? nl2br($comment) : '';
     $updateOrderstatus = 0;
     $gtway = $data->get('gateways');
     //	if ZERO ORDER (first time) or on edit
     if (empty($row->amount)) {
         // if ZERO ORDER and EDIT MODE (FOUND $data['order_id']) THEN DONT CHANGE GATEWAY
         $row->status = 'P';
         // ORDER IS NOT PLACED
         if (empty($orderId)) {
             // FIRST TIME AND AMOUT =0 THEN USE FREE CKOUT PAYMENT METHOD
             $updateOrderstatus = 1;
             $row->processor = 'FreeCheckout';
             //$data['gateways']; // vm:what should be place here?
         } else {
             // Order is placed and buyer editing something. Now fetch order price from D.
             // FETCH  ORDER PRICE FRM db
             $orderFinalAMt = (int) $this->getFinalOrderPrice($orderId);
         }
     } else {
         $row->status = 'P';
         // not free product and no geteway then return false
         /*	if (!isset($gtway))
         			{
         				return 0;
         			}
         			$row->processor 		= $gtway;*/
     }
     $row->cdate = $timestamp;
     $row->mdate = $timestamp;
     $row->ip_address = $ip;
     $comquick2cartHelper = new comquick2cartHelper();
     $row->currency = $comquick2cartHelper->getCurrencySession();
     //$row->discount_type 		= $this->discount_type;			@TODO coupon related???
     $row->id = '';
     if (!empty($orderId)) {
         //EDIT ORDER
         $row->id = $insert_order_id = $orderId;
         if (!$this->_db->updateObject('#__kart_orders', $row, 'id')) {
             echo $this->_db->stderr();
             return 0;
         }
     } else {
         if (!$this->_db->insertObject('#__kart_orders', $row, 'id')) {
             echo $this->_db->stderr();
             return 0;
         }
         $insert_order_id = $this->_db->insertid();
     }
     // Code to pad zero's to $insert_order_id and append to prefix and update
     JLoader::import('payment', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models');
     $Quick2cartModelpayment = new Quick2cartModelpayment();
     $prefix = $Quick2cartModelpayment->generate_prefix($insert_order_id);
     $row1 = new stdClass();
     $row1->prefix = $prefix;
     $row1->id = $insert_order_id;
     if (!$this->_db->updateObject('#__kart_orders', $row1, 'id')) {
         echo $this->_db->stderr();
         return 0;
     }
     // Get Cart item detail$taxdataf
     $Quick2cartModelcart = new Quick2cartModelcart();
     $cart_id = $Quick2cartModelcart->getCartId();
     $cart_itemsdata = $Quick2cartModelcart->getCartitems();
     if (empty($orderId)) {
         $this->addSaveOrderItems($insert_order_id, $cart_itemsdata, $data, $updateOrderstatus);
     }
     // Store billing and shipping detail.
     $this->billingaddr($user->id, $data, $insert_order_id);
     //START Q2C Sample development
     $order_obj = array();
     $order_obj['order'] = $row;
     $order_obj['items'] = $cart_itemsdata;
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin("system");
     $result = $dispatcher->trigger("OnAfterq2cOrder", array($order_obj, $data));
     //END Q2C Sample development
     /*
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('system');
     $plgresult = $dispatcher->trigger('qtcAfterCheckoutDetailSave',array($row->id, $data));
     */
     @$comquick2cartHelper->sendordermail($row->id);
     return $insert_order_id;
 }
Пример #3
0
 /**
  * $res is an object
  * */
 function addPayoutEntry($order_id, $txnid, $status, $pg_plugin)
 {
     // GET BUSINESS EMAIL
     $plugin = JPluginHelper::getPlugin('payment', $pg_plugin);
     $pluginParams = json_decode($plugin->params);
     $businessPayEmial = "";
     if (property_exists($pluginParams, 'business')) {
         $businessPayEmial = trim($pluginParams->business);
     } else {
         return array();
     }
     $params = JComponentHelper::getParams('com_quick2cart');
     $send_payments_to_owner = $params->get('send_payments_to_owner', 0);
     if ($pg_plugin == 'adaptive_paypal') {
         $comquick2cartHelper = new comquick2cartHelper();
         $storeHelper = new storeHelper();
         $adaptiveDetails = $storeHelper->getorderItemsStoreInfo($order_id);
         $Quick2cartModelReports = $comquick2cartHelper->loadqtcClass(JPATH_SITE . "/components/com_quick2cart/models/reports.php", 'Quick2cartModelReports');
         $reportStatus = $status == 'C' ? 1 : 0;
         foreach ($adaptiveDetails as $userReport) {
             $Quick2cartModelpayment = new Quick2cartModelpayment();
             $payDetail = $Quick2cartModelpayment->getPayoutId($txnid, $userReport['owner']);
             if (!empty($payDetail) && $payDetail['status'] == $reportStatus) {
                 // payout already present mean $payDetail will not empty AND STATUS is same then dont process.
                 // for new payout,thisl will not process
                 break;
             }
             $post = array();
             $post['id'] = empty($payDetail['id']) ? '' : $payDetail['id'];
             $post['user_id'] = $userReport['owner'];
             $post['payee_name'] = $comquick2cartHelper->getUserName($post['user_id']);
             $post['paypal_email'] = $userReport['store_email'];
             $post['transaction_id'] = $txnid;
             $post['payment_amount'] = $userReport['commissonCutPrice'];
             $post['payout_date'] = date('Y-m-d');
             $post['status'] = $reportStatus;
             $post['payment_comment'] = "adaptive pay";
             $Quick2cartModelReports->savePayout($post);
         }
     }
 }
Пример #4
0
 /**
  * This function add currency exchange info in order's extra field
  *
  * @param   ARRAY  $data  contain orderid,to,from,and currency exchange rate
  *
  * @return  VOID
  */
 public function currencyExchangeMsg($data)
 {
     if (!empty($data)) {
         // Load payment model
         $path = JPATH_SITE . '/components/com_quick2cart/model/payment.php';
         if (!class_exists('Quick2cartModelpayment')) {
             JLoader::load('Quick2cartModelpayment');
         }
         $Quick2cartModelpayment = new Quick2cartModelpayment();
         $order_id = $Quick2cartModelpayment->extract_prefix($data['order_id']);
         // As we dont want to store( see next) in DB
         unset($data['order_id']);
         $comquick2cartHelper = new comquick2cartHelper();
         $q = "SELECT  `extra` FROM  `#__kart_orders` WHERE `id` =" . $order_id;
         $extraFieldData = $comquick2cartHelper->appendExtraFieldData($data, $q, 1);
         $res = new stdClass();
         $res->id = $order_id;
         $res->extra = $extraFieldData;
         $db = JFactory::getDBO();
         // Get previous data if exist
         if (!$db->updateObject('#__kart_orders', $res, 'id')) {
             echo $this->_db->stderr();
             return false;
         }
     }
 }