if (!defined('DS')) { define('DS', '/'); } if (JFile::exists(JPATH_SITE . '/components/com_quick2cart/quick2cart.php')) { $path = JPATH_SITE . '/components/com_quick2cart/helper.php'; if (!class_exists('comquick2cartHelper')) { JLoader::register('comquick2cartHelper', $path); JLoader::load('comquick2cartHelper'); } // Load assets comquick2cartHelper::loadQuicartAssetFiles(); $doc = JFactory::getDocument(); $lang = JFactory::getLanguage(); $lang->load('mod_quick2cart', JPATH_SITE); JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $model = new Quick2cartModelcart(); $cart = $model->getCartitems(); // Trigger onBeforeCartModule $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('onBeforeCartModule'); if (!empty($result)) { $beforecartmodule = $result[0]; } // Trigger onAfterCartModule $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('onAfterCartModule'); if (!empty($result)) { $aftercartdisplay = $result[0]; }
function display($tpl = null) { $comquick2cartHelper = new comquick2cartHelper(); $input = JFactory::getApplication()->input; $layout = $input->get('layout', 'default'); $option = $input->get('option', ''); $this->params = JFactory::getApplication()->getParams('com_quick2cart'); // check for multivender COMPONENT PARAM // vm: commented for task #20773 /* $isMultivenderOFFmsg=$comquick2cartHelper->isMultivenderOFF(); if(!empty($isMultivenderOFFmsg)) { print $isMultivenderOFFmsg; return false; }*/ if ($layout == 'default') { // product page //DECLARATION SECTION $this->client = $client = "com_quick2cart"; $this->pid = 0; $this->item_id = $item_id = $input->get('item_id', ''); JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $model = new Quick2cartModelcart(); if (empty($item_id)) { // # if entry is not present in kart_item return false; } // retrun store_id,role etc with order by role,store_id $this->store_role_list = $comquick2cartHelper->getStoreIds(); // GETTING AUTHORIZED STORE ID $storeHelper = new storeHelper(); $this->store_list = $storeHelper->getuserStoreList(); // GETTING PRICE $this->price = $price = $model->getPrice($item_id, 1); // return array of price //GETTING ITEM COMPLEATE DETAIL (attributes and its option wil get) //$itemDetail=$model->getItemCompleteDetail($item_id); //getting stock min max,cat,store_id $this->itemdetail = $model->getItemRec($item_id); if (!empty($this->itemdetail)) { ///get attributes $this->attributes = $model->getAttributes($item_id); // for RELEATED PROD FROM CATEGORY $product_path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'product.php'; if (!class_exists('productHelper')) { //require_once $path; JLoader::register('productHelper', $product_path); JLoader::load('productHelper'); } $productHelper = new productHelper(); // get free products media file $this->mediaFiles = $productHelper->getProdmediaFiles($item_id); $this->prodFromCat = $productHelper->getSimilarProdFromCat($this->itemdetail->category, $this->item_id); $this->prodFromSameStore = $productHelper->prodFromSameStore($this->itemdetail->store_id, $this->item_id); $this->peopleAlsoBought = $productHelper->peopleAlsoBought($this->item_id); $this->peopleWhoBought = $productHelper->peopleWhoBought($this->item_id); //print_r($this->peopleWhoBought);die; $social_options = ''; $route = $comquick2cartHelper->getProductLink($this->item_id); // Jilke $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('onProductDisplaySocialOptions', array($this->item_id, 'com_quick2cart.productpage', $this->itemdetail->name, $route)); //Call the plugin and get the result if (!empty($result)) { $social_options = $result[0]; } $this->social_options = $social_options; $this->showBuyNowBtn = $productHelper->isInStockProduct($this->itemdetail); } } elseif ($layout == 'popupslide') { $this->item_id = $item_id = $input->get('qtc_prod_id', ''); JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $model = new Quick2cartModelcart(); if (empty($item_id)) { // # if entry is not present in kart_item return false; } $this->itemdetail = $model->getItemRec($item_id); } $this->item = $this->itemdetail; $this->_prepareDocument(); parent::display($tpl); }
} } </script> <div class ="form-horizontal"> <!-- for TITLE/ NAME --> <div class='qtc_title_textbox control-group' > <label for="item_name" class="control-label"><?php echo JHtml::tooltip(JText::_('QTC_PROD_TITLE_DES'), JText::_('QTC_PROD_TITLE'), '', '* ' . JText::_('QTC_PROD_TITLE')); ?> </label> <?php $item_id = !empty($this->item_id) ? $this->item_id : 0; JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $model = new Quick2cartModelcart(); $p_title = ''; if (!empty($this->itemDetail) && $this->itemDetail['name']) { //$p_title = stripslashes($this->itemDetail['name']); $p_title = $this->itemDetail['name']; } ?> <div class="controls"> <input type="text" class="inputbox required" name="item_name" size="1" id="item_name" value="<?php echo $this->escape($p_title); ?> " /> <!-- <input type="hidden" class="inputbox" name="store_id" size="1" id="store_id" value="<?php //echo $store_id; ?>
/** * 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); }
/** * amol changes * Get details of checkout cart items */ function getCheckoutCartItemsDetails() { // GETTING CART ITEMS JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $cartmodel = new Quick2cartModelcart(); $cart = $cartmodel->getCartitems(); foreach ($cart as $key => $rec) { JLoader::import('product', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $quick2cartModelProduct = new quick2cartModelProduct(); $cart[$key]['item_images'] = $quick2cartModelProduct->getProdutImages($rec['item_id']); $productHelper = new productHelper(); // Get cart items attribute details $cart[$key]['prodAttributeDetails'] = $productHelper->getItemCompleteAttrDetail($rec['item_id']); $product_attributes = rtrim($cart[$key]['product_attributes'], ","); if (!empty($product_attributes)) { // Get Cart Item attribute seleted value if ($cart[$key]['product_attributes']) { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select("`cartitemattribute_id`, `itemattributeoption_id`, `cartitemattribute_name`"); $query->from('#__kart_cartitemattributes'); $query->where("itemattributeoption_id IN(" . $product_attributes . ")"); $query->where(" cart_item_id = " . $cart[$key]['id']); $db->setQuery($query); $cart[$key]['product_attributes_values'] = $db->loadObjectList('itemattributeoption_id'); } } } return $cart; }
?> <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert"></button> <?php $create_store_itemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=vendor&layout=createstore'); $createstore = "<a href=\"" . JRoute::_('index.php?option=com_quick2cart&view=vendor&layout=createstore&Itemid=' . $create_store_itemid) . "\"> Click Here</a>"; ?> <strong><?php echo "<br>" . JText::sprintf('QTC_NO_STORE', $createstore); ?> </strong> </div> <?php } else { JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $model = new Quick2cartModelcart(); if (!empty($pid)) { $item_id = $model->getitemid($pid, $client); } /*fetch Minimum/ max /stock item Quantity*/ if (!empty($item_id)) { $minmaxstock = $model->getItemRec($item_id); } $class_nm = 'form-horizontal'; if ($client === 'com_zoo') { $class_nm = ''; } // If article is QTC product then show qtc fields. $showQtcFields = 'display:none;'; if (!empty($itemDetail['item_id'])) { $showQtcFields = '';
<div class="alert alert-error"> <span ><?php echo JText::_('QTC_LOGIN'); ?> </span> </div> </div> </div> <?php return false; } $session = JFactory::getSession(); $document = JFactory::getDocument(); // make cart empty JLoader::import('cart', JPATH_SITE . '/components/com_quick2cart/models'); $Quick2cartModelcart = new Quick2cartModelcart(); $Quick2cartModelcart->empty_cart(); ?> <?php /* $processor=$this->orderinfo[0]->processor; //$comquick2cartHelper->getPluginName() $model = $this->getModel('cartcheckout'); // gettng plugin name which is set in plugin option $plgname=$model->getPluginName($processor); $plgname=!empty($plgname)?$plgname:$processor; if (empty($this->payhtml)) {
/** * This function used to show product's detail's and allow to buy. * * @param integer $pId product id. * @param string $parent client eg com_content etc. * @param array $qtcExtraParam eg array('hideFreeDdownloads'=>true,'hideOriginalPrice'=>true, * 'hideDiscountPrice'=>true,'hideAttributes'=>true) * * @return html. * * @since 1.6 */ public function getBuynow($pId, $parent, $qtcExtraParam = array()) { // LOAD product HELPER $path = JPATH_SITE . '/components/com_quick2cart/helpers/product.php'; if (!class_exists('productHelper')) { // Require_once $path; JLoader::register('productHelper', $path); JLoader::load('productHelper'); } // Require_once (JPATH_SITE . '/components/com_quick2cart/models/cart.php'); $app = JFactory::getApplication(); $html = ''; JLoader::register("quick2cartViewcart", JPATH_SITE . "/components/com_quick2cart/views/cart/view.html.php"); $layout = 'pushtocart'; $view = new quick2cartViewcart(); // $view->_basePath = JPATH_ROOT . '/components/com_quick2cart'; $view->addTemplatePath(JPATH_SITE . '/components/com_quick2cart/views/cart/tmpl'); $view->addTemplatePath(JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_quick2cart/cart'); // JModel::addIncludePath(JPATH_SITE . '/components/com_quick2cart/models/cart.php'); $comparams = JComponentHelper::getParams('com_quick2cart'); JLoader::import('cart', JPATH_SITE . '/components/com_quick2cart/models'); $model = new Quick2cartModelcart(); // $item_id = $model->getitemid($pId, $parent); $itemidAndState = $model->getitemidAndState($pId, $parent); // # if entry is not present in kart_item if (empty($itemidAndState['item_id']) || empty($itemidAndState['state'])) { return false; } $item_id = $itemidAndState['item_id']; // Return array of price $price = $model->getPrice($item_id, 1); $itemAttrDetail = $model->getItemCompleteAttrDetail($item_id); $comquick2cartHelper = new comquick2cartHelper(); $productHelper = new productHelper(); $hasprice = $this->hasAttributePrice($itemAttrDetail); // Get free products media file $mediaFiles = $productHelper->getProdmediaFiles($item_id); $orderWithZeroPrice = $comparams->get('orderWithZeroPrice', 0); $qtcShowBuyNow = 0; if ($orderWithZeroPrice == 0 && ($price > 0 && $hasprice)) { // Product final price has some price and attribute has currency values $qtcShowBuyNow = 1; } $view->assign('price', $price); $view->assign('_basePath', JPATH_SITE . '/components/com_quick2cart'); $view->set('_controller', 'cart'); $view->set('_view', 'cart'); $view->set('_doTask', true); $view->set('hidemenu', true); $view->setModel($model, true); $view->setLayout($layout); $itemdetail = $model->getItemRec($item_id); $showBuyNowBtn = $productHelper->isInStockProduct($itemdetail); $view->assign('showBuyNowBtn', $showBuyNowBtn); $view->assign('stock', $itemdetail->stock); $view->assign('min_quantity', $itemdetail->min_quantity); $view->assign('max_quantity', $itemdetail->max_quantity); $view->assign('slab', $itemdetail->slab); $view->assign('product_id', $pId); $view->assign('parent', $parent); // Get attributes $attributes = $model->getAttributes($item_id); $view->assign('attributes', $attributes); $view->assign('mediaFiles', $mediaFiles); $view->assign('params', $comparams); $view->assign('qtcExtraParam', $qtcExtraParam); ob_start(); $view->display(); $html = ob_get_contents(); ob_end_clean(); return $html; }
/** * Function: updatecart updates the cart and also calculates the tax and shipping charges * * @return json * * @since 1.0.0 */ public function update_cart_item() { $comquick2cartHelper = new comquick2cartHelper(); $input = JFactory::getApplication()->input; $post = $input->post; $data = $post->get('formData', '', 'STRING'); $cart_item_id = $post->get('cart_item_id', '', 'INT'); $item_id = $post->get('item_id', '', 'INT'); // Get parsed form data parse_str($post->get('formData', '', 'STRING'), $formData); // Load cart model /*$item = Array ( [id] => 17 [parent] => com_quick2cart [item_id] => 8 if item_id present then no need of id and parent fields [count] => 1 [options] => 24,23,22,19 ) <pre>$userdata = Array ( [23] => Array ( [itemattributeoption_id] => 23 [type] => Textbox [value] => qqq ) [24] => Array ( [itemattributeoption_id] => 24 [type] => Textbox [value] => www ) ) * */ $itemFromattedDet = array(); $itemFromattedDet['item_id'] = $item_id; $userdata = array(); if (!empty($formData['cartDetail']) && !empty($cart_item_id)) { $newItemDetails = $formData['cartDetail'][$cart_item_id]; $itemFromattedDet['count'] = $newItemDetails['cart_count']; $itemFromattedDet['options'] = ''; // If not empty attribute details if (!empty($newItemDetails['attrDetail'])) { $attrDetail = $newItemDetails['attrDetail']; foreach ($attrDetail as $key => $attr) { if ($attr['type'] == 'Textbox' && !empty($attr['value'])) { $userkey = $attr['itemattributeoption_id']; $userdata[$userkey] = $attr; $itemFromattedDet['options'] .= $attr['itemattributeoption_id'] . ','; } else { $itemFromattedDet['options'] .= $attr['value'] . ','; } } } } $path = JPATH_SITE . "/components/com_quick2cart/models/cart.php"; $comquick2cartHelper->loadqtcClass($path, 'Quick2cartModelcart'); $Quick2cartModelcart = new Quick2cartModelcart(); // Remove last comma if (!empty($itemFromattedDet['options'])) { $tempArray = explode(',', $itemFromattedDet['options']); $tempArray = array_filter($tempArray, "strlen"); $itemFromattedDet['options'] = implode(',', $tempArray); } // Get formated product details (internal) $prod_details = $Quick2cartModelcart->getProd($itemFromattedDet); // If option present if (!empty($prod_details[1])) { // Add user field detail to options $AttrOptions = $prod_details[1]; $prod_details[1] = $comquick2cartHelper->AddUserFieldDetail($AttrOptions, $userdata); } // Update the cart $result = $Quick2cartModelcart->putCartitem('', $prod_details, $cart_item_id); // Validate Result. If added successfully. if (is_numeric($result) && $result == 1) { $msg['status'] = true; $msg['successCode'] = 1; //$msg['message'] = JText::sprintf('COM_QUICK2CART_COMPACT_MSG', $prod_details[0]['name'], $item_count); } else { $msg['status'] = false; $msg['successCode'] = 0; $msg['message'] = $result; } echo json_encode($msg); jexit(); }
public function countCartitems() { $db = JFactory::getDBO(); $Quick2cartModelcart = new Quick2cartModelcart(); $cart_id = $Quick2cartModelcart->getCartId(); if (!isset($cart_id)) { return; } $query = "Select SUM(product_quantity)\n\t\t FROM #__kart_cartitems\n\t\t WHERE cart_id='{$cart_id}' "; $db->setQuery($query); return $db->loadResult(); }
/** * Method to give available shipping mehtods list and its detail for cart items. * * @param object $post Post object . * * @since 2.2 * @return null */ public function getCartItemsShiphDetail($post) { $productHelper = new productHelper(); $itemWiseShipDetail = array(); $shipMethodHtml = ''; $address = new stdClass(); $address->billing_address = $post->get('bill', array(), 'ARRAY'); $address->shipping_address = $post->get('ship', array(), 'ARRAY'); $address->ship_chk = $post->get('ship_chk', 0); $qtcshiphelper = new qtcshiphelper(); $Quick2cartModelcart = new Quick2cartModelcart(); $cartitems = $Quick2cartModelcart->getCartitems(); if (!empty($cartitems)) { foreach ($cartitems as $citem) { // Get item's shipping profile id $profieId = $this->getItemsShipProfileId($citem['item_id']); if (!empty($profieId)) { // Get shipping methods list. $shipMeths = $this->getShipProfileMethods($profieId); if (!empty($shipMeths)) { $shipDetail = array(); $shipMethsDetail = array(); $shipDetail['item_id'] = $citem['item_id']; // Add current cart item detail $shipDetail['itemDetail'] = $citem; foreach ($shipMeths as $meth) { $methodId = $meth['methodId']; // $shipDetail['shippingMeths'] = $qtcshiphelper->getItemsShipMethods($citem['item_id'], $bill, $ship, $citem, $shipMeths); $shipDetail['shippingMeths'][$methodId] = $qtcshiphelper->getItemsShipMethods($citem['item_id'], $address, $citem, $meth); } $itemWiseShipDetail[] = $shipDetail; } } } } $shipMethodHtml = $this->getShipMethodHtml($itemWiseShipDetail); return $shipMethodHtml; }