コード例 #1
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->params = JComponentHelper::getParams('com_quick2cart');
     $comquick2cartHelper = new comquick2cartHelper();
     $zoneHelper = new zoneHelper();
     // Check whether view is accessible to user
     if (!$zoneHelper->isUserAccessible()) {
         return;
     }
     $qtcshiphelper = new qtcshiphelper();
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $user = JFactory::getUser();
     $layout = $jinput->get('layout', 'default');
     $model = $this->getModel('shipprofileform');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors));
     }
     if ($layout == 'default') {
         $this->state = $this->get('State');
         $this->item = $this->get('Data');
         $this->form = $this->get('Form');
         // Check whether user is authorized for this zone ?
         if (!empty($this->item->store_id)) {
             $status = $comquick2cartHelper->store_authorize('shipprofileform_default', $this->item->store_id);
             if (!$status) {
                 $zoneHelper->showUnauthorizedMsg();
                 return false;
             }
         }
         // Get store name while edit view
         if (!empty($this->item->id) && !empty($this->item->store_id)) {
             $comquick2cartHelper = new comquick2cartHelper();
             $this->storeDetails = $comquick2cartHelper->getSoreInfo($this->item->store_id);
             $this->shipPluglist = $model->getShipPluginListSelect();
         }
         // Get shipping profile_id
         $shipprofile_id = $app->input->get('id', 0);
         // Getting saved tax rules.
         if (!empty($shipprofile_id)) {
             $this->shipMethods = $model->getShipMethods($shipprofile_id);
         }
     } else {
         $this->qtcShipProfileId = $jinput->get('id');
         $this->shipmethId = $jinput->get('shipmethId', 0);
         $shipProfileDetail = $this->shipProfileDetail = $qtcshiphelper->getShipProfileDetail($this->qtcShipProfileId);
         // Getting saved tax rules.
         if (!empty($this->shipmethId) && !empty($shipProfileDetail['store_id'])) {
             // GET PLUGIN DETAIL
             $this->plgDetail = $qtcshiphelper->getPluginDetailByShipMethId($this->shipmethId);
             $this->shipPluglist = $model->getShipPluginListSelect($this->plgDetail['extension_id']);
             // Get plugin shipping methods
             $qtcshiphelper = new qtcshiphelper();
             $this->response = $qtcshiphelper->qtcLoadShipPlgMethods($this->plgDetail['extension_id'], $shipProfileDetail['store_id'], $this->plgDetail['methodId']);
         }
     }
     $this->_prepareDocument();
     parent::display($tpl);
 }
コード例 #2
0
 /**
  * This method handles all ajax related things;
  *
  * @param   object  $jinput  Joomla's jinput Object.
  *
  * @since   1.0
  * @return   Json format result.
  */
 function TjShip_AjaxCallHandler($jinput)
 {
     $post = $jinput->post;
     $qtcshiphelper = new qtcshiphelper();
     $qtczoneShipHelper = new qtczoneShipHelper();
     $ajaxTask = $jinput->get('plugtask');
     if (empty($ajaxTask)) {
         $ajaxTask = $post->get('plugtask');
     }
     switch ($ajaxTask) {
         case "addShipMethRate":
             $result = $qtcshiphelper->addShipMethRate($jinput);
             break;
         case "qtcDelshipMethRate":
             $result = $qtcshiphelper->qtcDelshipMethRate($jinput);
             break;
         case "updateShipMethRate":
             $result = $qtcshiphelper->qtcUpdateShipMethRate($jinput);
             break;
         case "getFieldHtmlForShippingType":
             $fieldData = $jinput->get('fieldData', array(), "ARRAY");
             $result = $qtczoneShipHelper->getFieldHtmlForShippingType($fieldData);
             break;
     }
     // Return json formatted result
     return $result;
 }
コード例 #3
0
ファイル: shipping.php プロジェクト: BetterBetterBetter/B3App
 /**
  * This function calls respective task on respective plugin
  */
 function qtcHandleShipAjaxCall()
 {
     $plgActionRes = '';
     $app = JFactory::getApplication();
     $qtcshiphelper = new qtcshiphelper();
     $comquick2cartHelper = new comquick2cartHelper();
     $jinput = JFactory::getApplication()->input;
     $extension_id = $jinput->get('extension_id');
     // Get plugin detail
     $plugName = $qtcshiphelper->getPluginDetail($extension_id);
     // Call specific plugin trigger
     JPluginHelper::importPlugin('tjshipping', $plugName);
     $dispatcher = JDispatcher::getInstance();
     $plgRes = $dispatcher->trigger('TjShip_AjaxCallHandler', array($jinput));
     if (!empty($plgRes)) {
         $plgActionRes = $plgRes[0];
     }
     echo $plgActionRes;
     $app->close();
 }
コード例 #4
0
 /**
  * Method to add shipping method.
  *
  * @since   2.2
  * @return   null object of shipping method select box.
  */
 public function addShippingPlgMeth($update = 0)
 {
     $app = JFactory::getApplication();
     $data = $app->input->post->get('jform', array(), 'array');
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $query->select('COUNT(*)');
     $query->from('#__kart_shipProfileMethods AS sm');
     if ($update == 1) {
         $data['id'] = $data['qtc_shipProfileMethodId'];
         $query->where('sm.id !=' . $db->escape($data['qtc_shipProfileMethodId']));
     }
     $qtcshiphelper = new qtcshiphelper();
     $data['client'] = $qtcshiphelper->getPluginDetail($data['qtcShipPluginId']);
     $query->where('sm.shipprofile_id=' . $db->escape($data['shipprofile_id']));
     $query->where('sm.client=' . $db->Quote($db->escape($data['client'])));
     $query->where('sm.methodId=' . $db->Quote($db->escape($data['methodId'])));
     $db->setQuery($query);
     $result = $db->loadResult();
     if (!empty($result)) {
         $this->setError(JText::_("COM_QUICK2CART_SHIPMETHOD_ALREADY_EXISTS"));
         return false;
     }
     $table = $this->getTable('Shipmethods');
     if (!$table->bind($data)) {
         $this->setError($table->getError());
         return false;
     }
     if (!$table->check()) {
         $this->setError($table->getError());
         return false;
     }
     if (!$table->store()) {
         $this->setError($table->getError());
         return false;
     }
     $app->input->set('shipMethodId', $table->id);
     return true;
 }
コード例 #5
0
 protected function getShipPluginForm($extension_id)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $qtcshiphelper = new qtcshiphelper();
     $plugName = $qtcshiphelper->getPluginDetail($extension_id);
     $import = JPluginHelper::importPlugin('tjshipping', $plugName);
     $dispatcher = JDispatcher::getInstance();
     $result = $dispatcher->trigger('TjShip_shipBuildLayout', array($jinput));
     if (!empty($result[0])) {
         return $this->form = $result[0];
     }
     return '';
 }
コード例 #6
0
 public function delete($pk = null)
 {
     if ($pk) {
         $qtcshiphelper = new qtcshiphelper();
         // Check whether zone is allowed to delete or not.  If not the enqueue error message accordingly.
         $count_id = $qtcshiphelper->isAllowedToDelShipProfile($pk);
         if ($count_id === true) {
             $this->load($pk);
             $result = parent::delete($pk);
             if ($result) {
             }
             return $result;
         }
     }
     return false;
 }
コード例 #7
0
ファイル: setrates.php プロジェクト: BetterBetterBetter/B3App
/**
 * @version    SVN: <svn_id>
 * @package    Quick2cart
 * @author     Techjoomla <*****@*****.**>
 * @copyright  Copyright (c) 2009-2015 TechJoomla. All rights reserved.
 * @license    GNU General Public License version 2 or later.
 */
// no direct access
defined('_JEXEC') or die;
JHtml::_('behavior.modal');
require_once JPATH_SITE . '/plugins/tjshipping/qtc_default_zoneshipping/qtc_default_zoneshipping/qtczoneShipHelper.php';
$qtczoneShipHelper = new qtczoneShipHelper();
$comquick2cartHelper = new comquick2cartHelper();
$productHelper = new productHelper();
$zoneHelper = new zoneHelper();
$qtcshiphelper = new qtcshiphelper();
$taxHelper = new taxHelper();
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$extension_id = $jinput->get('extension_id');
$methodId = $jinput->get('methodId', 0);
$shipMethDetail = $qtcshiphelper->getShipMethDetail($methodId);
$itemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=vendor&layout=cp');
if (!empty($methodId)) {
    $status = $comquick2cartHelper->store_authorize('', $shipMethDetail['store_id']);
    if (!$status) {
        $zoneHelper->showUnauthorizedMsg();
        return false;
    }
}
?>
コード例 #8
0
 /**
  * Method to give Plugins shipping method.
  *
  * @param   string  $store_id  store for which shipping profile have to select .
  * @param   string  $defaultProfile  default value to be selected .
  *
  * @since   2.2
  * @return   Json Plugin shipping methods list.
  */
 function qtcLoadPlgMethods()
 {
     $app = JFactory::getApplication();
     $extension_id = $app->input->post->get('qtcShipPluginId', 0, "INTEGER");
     $store_id = $app->input->post->get('store_id', 0, "INTEGER");
     $qtcshiphelper = new qtcshiphelper();
     $response = $qtcshiphelper->qtcLoadShipPlgMethods($extension_id, $store_id);
     echo json_encode($response);
     $app->close();
 }
コード例 #9
0
 /**
  * Gives applicable Shipping charges.
  *
  * @param   integer   $subtotal  cart subtotal (after discounted amount )
  * @param   object    $vars      object with cartdetail,billing address and shipping adress details.
  *
  * @since   2.2
  * @return   returns the applicatble shipping charges
  */
 public function afterShipPrice($subtotal, $vars)
 {
     $jinput = JFactory::getApplication()->input;
     $post = $jinput->post;
     $params = JComponentHelper::getParams('com_quick2cart');
     $shippingMode = $params->get('shippingMode', 'itemLevel');
     // @TODO SET ITEM LEVEL AS DEF
     //$shippingMode = $params->get('shippingMode', 'orderLeval');
     if ($shippingMode == "orderLeval") {
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('qtcshipping');
         //@TODO:need to check plugim type..
         $shipresults = $dispatcher->trigger('qtcshipping', array($subtotal, $vars));
         //Call the plugin and get the result
         if (!empty($shipresults[0]['charges']) && is_numeric($shipresults[0]['charges'])) {
             $firstRes = $shipresults[0];
             $charges = (double) $firstRes['charges'];
             $detail = json_encode($firstRes);
             $post->set("order_shipping_details", $detail);
             return $charges;
         }
     } else {
         $shipChargesDetail = array();
         $shipChargesDetail['totCharges'] = 0;
         $shipChargesDetail['itemShipMethDetail'] = array();
         $qtcshiphelper = new qtcshiphelper();
         foreach ($vars->cartItemDetail as $key => $itemDetail) {
             $item_id = $itemDetail['item_id'];
             // If item has shipping methods
             if (isset($vars->selectedItemshipMeth[$item_id])) {
                 $shipMethIdForItem = $vars->selectedItemshipMeth[$item_id];
                 $itemShipMethDetail = $vars->itemsShipMethRateDetail[$shipMethIdForItem];
                 $shipMethod = array();
                 $shipMethod['client'] = $itemShipMethDetail['client'];
                 $shipMethod['methodId'] = $itemShipMethDetail['methodId'];
                 $address = new stdClass();
                 $address->billing_address = $vars->billing_address;
                 $address->shipping_address = $vars->shipping_address;
                 $address->ship_chk = $vars->ship_chk;
                 //	(Recalculate) Get selected shipping method detail.
                 $shipChargesDetail['itemShipMethDetail'][$item_id] = $shippingChargeDetail = $qtcshiphelper->getItemsShipMethods($item_id, $address, $itemDetail, $shipMethod);
                 $vars->cartItemDetail[$key]['itemShipCharges'] = !empty($shippingChargeDetail['totalShipCost']) ? $shippingChargeDetail['totalShipCost'] : $itemShipMethDetail['totalShipCost'];
                 $shipChargesDetail['totCharges'] += $vars->cartItemDetail[$key]['itemShipCharges'];
             }
         }
         $qtcOrderShipcharges = 0;
         if (!empty($shipChargesDetail)) {
             // To add against item row entry
             $post->set('itemShipMethDetail', $shipChargesDetail['itemShipMethDetail']);
             if ($shipChargesDetail['totCharges']) {
                 $qtcOrderShipcharges = $shipChargesDetail['totCharges'];
                 //$shipval = $comquick2cartHelper->calamt($shipval, $shipChargesDetail['totCharges']);
             }
         }
         return $qtcOrderShipcharges;
     }
 }
コード例 #10
0
 /**
  * This method Check method is applicable or not (Min & max amount) etc..
  *
  * @param   object  $vars  gives billing, shipping, item_id, methodId(unique plug shipping method id) etc.
  *
  * @since   2.2
  * @return  Shipping charges.
  */
 function getApplicableShipMethRateDetail($vars, $shipMethDetail)
 {
     // Get zone id from address
     $shipMethId = $vars->shipMethId;
     $shipping_address = $vars->shipping_address;
     // Get item cart detail
     $cartItemDetail = $vars->cartItemDetail;
     $currency = $cartItemDetail['currency'];
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select('mr.id AS rateId');
     $query->from('#__kart_zonerules AS zr');
     $query->join('LEFT', '#__kart_zoneShipMethodRates AS mr ON mr.zone_id = zr.zone_id');
     $query->where('mr.methodId=' . $shipMethId);
     $applicable = 0;
     if (!empty($shipMethDetail)) {
         if ($shipMethDetail['shipping_type'] == 1) {
             // Check wether quantity is within rage
             if ($shipMethDetail['min_value'] <= $cartItemDetail['qty'] && ((int) $shipMethDetail['max_value'] == -1 || $cartItemDetail['qty'] <= $shipMethDetail['max_value'])) {
                 $applicable = 1;
             }
             $query->where('mr.rangeFrom <=' . $cartItemDetail['qty']);
             $query->where('mr.rangeTo >=' . $cartItemDetail['qty']);
         } elseif ($shipMethDetail['shipping_type'] == 2) {
             // ship  method type= weight
             $qtcshiphelper = new qtcshiphelper();
             $productDetail = $vars->productDetail;
             // Get product wt and weight class id
             $itemWt = $productDetail['item_weight'];
             $itemWt = $itemWt * $cartItemDetail['qty'];
             $fromWtClass = $productDetail['item_weight_class_id'];
             // get KG weiht class id
             $toWtClassid = $qtcshiphelper->getWeightDetailFromUnite('kg');
             // Convert item weight
             $newItemWt = (double) $qtcshiphelper->convertWeight($itemWt, $fromWtClass, $toWtClassid['id']);
             // Check whether mehod
             if ((double) $shipMethDetail['min_value'] <= $newItemWt && ((int) $shipMethDetail['max_value'] == -1 || $newItemWt <= (double) $shipMethDetail['max_value'])) {
                 $applicable = 1;
             }
             $query->where('mr.rangeFrom <=' . $newItemWt);
             $query->where('mr.rangeTo >=' . $newItemWt);
             // Get applicable rate
         } else {
             //  For flat rate pers store method. Get methods price rel things
             $methDetail = $this->getPriceRelMethDetail($shipMethId, $currency);
             // For flat rate per store item price.
             if ($methDetail['min_value'] <= $cartItemDetail['tamt'] && ((int) $methDetail['max_value'] == -1 || $cartItemDetail['tamt'] <= $methDetail['max_value'])) {
                 $applicable = 1;
             }
             // Range field are not present for flat rate per store method
         }
     }
     // If method is not applicable
     if ($applicable == 0) {
         return false;
     }
     $query->where('zr.country_id=' . (int) $shipping_address['country']);
     $query->where("( zr.region_id = 0 OR zr.region_id = " . (int) $shipping_address['state'] . ')');
     $db->setQuery($query);
     $rateId = $db->loadResult();
     // If rate is not i.e  not applicable
     if (empty($rateId)) {
         return false;
     }
     // Get method rate details;
     return $shipMethRateDetail = $this->getShipMethRateDetail($rateId, $currency);
 }
コード例 #11
0
 /**
  * This function save checkout data
  *
  * @return  json
  *
  * @since  1.0.0
  */
 public function qtc_autoSave()
 {
     $params = JComponentHelper::getParams('com_quick2cart');
     $isShippingEnabled = $params->get('shipping', 0);
     $shippingMode = $params->get('shippingMode', 'itemLevel');
     $mainframe = JFactory::getApplication();
     $input = JFactory::getApplication()->input;
     $session = JFactory::getSession();
     $post = $input->post;
     $model = $this->getModel('cartcheckout');
     $stepId = $input->get('stepId', '', 'STRING');
     $retdata = array();
     $retdata['stepId'] = $stepId;
     $retdata['payAndReviewHtml'] = '';
     $retdata['camp_id'] = '';
     $retdata['sa_sentApproveMail'] = '';
     $retdata['Itemid'] = '';
     $comquick2cartHelper = new comquick2cartHelper();
     // Trigger: this trigger is called while changing the steps from checkout page
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin("system");
     $result = $dispatcher->trigger("OnAfterQ2cStepChange");
     $Quick2cartControllercartcheckout = new Quick2cartControllercartcheckout();
     $nextstep = '';
     switch ($stepId) {
         case "qtc_cartDetails":
             $nextstep = "fetchBillData";
             break;
         case "qtc_billing":
             if ($isShippingEnabled == 1) {
                 // If order level shippin mode then place order. (No ned to fetch ship detail)
                 if ($shippingMode == "orderLeval") {
                     $nextstep = "fetchPayNdReviewData";
                 } else {
                     $nextstep = "fetchShipData";
                 }
             } else {
                 $nextstep = "fetchPayNdReviewData";
             }
             break;
         case "qtc_shippingStep":
             $nextstep = "fetchPayNdReviewData";
             break;
     }
     if ($nextstep == 'fetchBillData') {
         // Already fetched and rendered on form
     }
     // Clicked on billing
     if ($nextstep == 'fetchShipData') {
         $qtcshiphelper = new qtcshiphelper();
         $shippingHtml = $qtcshiphelper->getCartItemsShiphDetail($post);
         $retdata['shipMethoDetail'] = $shippingHtml;
     }
     // Save ad qtc_billing data
     if ($nextstep == 'fetchPayNdReviewData') {
         $response = $Quick2cartControllercartcheckout->save();
         $retdata['payAndReviewHtml'] = !empty($response['orderHTML']) ? $response['orderHTML'] : '';
         $retdata['order_id'] = !empty($response['order_id']) ? $response['order_id'] : 0;
     }
     echo json_encode($retdata);
     jexit();
 }
コード例 #12
0
ファイル: product.php プロジェクト: BetterBetterBetter/B3App
 /**
  * Method to give availale shipprofile against store.
  *
  * @since   2.2
  * @return   Json Plugin shipping methods list.
  */
 function qtcUpdateShipProfileList()
 {
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $store_id = $jinput->get('store_id', 0, "INTEGER");
     $qtcshiphelper = new qtcshiphelper();
     $response['selectList'] = $qtcshiphelper->qtcLoadShipProfileSelectList($store_id, '');
     echo json_encode($response);
     $app->close();
 }
コード例 #13
0
 /**
  * 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;
 }