Beispiel #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);
 }
    echo $this->comquick2cartHelper->getFromattedPrice(number_format($tprice, 2), $order_currency);
    ?>
</span></td>
					</tr>

					<!--discount price -->
					<?php 
    // / if currently vendor specific code (CALLED FROM ::1.sending email to
    // vendor OR 2.viewing vendor it own order details)is NOT running CODE OR
    // vendor specific
    if (!isset($this->vendor_email)) {
        if ($vendor_order_view == 0) {
            $coupon_code = trim($coupon_code);
            if (!empty($coupon_code)) {
                JLoader::import('cartcheckout', JPATH_SITE . '/components/com_quick2cart/models');
                $Quick2cartModelcartcheckout = new Quick2cartModelcartcheckout();
                $dis_totalamt = $Quick2cartModelcartcheckout->afterDiscountPrice($tprice, $coupon_code, $this->orderinfo->payee_id, 'order', $this->orderinfo->id);
                $discount = $tprice - $dis_totalamt;
                ?>
								<tr>
									<td colspan="<?php 
                echo $col;
                ?>
"></td>
									<td class="cartitem_tprice_label" align="left"><strong><?php 
                echo sprintf(JText::_('QTC_PRODUCT_DISCOUNT'), $coupon_code);
                ?>
</strong></td>
									<td class="cartitem_tprice" <?php 
                echo $price_col_style;
                ?>
Beispiel #3
0
 /**
  * $getOriginalPrice is set then product original price will be considered in calculation
  *
  */
 public function getCartitems($getOriginalPrice = 0)
 {
     $comquick2cartHelper = new comquick2cartHelper();
     $currency = $comquick2cartHelper->getCurrencySession();
     $db = JFactory::getDBO();
     //@TODO ask ashwin about this
     $Quick2cartModelcart = new Quick2cartModelcart();
     $cart_id = $Quick2cartModelcart->getCartId();
     if (!isset($cart_id)) {
         return;
     }
     $query = "Select k.cart_item_id as id, \tk.cart_id,k.store_id,i.sku,\n\t\t\t\t\tk.order_item_name as title,\tk.user_info_id,\n\t\t\t\t\tk.cdate,\t\t\t\t\t\tk.mdate,\n\t\t\t\t\tk.product_quantity as qty, \t\tk.product_attribute_names as options,\n\t\t\t\t\tk.item_id, k.product_item_price,k.product_attributes_price,k.product_final_price,k.original_price,k. params,currency,\n\t\t\t\t\tk.product_attributes\n\t\t FROM #__kart_cartitems as k,#__kart_items as i\n\t\t WHERE k.item_id=i.item_id and k.cart_id='{$cart_id}' order by k.`store_id`";
     $db->setQuery($query);
     $cart = $db->loadAssocList();
     foreach ($cart as $key => $rec) {
         $cart[$key]['seller_id'] = JFactory::getUser()->id;
         //@TODO fetch store owner from items table
         // task 1 fetch item price
         $pricearray = "";
         $return_disc = 0;
         $prod_price = $Quick2cartModelcart->getPrice($rec['item_id'], $return_disc, $getOriginalPrice);
         $cart[$key]['amt'] = $prod_price['price'];
         //product_item_price as amt
         // task 2 attribute price
         if (isset($rec['product_attributes']) && $rec['product_attributes']) {
             $totop_price = $Quick2cartModelcart->getCurrPriceFromBaseCurrencyOption($rec['product_attributes']);
             $cart[$key]['opt_amt'] = $totop_price;
             // product_attributes_price as opt_amt*/
         } else {
             $cart[$key]['opt_amt'] = 0;
             // product_attributes_price as opt_amt*/
         }
         // task 3 calculate total m price
         $cart[$key]['tamt'] = ((double) $cart[$key]['amt'] + (double) $cart[$key]['opt_amt']) * (double) $cart[$key]['qty'];
         //product_final_price as tamt
         //  synchronize new item price and its related in cart_item table
         $cart_item = new stdClass();
         $cart_item->cart_item_id = $cart[$key]['id'];
         //as id
         $cart_item->product_quantity = $cart[$key]['qty'];
         $cart_item->product_item_price = $cart[$key]['amt'];
         $cart_item->product_attributes_price = $cart[$key]['opt_amt'];
         if (!empty($rec['params'])) {
             $params = json_decode($rec['params'], true);
             JLoader::import('cartcheckout', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models');
             $Quick2cartModelcartcheckout = new Quick2cartModelcartcheckout();
             if (!empty($params['coupon_code'])) {
                 $coupon = $Quick2cartModelcartcheckout->getcoupon($params['coupon_code']);
                 $coupon = $coupon ? $coupon : array();
                 if (isset($coupon) && $coupon) {
                     if (in_array($cart[$key]['item_id'], $coupon[0]->item_id)) {
                         $camt = -1;
                         $cart[$key]['original_price'] = $cart[$key]['tamt'];
                         $cart_item->original_price = $cart[$key]['original_price'];
                         $coupon[0]->cop_code = $params['coupon_code'];
                         if ($coupon[0]->val_type == 1) {
                             $cval = $coupon[0]->value / 100 * $cart[$key]['tamt'];
                         } else {
                             $cval = $coupon[0]->value;
                             $cval = $cval * $cart[$key]['qty'];
                             /*multiply cop disc with qty*/
                         }
                         $camt = $cart[$key]['tamt'] - $cval;
                         if ($camt <= 0) {
                             $camt = 0;
                         }
                         $cart[$key]['tamt'] = !($camt == -1) ? $camt : $cart[$key]['tamt'];
                     }
                 }
             }
         }
         $cart_item->product_final_price = $cart[$key]['tamt'];
         $cart_item->currency = $comquick2cartHelper->getCurrencySession();
         $db = JFactory::getDBO();
         if ($cart_item->product_item_price != $cart[$key]['product_item_price'] || $cart_item->product_attributes_price != $cart[$key]['product_attributes_price'] || $cart_item->product_final_price != $cart[$key]['product_final_price'] || $cart_item->currency != $cart[$key]['currency']) {
             if (!$db->updateObject('#__kart_cartitems', $cart_item, "cart_item_id")) {
                 echo $this->_db->stderr();
                 return -1;
             }
         }
     }
     return $cart;
 }
Beispiel #4
0
 /**
  * syncOrderItems
  *
  * @param   MIXED    $orderitems  primary key of kart_items table.
  * @param   integer  $user_id     id of user
  * @param   integer  $order_id    order id
  *
  * @since   2.2.2
  *
  * @return  Object list.
  */
 public function syncOrderItems($orderitems, $user_id, $order_id)
 {
     $final_order_price = 0;
     foreach ($orderitems as $item) {
         $finalOrderItemPrice = 0;
         if (!empty($item->params)) {
             // Coupon coupon exist
             $c_code = json_decode($item->params, true);
             if (!empty($c_code['coupon_code'])) {
                 $path = JPATH_SITE . "/components/com_quick2cart/models/cartcheckout.php";
                 if (!class_exists("Quick2cartModelcartcheckout")) {
                     JLoader::register("Quick2cartModelcartcheckout", $path);
                     JLoader::load("Quick2cartModelcartcheckout");
                 }
                 $Quick2cartModelcartcheckout = new Quick2cartModelcartcheckout();
                 $valid = $Quick2cartModelcartcheckout->getcoupon($c_code['coupon_code'], $user_id, "order", $order_id);
                 if (empty($valid)) {
                     unset($c_code['coupon_code']);
                     if (!empty($c_code)) {
                         $params = json_encode($c_code);
                     } else {
                         $params = '';
                     }
                     // INVALID COUPON
                     $db = JFactory::getDBO();
                     $query = " UPDATE  `#__kart_order_item` SET  `product_final_price`=`original_price` ,`params`='" . $params . "' WHERE  `order_item_id` =" . $item->order_item_id;
                     $db->setQuery($query);
                     if (!$db->execute()) {
                         echo $img_ERROR . JText::_("Unable to Alter #__kart_order_item") . $BR;
                         echo $db->getErrorMsg();
                         return false;
                     }
                 } else {
                     // VALID COUPON:UPDATE WITH NEW COP #20712
                 }
             }
         }
         // Getting orderitems final price
         $db = JFactory::getDBO();
         $query = " SELECT  `product_final_price` FROM `#__kart_order_item` WHERE  `order_item_id` =" . $item->order_item_id;
         $db->setQuery($query);
         $finalOrderItemPrice = $db->loadResult();
         $final_order_price = (int) $final_order_price + (int) $finalOrderItemPrice;
     }
     $comquick2cartHelper = new comquick2cartHelper();
     // Vm:commented bz : we r doing after release q2cv2.0
     // $comquick2cartHelper->AfterSyncUpdateOrderDetails($allOrderitemsPrice, $order_id);
 }
Beispiel #5
0
 /** Insert/update the selected attribute option. This function is called while updatating the order.
  *
  * */
 public function insertOptionToOrderItems($optionDetail)
 {
     if (!empty($optionDetail)) {
         $db = JFactory::getDbo();
         $items_opt = new stdClass();
         $dbAction = 'insertObject';
         if (isset($optionDetail['orderitemattribute_id'])) {
             $dbAction = 'updateObject';
             $items_opt->orderitemattribute_id = $optionDetail['orderitemattribute_id'];
         }
         if (isset($optionDetail['order_item_id'])) {
             $items_opt->order_item_id = $optionDetail['order_item_id'];
         }
         if (isset($optionDetail['itemattributeoption_id'])) {
             $items_opt->itemattributeoption_id = $optionDetail['itemattributeoption_id'];
         }
         if (isset($optionDetail['orderitemattribute_name'])) {
             $items_opt->orderitemattribute_name = $optionDetail['orderitemattribute_name'];
         }
         if (isset($optionDetail['orderitemattribute_prefix'])) {
             $items_opt->orderitemattribute_prefix = $optionDetail['orderitemattribute_prefix'];
         }
         // Load model file
         $path = JPATH_SITE . "/components/com_quick2cart/models/cartcheckout.php";
         if (!class_exists("Quick2cartModelcartcheckout")) {
             JLoader::register("Quick2cartModelcartcheckout", $path);
             JLoader::load("Quick2cartModelcartcheckout");
         }
         $Quick2cartModelcartcheckout = new Quick2cartModelcartcheckout();
         // Get option price [currency is referred in this function]
         $items_opt->orderitemattribute_price = $Quick2cartModelcartcheckout->getAttrOptionPrice($optionDetail['itemattributeoption_id']);
         try {
             if (!$db->{$dbAction}('#__kart_order_itemattributes', $items_opt, 'orderitemattribute_id')) {
                 echo $this->_db->stderr();
                 return 0;
             }
             return (array) $items_opt;
             //return $items_opt->orderitemattribute_id;
         } catch (Exception $e) {
             $this->setError($e->getMessage());
         }
     }
 }