コード例 #1
0
ファイル: config.php プロジェクト: aldegtyarev/stelsvelo
 public static function tableExists()
 {
     static $ret;
     if (isset($ret)) {
         return $ret;
     }
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $ret = OPCmini::tableExists('onepage_config');
     return $ret;
 }
コード例 #2
0
ファイル: pickup.php プロジェクト: aldegtyarev/stelsvelo
    function store()
    {
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        if (!OPCmini::tableExists('virtuemart_shipment_plg_pickup_or_free_conf')) {
            $db = JFactory::getDBO();
            $q = '
	
CREATE TABLE IF NOT EXISTS `#__virtuemart_shipment_plg_pickup_or_free_conf` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `from` int(11) NOT NULL,
  `to` int(11) NOT NULL,
  `route` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci AUTO_INCREMENT=1 ;';
            $db->setQuery($q);
            $db->query();
            $e = $db->getErrorMsg();
            if (!empty($e)) {
                return $e;
            }
        }
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'models' . DS . 'config.php';
        /*	
        if (!OPCJ3)
        	{
        	 require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_onepage'.DS.'helpers'.DS.'opcparameters.php'); 
        	}
        	else
        	{
        
        	}
        */
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'jformrender.php';
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
        $config = new JModelConfig();
        $config->loadVmConfig();
        $files = $config->getPhpTrackingThemes();
        $statuses = $config->getOrderStatuses();
        $data = JRequest::get('post');
        jimport('joomla.filesystem.file');
        return;
    }
コード例 #3
0
ファイル: tos.php プロジェクト: aldegtyarev/stelsvelo
 public static function getTosRequired(&$ref, &$OPCloader)
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $userFieldsModel = OPCmini::getModel('Userfields');
     // new VirtueMartModelUserfields();
     if ($userFieldsModel->getIfRequired('agreed')) {
         if (!class_exists('VmHtml')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
         }
         $tos_required = true;
     } else {
         $tos_required = false;
     }
     $l = OPCloader::logged($ref->cart);
     if (!empty($l)) {
         // logged
         if (!empty($tos_logged)) {
             return true;
         }
         if (!isset($tos_logged)) {
             return $tos_required;
         } else {
             return !empty($tos_logged);
         }
     } else {
         if (!empty($tos_unlogged)) {
             return true;
         }
         if (!isset($tos_unlogged)) {
             return $tos_required;
         }
         return !empty($tos_unlogged);
     }
     return $tos_required;
 }
コード例 #4
0
ファイル: opc.php プロジェクト: aldegtyarev/stelsvelo
 /**
  * This function just gets the post data and put the data if there is any to the cart
  *
  * @author Max Milbers
  *
  * this is from user model 
  */
 function saveToCart($data, $cart = null)
 {
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $userFieldsModel = OPCmini::getModel('userfields');
     $prepareUserFields = $userFieldsModel->getUserFieldsFor('cart', $data['address_type']);
     if (!empty($prepareUserFields)) {
         foreach ($prepareUserFields as $fld) {
             $name = $fld->name;
             if ($data['address_type'] == 'BT') {
                 if (isset($cart) && !empty($cart->BT[$name])) {
                     $data[$name] = $cart->BT[$name];
                 }
             }
             if ($data['address_type'] == 'ST') {
                 if (isset($cart) && !empty($cart->ST[$name])) {
                     $data[$name] = $cart->ST[$name];
                 }
             }
             // we need to add empty values for checkboxes and radios
             if ($data['address_type'] == 'ST') {
                 if (!isset($data['shipto_' . $name])) {
                     $data['shipto_' . $name] = '';
                 }
             }
             if (isset($cart) && empty($cart->BT[$name])) {
                 if ($data['address_type'] == 'BT') {
                     if (!isset($data[$name])) {
                         $data[$name] = '';
                     }
                 }
             }
         }
     }
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!isset($cart)) {
         $cart = VirtueMartCart::getCart();
     }
     if (method_exists($cart, 'prepareCartData')) {
         $cart->prepareCartData(false);
     }
     $type = $data['address_type'];
     $oldcart = clone $cart;
     if ($type === 'BT') {
         $prefix = '';
     } else {
         $prefix = 'shipto_';
     }
     if (defined('VM_VERSION') && VM_VERSION >= 3) {
         $cart->saveAddressInCart($data, $type, true, $prefix);
     } else {
         $cart->saveAddressInCart($data, $type);
     }
     //$cart->saveAddressInCart($data, $type );
     if (isset($oldcart->{$type})) {
         foreach ($oldcart->{$type} as $key => $val) {
             if (empty($cart->{$type}[$key])) {
                 $cart->{$type}[$key] = $val;
             }
         }
     }
     $sa = JRequest::getVar('sa', '');
     if ($sa == 'adresaina') {
         /*
         		
         		stAn -> this works as well - will update ST for VM3
         		
         		$ndata = $data; 
         		
         		
         		foreach ($data as $key=>$val)
         		 {
         		    
         		    if (substr($key, 0, 7)==='shipto_')
         			 {
         			     $nk = substr($key, 7); 
         			     //echo 'subst: '.$nk." ".$val."<br />\n"; 
         			   
         				$ndata[$nk] = $val; 
         				
         				
         			 }
         		 }
         */
         if (defined('VM_VERSION') && VM_VERSION >= 3) {
             $cart->saveAddressInCart($data, 'ST', true, 'shipto_');
         } else {
             $cart->saveAddressInCart($data, 'ST');
         }
         if (isset($oldcart->ST)) {
             foreach ($oldcart->ST as $key => $val) {
                 if (empty($cart->ST[$key])) {
                     $cart->ST[$key] = $val;
                 }
             }
         }
     } else {
         $cart->STsameAsBT = 1;
     }
     $cart->setCartIntoSession();
 }
コード例 #5
0
 /**
  * Test userdata if valid
  *
  * @author Max Milbers
  * @param String if BT or ST
  * @param Object If given, an object with data address data that must be formatted to an array
  * @return redirectMsg, if there is a redirectMsg, the redirect should be executed after
  */
 function validateUserData($type = 'BT', $obj = null, $cart = null)
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     // we disable validation for ST address, because it is still missing at the front-end and shall be added as an optional feature
     if ($type == 'ST') {
         return false;
     }
     require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php';
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $userFieldsModel = OPCmini::getModel('userfields');
     if ($type == 'BT') {
         $fieldtype = 'account';
     } else {
         $fieldtype = 'shipment';
     }
     if ($type == 'BT') {
         if (empty($bt_fields_from)) {
             $fieldtype = 'registration';
         } else {
             if ($bt_fields_from === 1) {
                 $fieldtype = 'account';
             } else {
                 $fieldtype = 'cart';
             }
         }
     }
     $neededFields = $userFieldsModel->getUserFields($fieldtype, array('required' => true, 'delimiters' => true, 'captcha' => true, 'system' => false), array('delimiter_userinfo', 'name', 'username', 'password', 'password2', 'address_type_name', 'address_type', 'user_is_vendor', 'agreed'));
     $redirectMsg = false;
     $i = 0;
     $missing = '';
     foreach ($neededFields as $field) {
         $is_business = JRequest::getVar('opc_is_business', 0);
         // we need to alter shopper group for business when set to:
         $is_business = JRequest::getVar('opc_is_business', 0);
         if (!empty($business_fields)) {
             if (!$is_business) {
                 // do not check if filled
                 if (in_array($field->name, $business_fields)) {
                     continue;
                 }
             }
         }
         if ($type == 'ST') {
             if (!empty($shipping_obligatory_fields)) {
                 if (!in_array($field->name, $shipping_obligatory_fields)) {
                     continue;
                 }
             }
         }
         // manage required business fields when not business selected:
         //foreach ($business_fields as $fn)
         if ($field->required && empty($cart->{$type}[$field->name]) && $field->name != 'virtuemart_state_id') {
             $redirectMsg = JText::sprintf('COM_VIRTUEMART_MISSING_VALUE_FOR_FIELD', JText::_($field->title));
             $i++;
             //more than four fields missing, this is not a normal error (should be catche by js anyway, so show the address again.
             if ($i > 2 && $type == 'BT') {
                 $missing .= JText::_($field->title);
                 $redirectMsg = JText::_('COM_VIRTUEMART_CHECKOUT_PLEASE_ENTER_ADDRESS');
             }
         }
         if ($obj !== null && is_array($cart->{$type})) {
             $cart->{$type}[$field->name] = $obj->{$field->name};
         }
         //This is a special test for the virtuemart_state_id. There is the speciality that the virtuemart_state_id could be 0 but is valid.
         if ($field->name == 'virtuemart_state_id') {
             if (!class_exists('VirtueMartModelState')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'state.php';
             }
             if (!empty($cart->{$type}['virtuemart_country_id']) && !empty($cart->{$type}['virtuemart_state_id'])) {
                 if (!($msg = VirtueMartModelState::testStateCountry($cart->{$type}['virtuemart_country_id'], $cart->{$type}['virtuemart_state_id']))) {
                     $redirectMsg = $msg;
                 }
             }
         }
     }
     if (empty($redirectMsg)) {
         return false;
     }
     $redirectMsg .= ' ' . $missing;
     return $redirectMsg;
 }
コード例 #6
0
ファイル: thankyou.php プロジェクト: aldegtyarev/stelsvelo
 public static function updateHtml($html, &$order, $afterrender = false)
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
     $ty_page = OPCconfig::getValue('ty_page', 'ty_page', 0, array());
     if (empty($ty_page)) {
         return;
     }
     if (empty($order)) {
         return;
     }
     if (is_array($order)) {
         if (isset($order['details'])) {
             $order = $order['details']['BT'];
         }
     }
     //we must reload order here in case any plugin had changed it in meantime:
     $id = $order->virtuemart_order_id;
     if (!empty($id)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
         $orderModel = OPCmini::getModel('orders');
         $order_full = $orderModel->getOrder($id);
         if (empty($order_full)) {
             return;
         }
         $order = $order_full['details']['BT'];
     }
     $status = $order->order_status;
     if (!is_object($order)) {
         return;
     }
     $payment_id = $order->virtuemart_paymentmethod_id;
     if (empty($order->order_language)) {
         $jlang = JFactory::getLanguage();
         $cl = $jlang->getTag();
         $cl = strtolower(str_replace('-', '_', $cl));
     } else {
         $cl = $order->order_language;
     }
     // check conditions:
     $orightml = $html;
     $todo = array();
     foreach ($ty_page as $k => $ty) {
         if (!is_object($ty)) {
             continue;
         }
         if ($ty->payment_id != $payment_id) {
             continue;
         }
         if (!empty($ty->language)) {
             if ($ty->language != $cl) {
                 continue;
             }
         }
         if ($ty->order_status != $status) {
             continue;
         }
         $todo[] = $ty;
     }
     if (empty($todo)) {
         return;
     }
     /*
     	  COM_ONEPAGE_TY_MODE_0="Prepend to payment generated html"
     COM_ONEPAGE_TY_MODE_1="Append to payment generated html"
     COM_ONEPAGE_TY_MODE_2="Replace payment generated html"
     */
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php';
     $repvals = array();
     $order_object = new stdClass();
     OPCtrackingHelper::getOrderVars($id, $repvals, $order_object, false);
     foreach ($todo as $ty2) {
         $htmla = OPCloader::getArticle($ty2->article_id, $repvals);
         if (empty($ty2->mode)) {
             $html = $htmla . '<br />' . $html;
         } else {
             if ($ty2->mode == 1) {
                 $html = $html . '<br />' . $htmla;
             } else {
                 if ($ty->mode == 2) {
                     $html = $htmla;
                 }
             }
         }
     }
     if (defined('TYMODDONE')) {
         return $html;
     } else {
         define('TYMODDONE', true);
     }
     if ($orightml != $html) {
         if (!$afterrender) {
             JRequest::setVar('html', $html);
         } else {
             $buffer = JResponse::getBody();
             $buffer = str_replace($orightml, $html, $buffer);
             JResponse::setBody($buffer);
         }
     }
     return $html;
 }
コード例 #7
0
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * Okey I try now a completly new idea.
  * We make a function for every tab and the display is getting the right tabs by an own function
  * putting that in an array and after that we call the preparedataforlayoutBlub
  *
  * @author Oscar van Eijk
  * @author Max Milbers
  *
  *  Original code from: \components\com_virtuemart\views\user\view.html.php
  *
  */
 function display($tpl = null)
 {
     $useSSL = VmConfig::get('useSSL', 0);
     $useXHTML = true;
     $this->assignRef('useSSL', $useSSL);
     $this->assignRef('useXHTML', $useXHTML);
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     if (!defined('OPC_IN_REGISTRATION_MODE')) {
         define('OPC_IN_REGISTRATION_MODE', 1);
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     OPCLang::loadLang();
     $this->loadOPC();
     // 	vmdebug('layout by view '.$layoutName);
     if (empty($layoutName) or $layoutName == 'default') {
         $layoutName = JRequest::getWord('layout', 'edit');
         if ($layoutName == 'default') {
             $layoutName = 'edit';
         }
         $this->setLayout($layoutName);
     }
     if (empty($this->fTask)) {
         $ftask = 'saveUser';
         $this->assignRef('fTask', $ftask);
     }
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     // 	vmdebug('my layoutname',$layoutName);
     if ($layoutName == 'login') {
         parent::display($tpl);
         return;
     }
     if (!class_exists('VirtuemartModelUser')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'user.php';
     }
     $this->_model = new VirtuemartModelUser();
     //		$this->_model->setCurrent(); //without this, the administrator can edit users in the FE, permission is handled in the usermodel, but maybe unsecure?
     $editor = JFactory::getEditor();
     //the cuid is the id of the current user
     $this->_currentUser = JFactory::getUser();
     $this->_cuid = $this->_lists['current_id'] = $this->_currentUser->get('id');
     $this->assignRef('userId', $this->_cuid);
     $this->_userDetails = $this->_model->getUser();
     $this->assignRef('userDetails', $this->_userDetails);
     $address_type = JRequest::getWord('addrtype', 'BT');
     $this->assignRef('address_type', $address_type);
     //New Address is filled here with the data of the cart (we are in the cart)
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $new = false;
     if (JRequest::getInt('new', '0') == 1) {
         $new = true;
     }
     if ($new) {
         $virtuemart_userinfo_id = 0;
     } else {
         $virtuemart_userinfo_id = JRequest::getString('virtuemart_userinfo_id', '0', '');
         if (empty($virtuemart_userinfo_id)) {
             require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php';
             $umodel = OPCmini::getModel('user');
             //new VirtuemartModelUser();
             $uid = JFactory::getUser()->id;
             $userDetails = $umodel->getUser();
             $virtuemart_userinfo_id = $umodel->getBTuserinfo_id();
         }
     }
     $this->assignRef('virtuemart_userinfo_id', $virtuemart_userinfo_id);
     $userFields = null;
     if ((strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) && empty($virtuemart_userinfo_id)) {
         $fieldtype = $address_type . 'address';
         if (method_exists($cart, 'prepareAddressDataInCart')) {
             $cart->prepareAddressDataInCart($address_type, $new);
         }
         if (method_exists($cart, 'prepareAddressFieldsInCart')) {
             $cart->prepareAddressFieldsInCart();
         }
         $userFields = $cart->{$fieldtype};
         $task = JRequest::getWord('task', '');
     } else {
         $userFields = $this->_model->getUserInfoInUserFields($layoutName, $address_type, $virtuemart_userinfo_id);
         if (!$new && empty($userFields[$virtuemart_userinfo_id])) {
             $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id();
             // 			vmdebug('Try to get $virtuemart_userinfo_id by type BT', $virtuemart_userinfo_id);
         }
         $userFields = $userFields[$virtuemart_userinfo_id];
         $task = 'editaddressST';
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'loader.php';
     /*
     if (!class_exists('VirtueMartCart'))
     	require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
     $this->cart = VirtueMartCart::getCart(); 
     */
     $OPCloader = new OPCloader();
     OPCloader::setRegType();
     $action_url = JURI::root(true) . '/index.php?option=com_onepage&amp;view=opc&amp;controller=opc&amp;task=opcregister&amp;nosef=1';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'javascript.php';
     OPCJavascript::getJavascript($this, $OPCloader, false, $action_url, 'com_onepage', 'opcregister');
     $OPCloader->customizeFieldsPerOPCConfig($userFields);
     OPCloader::loadJavascriptFiles($this);
     $op_formvars = OPCloader::getFormVars($this);
     /*
     	foreach ($userFields['fields'] as $key=>$val)
     {
        if (isset($val['formcode']))
     		{
     		
     		  $val['formcode'] .= $html; 
     		  break; 
     		  
     		}
     }
     */
     $this->assignRef('userFields', $userFields);
     if ($layoutName == 'edit') {
         if ($this->_model->getId() == 0 && $this->_cuid == 0) {
             $button_lbl = JText::_('COM_VIRTUEMART_REGISTER');
         } else {
             $button_lbl = JText::_('COM_VIRTUEMART_SAVE');
         }
         $this->assignRef('button_lbl', $button_lbl);
         $this->lUser();
         if (JVM_VERSION <= 2) {
             $this->shopper($userFields);
         } else {
             $this->shopper3($userFields);
         }
         $this->payment();
         $this->lOrderlist();
         $this->lVendor();
     }
     $this->_lists['shipTo'] = $this->generateStAddressList($this, $this->_model, $task, $cart);
     if ($this->_openTab < 0) {
         $_paneOffset = array();
     } else {
         if (defined('__VM_USER_USE_SLIDERS')) {
             $_paneOffset = array('startOffset' => $this->_openTab, 'startTransition' => 1, 'allowAllClose' => true);
         } else {
             $_paneOffset = array('startOffset' => $this->_openTab);
         }
     }
     // Implement the Joomla panels. If we need a ShipTo tab, make it the active one.
     // In tmpl/edit.php, this is the 4th tab (0-based, so set to 3 above)
     jimport('joomla.html.pane');
     $pane = OPCPane::getInstance(defined('__VM_USER_USE_SLIDERS') ? 'Sliders' : 'Tabs', $_paneOffset);
     $this->assignRef('lists', $this->_lists);
     $this->assignRef('editor', $editor);
     $this->assignRef('pane', $pane);
     if ($layoutName == 'mailregisteruser') {
         $vendorModel = VmModel::getModel('vendor');
         //			$vendorModel->setId($this->_userDetails->virtuemart_vendor_id);
         $vendor = $vendorModel->getVendor();
         $this->assignRef('vendor', $vendor);
     }
     if ($layoutName == 'editaddress') {
         $layoutName = 'edit_address';
         $this->setLayout($layoutName);
     }
     if (!$this->userDetails->JUser->get('id')) {
         $corefield_title = JText::_('COM_VIRTUEMART_USER_CART_INFO_CREATE_ACCOUNT');
     } else {
         $corefield_title = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     }
     if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) {
         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
     } else {
         //$pathway->addItem(JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'), JRoute::_('index.php?option=com_virtuemart&view=user&&layout=edit'));
     }
     $pathway_text = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     if (!$this->userDetails->JUser->get('id')) {
         if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) {
             if ($address_type == 'BT') {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
             } else {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         } else {
             if ($address_type == 'BT') {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
                 $title = JText::_('COM_VIRTUEMART_REGISTER');
             } else {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         }
     } else {
         if ($address_type == 'BT') {
             $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL');
         } else {
             $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
         }
     }
     $add_product_link = "";
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php';
     if (OPCmini::isSuperVendor()) {
         $add_product_link = JRoute::_('/index.php?option=com_virtuemart&tmpl=component&view=product&view=product&task=edit&virtuemart_product_id=0');
         $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_ADD_PRODUCT', 'new', false, false, true, true);
     }
     $this->assignRef('add_product_link', $add_product_link);
     $document = JFactory::getDocument();
     $document->setTitle($pathway_text);
     $pathway->additem($pathway_text);
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->assignRef('page_title', $pathway_text);
     $this->assignRef('corefield_title', $corefield_title);
     $this->assignRef('vmfield_title', $vmfield_title);
     //   if ($onlyindex) return JURI::root(true).'/index.php';
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     require_once JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'removemsgs.php';
     OPCremoveMsgs::removeMsgs($cart);
     $jsvalidator = $OPCloader->getJSValidatorScript($this);
     $op_userfields = $OPCloader->getBTfields($this);
     $registration_html = $OPCloader->getRegistrationHhtml($this);
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'commonhtml.php';
     $reg_html = OPCCommonHtml::getFormVarsRegistration($OPCloader);
     $op_formvars = $reg_html . $jsvalidator;
     $op_userfields .= $op_formvars;
     $onsubmit = $op_onclick = $OPCloader->getJSValidator($this);
     $op_onclick = ' onclick="' . $op_onclick . '" ';
     ob_start();
     //parent::display($tpl);
     include_once JPATH_OPC . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'registration_templates.php';
     $html = ob_get_clean();
     //$html = str_replace('"com_virtuemart"', '"com_onepage"', $html);
     //$html = str_replace('=com_virtuemart', '=com_onepage', $html);
     $this->getActions($html);
     $html = $OPCloader->addListeners($html);
     echo $html;
     $extras = $OPCloader->getExtras($this);
     echo $extras;
 }
コード例 #8
0
ファイル: mini.php プロジェクト: aldegtyarev/stelsvelo
 public static function getModel($model)
 {
     // make sure VM is loaded:
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
         VmConfig::loadConfig();
     }
     if (empty(OPCmini::$modelCache)) {
         OPCmini::$modelCache = array();
     }
     if (!empty(OPCmini::$modelCache[$model])) {
         return OPCmini::$modelCache[$model];
     }
     if (!class_exists('VirtueMartModel' . ucfirst($model))) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . strtolower($model) . '.php';
     }
     if (method_exists('VmModel', 'getModel')) {
         $Omodel = VmModel::getModel($model);
         OPCmini::$modelCache[$model] = $Omodel;
         return $Omodel;
     } else {
         // this section loads models for VM2.0.0 to VM2.0.4
         $class = 'VirtueMartModel' . ucfirst($model);
         if (class_exists($class)) {
             if ($class == 'VirtueMartModelUser') {
                 //require_once(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'overrides'.DS.'user.php');
                 //$class .= 'Override';
                 $Omodel = new VirtueMartModelUser();
                 return $Omodel;
                 $Omodel->setMainTable('virtuemart_vmusers');
             }
             $Omodel = new $class();
             OPCmini::$modelCache[$model] = $Omodel;
             return $Omodel;
         } else {
             echo 'Class not found: ' . $class;
             $app = JFactory::getApplication()->close();
         }
     }
     echo 'Model not found: ' . $model;
     $app = JFactory::getApplication()->close();
     //return new ${'VirtueMartModel'.ucfirst($model)}();
 }
コード例 #9
0
 public static function removeShopperGroups($arr)
 {
     return;
     if (!class_exists('VirtueMartModelShopperGroup')) {
         if (file_exists(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'shoppergroup.php')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'shoppergroup.php';
         } else {
             return 1;
         }
     }
     if (!method_exists('VirtueMartModelShopperGroup', 'appendShopperGroups')) {
         return 1;
     }
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $shoppergroupmodel = OPCmini::getModel('ShopperGroup');
     //new VirtueMartModelShopperGroup();
     $session = JFactory::getSession();
     $shoppergroup_ids = $session->get('vm_shoppergroups_add', array(), 'vm');
     /*
     foreach ($arr as $id)
      {
         if (in_array($id, $shoppergroup_ids))
     		  {
     		     
     		  }
      }
     */
 }
コード例 #10
0
 public static function getSTHtml(&$cart)
 {
     $html = '';
     $stId = JRequest::getVar('ship_to_info_id', 0);
     $stId = (int) $stId;
     if (!empty($stId)) {
         $user_id = JFactory::getUser()->get('id');
         if (!empty($user_id)) {
             $db = JFactory::getDBO();
             $q = 'select * from #__virtuemart_userinfos where virtuemart_userinfo_id = ' . $db->escape($stId) . ' limit 0,1';
             $db->setQuery($q);
             $adr1 = $db->loadObject();
             if (!empty($adr1)) {
                 if ($adr1->virtuemart_user_id == $user_id) {
                     /*
                     			   $new_adr1 = new stdClass(); 
                     			   foreach ($adr1 as $key=>$val)
                     			    {
                       $new_adr1->$key = $val; 
                     }
                     */
                     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
                     $umodel = OPCmini::getModel('user');
                     //new VirtuemartModelUser();
                     $virtuemart_userinfo_id = 0;
                     $currentUser = JFactory::getUser();
                     $uid = $currentUser->get('id');
                     $userDetails = $umodel->getUser();
                     $virtuemart_userinfo_id = $umodel->getBTuserinfo_id();
                     $userFields = $umodel->getUserInfoInUserFields('default', 'BT', $virtuemart_userinfo_id);
                     $userFields = $umodel->getUserInfoInUserFields('default', 'ST', $stId);
                     /*
                      */
                     if (method_exists($cart, 'prepareAddressDataInCart')) {
                         $cart->prepareAddressDataInCart('ST', 1);
                     }
                     if (method_exists($cart, 'prepareAddressFieldsInCart')) {
                         $cart->prepareAddressFieldsInCart();
                     }
                     if (isset($cart->STaddress['fields'])) {
                         $BTaddress = $cart->STaddress['fields'];
                     } else {
                         $BTaddress = $cart->BTaddress['fields'];
                     }
                     $new_address_link = '#" onclick="return Onepage.op_showEditST();';
                     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
                     $OPCloader = new OPCloader();
                     $BTaddressNamed = $OPCloader->setCountryAndState($BTaddress);
                     $html = self::renderNamed($BTaddressNamed, $adr1, $cart, $OPCloader, $virtuemart_userinfo_id, true);
                 }
             }
         }
     }
     return $html;
 }
コード例 #11
0
ファイル: onepage.php プロジェクト: aldegtyarev/stelsvelo
    $caching = JCache::getInstance('page', $options);
    $caching->setCaching(false);
}
$task = JRequest::getVar('task', '');
if ($task === 'opcregister') {
    require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'controllers' . DS . 'opc.php';
    $opc = new VirtueMartControllerOpc();
    $opc->opcregister();
    $app = JFactory::getApplication();
    $app->close();
} else {
    if ($task === 'loadjs') {
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        $file = JRequest::getVar('file', '');
        if (!empty($file)) {
            OPCmini::loadJSfile($file);
            $app = JFactory::getApplication();
            $app->close();
            die;
        }
    } else {
        if ($task === 'ping') {
            require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php';
            OPCtrackingHelper::ping();
            $app = JFactory::getApplication();
            $app->close();
            die;
        }
    }
}
//index.php?option=com_onepage&task=loadjs&file=onepage.js
コード例 #12
0
ファイル: commonhtml.php プロジェクト: aldegtyarev/stelsvelo
    public static function getStateList(&$ref)
    {
        /*
            if (!class_exists('VirtueMartModelState'))
            require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'state.php'); 
            if (!class_exists('VirtueMartModelCountry'))
        	require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'country.php'); 
        */
        $db = JFactory::getDBO();
        $q = 'select count(*) as count from #__virtuemart_states where 1';
        $db->setQuery($q);
        $count = $db->loadResult();
        $js_filename = 'opc_states_' . VMLANG . '_' . $count . '.js';
        $js_file = JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'dynamic_scripts' . DS . $js_filename;
        $js_path = 'components/com_onepage/config/dynamic_scripts/';
        $js = ' var OPCStates = { ' . "\n";
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        $countryModel = OPCmini::getModel('country');
        //new VirtueMartModelCountry();
        $list = $countryModel->getCountries(true, true, false);
        $countries = array();
        $states = array();
        $stateModel = OPCmini::getModel('state');
        //new VirtueMartModelState();
        // if state is set in BT, let's make it default
        if (!empty($ref->cart->BT) && !empty($ref->cart->BT['virtuemart_state_id'])) {
            $cs = $ref->cart->BT['virtuemart_state_id'];
        } else {
            $cs = '';
        }
        //$html = '<div style="display: none;">';
        $counts = count($list);
        $ci = 0;
        foreach ($list as $c) {
            if (empty($c->published)) {
                continue;
            }
            $ci++;
            $states[$c->virtuemart_country_id] = $stateModel->getStates($c->virtuemart_country_id, true, true);
            unset($state);
            //$html .= '<input type="hidden" name="opc_state_list" id="state_for_'.$c->virtuemart_country_id.'" value="" />';
            if (!empty($states[$c->virtuemart_country_id])) {
                $js .= ' state_for_' . $c->virtuemart_country_id . ': { ' . "\n";
                //$html .= '<select id="state_for_'.$c->virtuemart_country_id.'">';
                //$html .= '<option value="">'.OPCLang::_('COM_VIRTUEMART_LIST_EMPTY_OPTION').'</option>';
                $counts2 = count($states[$c->virtuemart_country_id]);
                $ci2 = 0;
                foreach ($states[$c->virtuemart_country_id] as $state) {
                    if (empty($state->published)) {
                        continue;
                    }
                    $ci2++;
                    //$js .= ' state_for_'.$c->virtuemart_country_id.'['.$state->virtuemart_state_id.']: "'.str_replace('"', '\"', $state->state_name).'",'."\n";
                    $js .= $state->virtuemart_state_id . ': "' . str_replace('"', '\\"', $state->state_name) . '"';
                    if ($ci2 != $counts2) {
                        $js .= ', ';
                    }
                    $js .= "\n";
                    //$html .= '<option ';
                    //if ($state->virtuemart_state_id == $cs) $html .= ' selected="selected" ';
                    //$html .= ' value="'.$state->virtuemart_state_id.'">'.$state->state_name.'</option>';
                }
                $js .= ' }';
                if ($ci != $counts) {
                    $js .= ', ';
                }
                $js .= "\n";
                //$html .= '</select>';
            }
            // debug
        }
        $js .= ' }; 
	
	
	';
        $html = '<div style="display: none;">';
        $html .= '<select id="no_states" name="no_states">';
        $html .= '<option value="">' . OPCLang::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . '</option>';
        $html .= '</select>';
        $html .= '</div>';
        //$html .= '</div>';
        //alert(OPCStates.state_for_10[373]);
        if (!empty($ref->cart->BT) && !empty($ref->cart->BT['virtuemart_state_id'])) {
            $cs = $ref->cart->BT['virtuemart_state_id'];
        } else {
            $cs = '';
        }
        if (!empty($ref->cart->ST) && !empty($ref->cart->ST['virtuemart_state_id'])) {
            $css = $ref->cart->ST['virtuemart_state_id'];
        } else {
            $css = '';
        }
        $html .= '<script type="text/javascript">
	var selected_bt_state = \'' . $cs . '\';
	var selected_st_state = \'' . $css . '\';
	
	</script>';
        //$html = '<script>'.$js.'</script>';
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        if (JFile::write($js_file, $js) !== false) {
            JHTMLOPC::script($js_filename, $js_path);
        } else {
            $html .= '
<script type="text/javascript">
//<![CDATA[		   
			   ' . $js . '
//]]>		   
</script>
';
        }
        return $html;
        return '';
    }
コード例 #13
0
ファイル: ajaxhelper.php プロジェクト: aldegtyarev/stelsvelo
 function getPaymentArrayHtml($cart2, $payment_array, &$shipping_array)
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     if (is_null(OPCloader::$inform_html)) {
         OPCloader::$inform_html = array();
     }
     $preselected = JRequest::getVar('virtuemart_shipmentmethod_id', JRequest::getVar('shipping_rate_id', ''));
     $default = array();
     $session = JFactory::getSession();
     $session->set('fedex_rates', null, 'vm');
     // if ($op_show_others) $vendor_freeshipping = 0;
     // $extHelper = new opExtension();
     // $extHelper->runExt('setFreeShipping', '', '', $vars['country'], $vendor_freeshipping);
     // coupon will get counted again
     $cart = VirtueMartCart::getCart();
     $add = array();
     if (!empty($payment_array)) {
         foreach ($payment_array as &$pay) {
             if (isset($pay->payment_element)) {
                 if (!empty($pay->split_plugin_path)) {
                     include $pay->split_plugin_path;
                 }
             }
             //if (!empty($params)) break;
         }
     }
     if (!empty($add)) {
         //array_merge($payment_array, $add);
         foreach ($add as $v) {
             $payment_array[] = $v;
         }
     }
     $payment_array['zero_payment'] = '<input type="hidden" value="0" name="virtuemart_paymentmethod_id" />';
     // again and again we have to do overrides because VM team decides about private functions and properties
     $dispatcher = JDispatcher::getInstance();
     $prices = array();
     // renew parameters
     //For the selection of the shipment method we need the total amount to pay.
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $shipmentModel = OPCmini::getModel('Shipmentmethod');
     //new VirtueMartModelShipmentmethod();
     // the configuration is reloaded only when this function is called interanally
     // getPluginMethods which is called by FEdisplay method
     $html = '';
     self::$totals_html = '';
     if (!empty($cart->couponCode)) {
         self::$totals_html = '<input type="hidden" id="opc_coupon_code_returned" name="opc_coupon_code_returned" value="' . OPCloader::slash($cart->couponCode) . '" />';
     } else {
         self::$totals_html = '<input type="hidden" id="opc_coupon_code_returned" name="opc_coupon_code_returned" value="" />';
     }
     //$opc_calc_cache = true;
     if (file_exists(JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'overrides' . DS . 'calculationh.php')) {
         if (!empty($opc_calc_cache)) {
             require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'overrides' . DS . 'calculationh.php';
             if (!class_exists('calculationHelperOPC')) {
                 require JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'overrides' . DS . 'calculationh_override.php';
             }
         }
     }
     // from vm 2.0.22
     $calc = calculationHelper::getInstance();
     if (!empty($opc_calc_cache)) {
         if (class_exists('calculationHelperOPC')) {
             $calc = calculationHelperOPC::getInstanceOPC();
         }
     }
     /*
     			$class = new ReflectionClass('calculationHelper');
     			$method = $class->getMethod('setShopperGroupIds');
     			$method->setAccessible(true);
     			$method->invokeArgs($calc, array('6'));
     */
     if (method_exists($calc, 'setCartPrices')) {
         $vm2015 = true;
     } else {
         $vm2015 = false;
     }
     /*
     foreach ($cart->products as &$p)
     $calc->
     */
     $mainframe = Jfactory::getApplication();
     $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id'));
     //$calc->setVendorCurrency($virtuemart_currency_id);
     if (!empty($virtuemart_currency_id)) {
         $currencyDisplay = CurrencyDisplay::getInstance($virtuemart_currency_id);
     } else {
         $currencyDisplay = CurrencyDisplay::getInstance($cart->paymentCurrency);
         $virtuemart_currency_id = $cart->paymentCurrency;
     }
     $unset_zero = true;
     if (empty($shipping_array)) {
         $shipping_array = array();
         $cart->virtuemart_shipmentmethod_id = 0;
         $unset_zero = false;
     }
     $shipping_array['zero_shipment'] = '<input type="hidden" name="virtuemart_shipmentmethod_id" checked="checked" id="shipment_id_0" value="0" />';
     $shipping_array['choose_shipping'] = '<input type="radio" value="0" id="shipment_id_0" />';
     $payment_a = new stdClass();
     $payment_a->virtuemart_paymentmethod_id = 0;
     $payment_array[] = $payment_a;
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currencyDisplay = CurrencyDisplay::getInstance($cart->pricesCurrency);
     //do_dump($shipping_array); die();
     //virtuemart_currency_id
     foreach ($shipping_array as &$shipping_method) {
         foreach ($payment_array as &$payment) {
             if (strpos($shipping_method, 'invalid_country') !== false) {
                 $cart->virtuemart_shipmentmethod_id = 0;
             }
             if (strpos($shipping_method, 'virtuemart_shipmentmethod_id') === false) {
                 $cart->virtuemart_shipmentmethod_id = 0;
             }
             $multishipmentid = array();
             if (!empty($shipping_method)) {
                 //check opc multi methods:
                 //multielementgetphp
                 $multishipmentid = OPCTransform::getFT($shipping_method, 'input', 'virtuemart_shipmentmethod_id', 'type', 'radio', '>', 'id');
                 //example of a multi method with select drop down:
                 /*
                 foreach ($pobocky_options as $ppp)
                 		 {
                 		    $pobocky .= '<option '; 
                 			if ($sind == $ppp->id) $pobocky .= ' selected="selected" '; 
                 			$pobocky .= ' ismulti="true" multi_id="shipment_id_'.$method->virtuemart_shipmentmethod_id.'_'.$ppp->id.'" value="'.$ppp->id.'">'.$ppp->nazev.'</option>'; 
                 		 }
                 */
                 $real_id = false;
                 $multishipmentid_test = OPCTransform::getFT($shipping_method, 'option', 'ismulti', 'ismulti', 'true', '>', 'multi_id');
                 if (!empty($multishipmentid_test)) {
                     if (!empty($multishipmentid)) {
                         $real_id = $multishipmentid[0];
                     }
                     $multishipmentid = $multishipmentid_test;
                 }
                 if (empty($multishipmentid)) {
                     $multishipmentid = OPCTransform::getFT($shipping_method, 'input', 'cpsol_radio', 'type', 'radio', '>', 'id');
                 }
                 //$idth = 'shipment_id_'.$shipmentid;
                 // $idth = $shipmentid;
             } else {
                 $idth = 'shipment_id_0';
             }
             if (empty($multishipmentid)) {
                 $idth = 'shipment_id_0';
                 $multishipmentid[0] = $idth;
             }
             foreach ($multishipmentid as $shipmentid) {
                 $idth = $shipmentid;
                 $ida = OPCTransform::getFT($shipping_method, 'input', 'virtuemart_shipmentmethod_id', 'type', 'hidden', '>', 'value');
                 if (empty($ida)) {
                     $ida = OPCTransform::getFT($shipping_method, 'input', $shipmentid, 'type', 'radio', '>', 'value');
                 }
                 if (!empty($ida[0])) {
                     $id = $ida[0];
                 } else {
                     $id = 0;
                 }
                 if (!isset($payment->virtuemart_paymentmethod_id)) {
                     $payment_id = 0;
                 } else {
                     $payment_id = (int) $payment->virtuemart_paymentmethod_id;
                 }
                 $_REQUEST['virtuemart_shipmentmethod_id'] = $id;
                 $cart->automaticSelectedShipment = true;
                 $cart->automaticSelectedPayment = true;
                 $cart->automaticSelectedShipment = true;
                 $cart->automaticSelectedPayment = true;
                 $cart->setPaymentMethod($payment_id);
                 if (method_exists($cart, 'setShipment')) {
                     $cart->setShipment($id);
                 }
                 $cart->virtuemart_shipmentmethod_id = $id;
                 $cart->virtuemart_paymentmethod_id = $payment_id;
                 $payment_id_override = 0;
                 //
                 if (isset($payment->payment_element)) {
                     if (!empty($payment->preparecalculation_path)) {
                         include $payment->preparecalculation_path;
                     }
                 }
                 $htmlsaved = $html;
                 $html = '';
                 require JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'third_party' . DS . 'third_party_shipping.php';
                 $md5 = md5($html);
                 OPCloader::$inform_html[$md5] = $html;
                 //self::$totals_html .= $html;
                 $html = $htmlsaved;
                 //$cart = VirtueMartCart::getCart();
                 //$returnValues = $dispatcher->trigger('calculateSalesPrice',array(  &$cart, &$id, &$cart->priceUnformatted  ));
                 $cart->setCartIntoSession();
                 /*
                 if (!class_exists('VirtueMartControllerCartOpc'))
                 require_once(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'overrides'.DS.'cartcontroller.php'); 
                 $cartcontroller = new VirtueMartControllerCartOpc(); 
                 */
                 // will trigger plugin code for the selected shipment
                 JRequest::setVar('virtuemart_shipmentmethod_id', $id);
                 //OLD: $cartcontroller->setshipment($cart, $id, false, false);
                 $savedp = $cart->virtuemart_paymentmethod_id;
                 $seveds = $cart->virtuemart_shipmentmethod_id;
                 if (!empty($id)) {
                     ob_start();
                     $_dispatcher = JDispatcher::getInstance();
                     $_retValues = $_dispatcher->trigger('plgVmOnSelectCheckShipment', array(&$cart));
                     $x = ob_get_clean();
                 }
                 $cart->virtuemart_paymentmethod_id = $savedp;
                 $cart->virtuemart_shipmentmethod_id = $seveds;
                 $op_disable_shipping = OPCloader::getShippingEnabled($cart);
                 if (empty($op_disable_shipping)) {
                     if (!$vm2015) {
                         $prices = $calc->calculateShipmentPrice($cart, $id, true);
                     }
                 } else {
                     $cart->virtuemart_shipmentmethod_id = 0;
                     //if (!$vm2015)
                     //$calc->calculateShipmentPrice($cart, $id, false);
                     //$calc->_cartPrices
                 }
                 if (!$vm2015) {
                     $calc->calculatePaymentPrice($cart, $payment_id, true);
                 } else {
                     //$calc->_cartData = null;
                     //$ref->cart->cartData = null;
                     $calc->setCartPrices(array());
                 }
                 $prices = array();
                 $this->getCachedShipping($cart, $prices, $idth, $calc);
                 $cart->pricesUnformatted = $prices;
                 if (empty($subtotal_price_display)) {
                     $subtotal_price_display = 'salesPrice';
                 }
                 if ($subtotal_price_display != 'diffTotals') {
                     $order_subtotal = $prices[$subtotal_price_display];
                     /*
                     	if (empty($order_subtotal))
                     {
                       $order_subtotal = $prices['salesPrice']; 
                     }
                     */
                 }
                 if (empty($order_subtotal)) {
                     $order_subtotal = $prices['salesPrice'];
                     $subtotal_price_display = 'salesPrice';
                 }
                 if ($subtotal_price_display == 'diffTotals') {
                     // difference of billTotal and billTaxAmount
                     $order_subtotal = $prices['billTotal'] - $prices['billTaxAmount'];
                 }
                 $order_subtotal = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $order_subtotal, false);
                 $order_total = $prices['billTotal'];
                 $order_total = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $order_total, false);
                 $order_tax = 0;
                 if ($coupon_price_display == 'salesWithoutTax') {
                     if (isset($prices['couponTax'])) {
                         $cT = $prices['couponTax'];
                     } else {
                         $cT = 0;
                     }
                     if (isset($prices['salesPriceCoupon'])) {
                         $cS = $prices['salesPriceCoupon'];
                     } else {
                         $cS = 0;
                     }
                     $prices['salesWithoutTax'] = $cS - $cT;
                 }
                 if (empty($coupon_price_display)) {
                     $coupon_price_display = 'discountAmount';
                 }
                 if (!empty($prices[$coupon_price_display])) {
                     $coupon_discount = $prices[$coupon_price_display];
                 } else {
                     $coupon_discount = 0;
                 }
                 $coupon_discount = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $coupon_discount, false);
                 if (!empty($payment_discount_before)) {
                     $coupon_discount2 = 0;
                     if (empty($other_discount_display)) {
                         $other_discount_display = 'billDiscountAmount';
                     }
                     switch ($other_discount_display) {
                         case 'billDiscountAmount':
                             $coupon_discount2 = $coupon_discount2 = $prices['billDiscountAmount'];
                             break;
                         case 'discountAmount':
                             $coupon_discount2 = $prices['billDiscountAmount'];
                             break;
                         case 'minus':
                             $billD = abs($prices['billDiscountAmount']);
                             foreach ($prices as $key => $val) {
                                 if (!empty($cart->products[$key])) {
                                     if (is_array($val)) {
                                         $billD -= abs($val['subtotal_discount']);
                                     }
                                 }
                             }
                             $billD = abs($billD) * -1;
                             $prices_new['billTotal'] = $billD;
                             $coupon_discount2 = $billD;
                             break;
                         case 'sum':
                             $billD = 0;
                             foreach ($prices as $key => $val) {
                                 if (!empty($cart->products[$key])) {
                                     if (is_array($val)) {
                                         $billD += $val['subtotal_discount'];
                                     }
                                 }
                             }
                             $billD = abs($billD) * -1;
                             $prices_new['billTotal'] = $billD;
                             $coupon_discount2 = $billD;
                             break;
                     }
                     if (!empty($coupon_discount2)) {
                         $coupon_discount2 = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $coupon_discount2, false);
                     }
                     /*	
                     if (!empty($prices['billDiscountAmount']))
                     {
                     $coupon_discount2 = $prices['billDiscountAmount']; 
                     $coupon_discount2 = $currencyDisplay->convertCurrencyTo( $virtuemart_currency_id, $coupon_discount2,false);
                     
                     }
                     else
                     if (!empty($prices['discountAmount']))
                     {
                     $coupon_discount2 = $prices['discountAmount']; 
                     $coupon_discount2 = $currencyDisplay->convertCurrencyTo( $virtuemart_currency_id, $coupon_discount2,false);
                     }
                     else $coupon_discount2 = 0; 
                     */
                 } else {
                     $coupon_discount2 = 0;
                 }
                 if (!empty($payment_discount_before)) {
                     if (empty($coupon_discount2)) {
                         if (!empty($prices['couponValue'])) {
                             // $coupon_discount2 = $prices['couponValue'];
                         }
                     }
                 }
                 if ($product_price_display == 'basePriceWithTax' || $product_price_display == 'salesPrice') {
                     $shippingpayment_price_display = 'salesPrice';
                 } else {
                     $shippingpayment_price_display = 'basePrice';
                 }
                 if (empty($prices['basePriceWithTax'])) {
                     $shippingpayment_price_display = 'basePrice';
                 }
                 $subtotal_price_display = $product_price_display;
                 if (!isset($prices[$shippingpayment_price_display . 'Shipment'])) {
                     if ($shippingpayment_price_display != 'salesPrice') {
                         $order_shipping = $prices['shipmentValue'];
                     } else {
                         $order_shipping = $prices['salesPriceShipment'];
                     }
                 } else {
                     $order_shipping = $prices[$shippingpayment_price_display . 'Shipment'];
                 }
                 $order_shipping = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $order_shipping, false);
                 if ($shippingpayment_price_display != 'salesPrice') {
                     $ps = $prices['salesPriceShipment'];
                     $ps = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $ps, false);
                     $ps = $currencyDisplay->priceDisplay($ps);
                     $os = $currencyDisplay->priceDisplay($order_shipping);
                     $shipping_method = str_replace($ps, $os, $shipping_method);
                 }
                 $order_shipping = (double) $order_shipping;
                 if (empty($order_shipping)) {
                 }
                 // lets select a default shipping method:
                 // first shipping found:
                 // none to be selected by default if nothing is already selected:
                 if (empty($preselected) && (!empty($opc_default_shipping) && $opc_default_shipping == 3)) {
                     $default['id'] = 0;
                     $default['shipmentid'] = 'choose_shipping';
                     $default['price'] = 0;
                 } else {
                     if (!empty($id)) {
                         if (empty($default)) {
                             $default['id'] = $id;
                             $default['shipmentid'] = $shipmentid;
                             $default['price'] = $order_shipping;
                         } else {
                             // preselected found (from $_REQUEST)
                             if ($preselected == $id) {
                                 // if we found the preselected, let's leave it there
                                 $default['p'] = true;
                                 $default['id'] = $id;
                                 if (!empty($real_id)) {
                                     $default['shipmentid'] = $real_id;
                                 } else {
                                     $default['shipmentid'] = $shipmentid;
                                 }
                                 $default['price'] = $order_shipping;
                             }
                             // check if we already selected:
                             if (empty($default['p'])) {
                                 if (!empty($op_default_shipping_search)) {
                                     foreach ($op_default_shipping_search as $s) {
                                         if ($shipmentid == $s) {
                                             $default['id'] = $id;
                                             $default['shipmentid'] = $shipmentid;
                                             $default['price'] = $order_shipping;
                                             $default['p'] = true;
                                             break;
                                         }
                                     }
                                 }
                                 if (empty($default['p'])) {
                                     if (empty($opc_default_shipping) || $opc_default_shipping === 1) {
                                         if ($default['price'] > $order_shipping || empty($default['price']) && !empty($order_shipping)) {
                                             if ($op_default_shipping_zero && empty($order_shipping)) {
                                                 $default['id'] = $id;
                                                 $default['shipmentid'] = $shipmentid;
                                                 $default['price'] = $order_shipping;
                                             } else {
                                                 if (!$op_default_shipping_zero && !empty($order_shipping)) {
                                                     $default['id'] = $id;
                                                     $default['shipmentid'] = $shipmentid;
                                                     $default['price'] = $order_shipping;
                                                 }
                                             }
                                         }
                                     } else {
                                         if (!empty($opc_default_shipping) && $opc_default_shipping === 2) {
                                             // select the most expensive here:
                                             if ($default['price'] < $order_shipping || empty($default['price']) && !empty($order_shipping)) {
                                                 if (!$op_default_shipping_zero && !empty($order_shipping)) {
                                                     $default['id'] = $id;
                                                     $default['shipmentid'] = $shipmentid;
                                                     $default['price'] = $order_shipping;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($shippingpayment_price_display == 'basePrice') {
                     $paymentPriceType = 'paymentValue';
                 } else {
                     $paymentPriceType = 'salesPricePayment';
                 }
                 if (isset($prices[$shippingpayment_price_display . 'Payment'])) {
                     $payment_discount = -1 * $prices[$shippingpayment_price_display . 'Payment'];
                 } else {
                     if (!empty($prices[$paymentPriceType])) {
                         $payment_discount = -1 * $prices[$paymentPriceType];
                     } else {
                         $payment_discount = -1 * $prices['salesPricePayment'];
                     }
                 }
                 $payment_discount = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $payment_discount, false);
                 $tax_id = 0;
                 $taxname = array();
                 $taxrate = array();
                 $taxamount = array();
                 if (!empty($cart->cartData['DBTaxRulesBill'])) {
                     foreach ($cart->cartData['DBTaxRulesBill'] as $rule) {
                         $tax_id = $rule['virtuemart_calc_id'];
                         $taxname[$tax_id] = $rule['calc_name'];
                         $taxrate[$tax_id] = $rule['calc_value'];
                         $tax = $prices[$tax_id . 'Diff'];
                         if (empty($tax)) {
                             $tax = $cart->pricesUnformatted[$tax_id . 'Diff'];
                         }
                         if (!empty($tax)) {
                             $taxamount[$tax_id] = $tax;
                         }
                     }
                 }
                 if (!empty($cart->cartData['taxRulesBill'])) {
                     foreach ($cart->cartData['taxRulesBill'] as $x) {
                         $tax_id = $x['virtuemart_calc_id'];
                         $taxname[$tax_id] = $x['calc_name'];
                         $taxrate[$tax_id] = $x['calc_value'];
                         if (isset($prices[$tax_id . 'Diff'])) {
                             $tax = $prices[$tax_id . 'Diff'];
                         } else {
                             $tax = 0;
                         }
                         if (empty($tax) && isset($cart->pricesUnformatted[$tax_id . 'Diff'])) {
                             $tax = $cart->pricesUnformatted[$tax_id . 'Diff'];
                         }
                         // convert the tax
                         if (!empty($tax)) {
                             $tax = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $tax, false);
                             $taxamount[$tax_id] = $tax;
                         }
                     }
                 }
                 // this tax is already included in the subtotal
                 if (!empty($prices)) {
                     foreach ($prices as $k => $x2) {
                         if (isset($x2['Tax']) && is_array($x2['Tax'])) {
                             foreach ($x2['Tax'] as $ind => $r) {
                                 $tax_id = $ind;
                                 $taxname[$tax_id] = $r[0];
                                 $taxrate[$tax_id] = $r[1];
                                 if (isset($prices[$tax_id . 'Diff'])) {
                                     $tax = $prices[$tax_id . 'Diff'];
                                 }
                                 if (empty($tax)) {
                                     if (isset($cart->pricesUnformatted[$tax_id . 'Diff'])) {
                                         $tax = $cart->pricesUnformatted[$tax_id . 'Diff'];
                                     }
                                 }
                                 if (!empty($tax)) {
                                     $taxamount[$tax_id] = $tax;
                                 }
                             }
                         }
                     }
                 }
                 //stAn, 2.0.226:
                 //dynamic lines start
                 if (!empty($opc_dynamic_lines)) {
                     $types = array('DATax', 'VatTax', 'Tax', 'DBTax');
                     $results = array();
                     $resultsNames = array();
                     foreach ($prices as $key => $val) {
                         if (is_array($prices[$key])) {
                             if (!empty($prices[$key]['subtotal_tax_amount'])) {
                                 foreach ($types as $ttype) {
                                     if (!empty($prices[$key][$ttype])) {
                                         foreach ($prices[$key][$ttype] as $id => $calcOp) {
                                             if (empty($calcOp)) {
                                                 continue;
                                             }
                                             $tax = array();
                                             $tax['calc_name'] = $calcOp[0];
                                             $tax['calc_value'] = $calcOp[1];
                                             $tax['calc_value_mathop'] = $calcOp[2];
                                             $tax['calc_shopper_published'] = $calcOp[3];
                                             $tax['calc_currency'] = $calcOp[4];
                                             $tax['calc_params'] = $calcOp[5];
                                             $tax['virtuemart_vendor_id'] = $calcOp[6];
                                             $tax['virtuemart_calc_id'] = $calcOp[7];
                                             $res = $calc->interpreteMathOp($tax, $prices[$key]['subtotal']);
                                             if (!isset($results[$id])) {
                                                 $results[$id] = 0;
                                             }
                                             $results[$id] += $res - $prices[$key]['subtotal'];
                                             $resultsNames[$id] = JText::_($tax['calc_name']);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $billRuls = array();
                     if (!empty($cart->OPCCartData['DBTaxRulesBill'])) {
                         foreach ($cart->OPCCartData['DBTaxRulesBill'] as $rule) {
                             if (empty($rule)) {
                                 continue;
                             }
                             $results[$rule['virtuemart_calc_id']] = $prices[$rule['virtuemart_calc_id'] . 'Diff'];
                             $restulsNamed[$rule['virtuemart_calc_id']] = $rule['calc_name'];
                             $billRuls[$rule['virtuemart_calc_id']] = $rule['virtuemart_calc_id'];
                         }
                     }
                     if (!empty($cart->OPCCartData['taxRulesBill'])) {
                         foreach ($cart->OPCCartData['taxRulesBill'] as $rule) {
                             if (empty($rule)) {
                                 continue;
                             }
                             $results[$rule['virtuemart_calc_id']] = $prices[$rule['virtuemart_calc_id'] . 'Diff'];
                             $restulsNamed[$rule['virtuemart_calc_id']] = $rule['calc_name'];
                             $billRuls[$rule['virtuemart_calc_id']] = $rule['virtuemart_calc_id'];
                         }
                     }
                     if (!empty($cart->OPCCartData['DATaxRulesBill'])) {
                         foreach ($cart->OPCCartData['DATaxRulesBill'] as $rule) {
                             if (empty($rule)) {
                                 continue;
                             }
                             $results[$rule['virtuemart_calc_id']] = $prices[$rule['virtuemart_calc_id'] . 'Diff'];
                             $restulsNamed[$rule['virtuemart_calc_id']] = $rule['calc_name'];
                             $billRuls[$rule['virtuemart_calc_id']] = $rule['virtuemart_calc_id'];
                         }
                     }
                     //DATaxRulesBill end
                     //shipping fee
                     if (!empty($results)) {
                         reset($results);
                         $first_key = key($results);
                         if (empty($prices['shipment_calc_id'])) {
                             if (!empty($prices['shipmentTax'])) {
                                 $results[$first_key] += $prices['shipmentTax'];
                             }
                         } else {
                             if (!is_array($prices['shipment_calc_id'])) {
                                 if (!empty($prices['shipmentTax'])) {
                                     if (!isset($results[$prices['shipment_calc_id']])) {
                                         $results[$prices['shipment_calc_id']] = 0;
                                     }
                                     $results[(int) $prices['shipment_calc_id']] += $prices['shipmentTax'];
                                 }
                             } else {
                                 foreach ($prices['shipment_calc_id'] as $calc_id) {
                                     if (!isset($results[$calc_id])) {
                                         $results[$calc_id] = 0;
                                     }
                                     $results[$calc_id] += $prices['shipmentTax'];
                                     // maybe we should add it just once !!!
                                 }
                             }
                         }
                         if (empty($prices['payment_calc_id'])) {
                             if (!empty($prices['paymentTax'])) {
                                 $results[$first_key] += $prices['paymentTax'];
                             }
                         } else {
                             if (!is_array($prices['payment_calc_id'])) {
                                 if (!empty($prices['paymentTax'])) {
                                     if (!isset($results[$prices['payment_calc_id']])) {
                                         $results[$prices['payment_calc_id']] = 0;
                                     }
                                     $results[$prices['payment_calc_id']] += $prices['paymentTax'];
                                 }
                             } else {
                                 foreach ($prices['payment_calc_id'] as $calc_id) {
                                     if (!isset($results[$calc_id])) {
                                         $results[$calc_id] = 0;
                                     }
                                     $results[$calc_id] += $prices['paymentTax'];
                                     // maybe we should add it just once !!!
                                 }
                             }
                         }
                     }
                     $dynamic = array();
                     foreach ($results as $key => $val) {
                         //this is for the bill taxes:
                         if (isset($prices[$key . 'Diff'])) {
                             if ($prices[$key . 'Diff'] > $val) {
                                 $val = $key . 'Diff';
                             }
                         }
                         $dynamic[$key]['value'] = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $val, false);
                         if (!isset($resultsNames[$key])) {
                             $db = JFactory::getDBO();
                             $q = 'select calc_name from #__virtuemart_calcs where virtuemart_calc_id = ' . (int) $key . ' limit 0,1';
                             $db->setQuery($q);
                             $resultsNames[$key] = $name = $db->loadResult();
                         }
                         $dynamic[$key]['name'] = $resultsNames[$key];
                     }
                     //stAn, 2.0.226 end
                     if (!empty($prices)) {
                         foreach ($prices as $k => $x2) {
                             if (strpos($k, 'Diff') !== false) {
                                 $k2 = str_replace('Diff', '', $k);
                                 if (!empty($results) && !array_key_exists($k2, $results)) {
                                     if (is_numeric($k2)) {
                                         $k2 = (int) $k2;
                                         $db = JFactory::getDBO();
                                         $q = 'select calc_name from #__virtuemart_calcs where virtuemart_calc_id = ' . $k2 . ' limit 0,1';
                                         $db->setQuery($q);
                                         $name = $db->loadResult();
                                         // to support multilang
                                         $name = JText::_($name);
                                         $dynamic[$k2]['name'] = $name;
                                         $val = 0;
                                         if (isset($cart->OPCCartData['VatTax'])) {
                                             if (isset($cart->OPCCartData['VatTax'][$k2])) {
                                                 if (isset($cart->OPCCartData['VatTax'][$k2]['taxAmount'])) {
                                                     $val = $cart->OPCCartData['VatTax'][$k2]['taxAmount'];
                                                     if (isset($prices['shipmentTax'])) {
                                                         $val += $prices['shipmentTax'];
                                                     }
                                                     if (isset($prices['paymentTax'])) {
                                                         $val += $prices['paymentTax'];
                                                     }
                                                 }
                                             }
                                         }
                                         if ($val == 0) {
                                             $val = $x2;
                                         }
                                         $dynamic[$k2]['value'] = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $val, false);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 //dynamic lines end
                 // add shipment tax to it's plugins subtotal
                 if (!empty($prices['shipmentTax'])) {
                     if (isset($prices['shipment_calc_id'])) {
                         if (!is_array($prices['shipment_calc_id'])) {
                             if (!isset($taxamount[$prices['shipment_calc_id']])) {
                                 $taxamount[$prices['shipment_calc_id']] = 0;
                             }
                             $taxamount[$prices['shipment_calc_id']] += $prices['shipmentTax'];
                         } else {
                             foreach ($prices['shipment_calc_id'] as $calc_id) {
                                 if (!isset($taxamount[$calc_id])) {
                                     $taxamount[$calc_id] = 0;
                                 }
                                 $taxamount[$calc_id] += $prices['shipmentTax'];
                                 // maybe we should add it just once !!!
                                 // break;
                             }
                         }
                     }
                 }
                 if (!isset($tax)) {
                     $tax = 0;
                 }
                 if (!empty($prices['paymentTax'])) {
                     if (isset($prices['payment_calc_id'])) {
                         if (!is_array($prices['payment_calc_id'])) {
                             if (!isset($taxamount[$prices['payment_calc_id']])) {
                                 $taxamount[$prices['payment_calc_id']] = 0;
                             }
                             $taxamount[$prices['payment_calc_id']] += $prices['paymentTax'];
                         } else {
                             foreach ($prices['payment_calc_id'] as $calc_id) {
                                 if (!isset($taxamount[$calc_id])) {
                                     $taxamount[$calc_id] = 0;
                                 }
                                 $taxamount[$calc_id] += $prices['paymentTax'];
                             }
                         }
                     } else {
                         if (isset($prices['payment_tax_id'])) {
                             if (!isset($taxamount[$prices['payment_tax_id']])) {
                                 $taxamount[$prices['payment_tax_id']] = 0;
                             }
                             $taxamount[$prices['payment_tax_id']] += $prices['paymentTax'];
                         }
                     }
                 }
                 $order_tax = $prices['billTaxAmount'];
                 $order_tax = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $order_tax, false);
                 // ok, here we should reprocess the coupon
                 if (!empty($payment_id_override)) {
                     $o = '<input type="hidden" id="payment_id_override_' . $payment_id . '" value="1"/>';
                     if (!defined('payment_id_override_' . $payment_id)) {
                         self::$totals_html .= $o;
                         define('payment_id_override_' . $payment_id, 1);
                     }
                     $payment_id = $payment_id_override;
                 }
                 self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_subtotal" value="' . $order_subtotal . '"/>';
                 $sum = (double) 0;
                 // this shows
                 if (count($taxname) >= 1 && empty($show_single_tax)) {
                     //if (!defined('.$idth.'_'.$payment_id.'_tax
                     $taxhtml = '';
                     foreach ($taxname as $id => $name) {
                         $rate = (double) $taxrate[$id] / 100;
                         if (empty($taxamount[$id])) {
                             continue;
                         }
                         $tax = $taxamount[$id];
                         if (!is_numeric($tax)) {
                             // we have a possible cross compatiblity error here
                             $tax = 0;
                         }
                         $sum += $tax;
                         self::$totals_html .= '<input type="hidden" name="' . $idth . '_' . $payment_id . '_tax" value="' . $rate . '|' . $tax . '"/>';
                         self::$totals_html .= '<input type="hidden" name="' . $idth . '_' . $payment_id . '_taxname" value="' . OPCloader::slash($name) . '"/>';
                     }
                 }
                 self::$totals_html .= '<input type="hidden" name="' . $idth . '_' . $payment_id . '_tax_all" id="' . $idth . '_' . $payment_id . '_tax_all" value="|' . $order_tax . '"/>';
                 if (!empty($dynamic)) {
                     foreach ($dynamic as $key => $val) {
                         if (!empty($dynamic[$key]['value'])) {
                             self::$totals_html .= '<input type="hidden" name="' . $idth . '_' . $payment_id . '_dynamic" rel="' . $key . '" id="' . $idth . '_' . $payment_id . '_dynamicvalue_' . $key . '" stringname="' . OPCloader::slash($dynamic[$key]['name']) . '" value="' . $dynamic[$key]['value'] . '"/>';
                         }
                     }
                 }
                 if (!empty($payment_discount)) {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_payment_discount" value="' . $payment_discount . '"/>';
                 } else {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_payment_discount" value="0.00"/>';
                 }
                 if (!empty($coupon_discount)) {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_coupon_discount" value="' . $coupon_discount . '"/>';
                 } else {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_coupon_discount" value="0.00"/>';
                 }
                 if (!empty($coupon_discount2)) {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_coupon_discount2" value="' . $coupon_discount2 . '"/>';
                 } else {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_coupon_discount2" value="0.00"/>';
                 }
                 if (!empty($order_shipping)) {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_order_shipping" value="' . $order_shipping . '"/>';
                 } else {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_order_shipping" value="0.00"/>';
                 }
                 if (!empty($order_shipping_tax)) {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_order_shipping_tax" value="' . $order_shipping_tax . '"/>';
                 } else {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_order_shipping_tax" value="0.00"/>';
                 }
                 if (!empty($order_total)) {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_order_total" value="' . $order_total . '"/>';
                 } else {
                     self::$totals_html .= '<input type="hidden" id="' . $idth . '_' . $payment_id . '_order_total" value="0.00"/>';
                 }
             }
         }
     }
     unset($ke);
     unset($html2);
     if (!empty($unset_zero)) {
         unset($shipping_array['zero_shipment']);
     }
     unset($payment_array['zero_payment']);
     if (!empty($shipping_array)) {
         unset($shipping_array['choose_shipping']);
     }
     $wrapper = '<!--shipping_goes_here-->';
     $num = 1;
     if (!empty($shipping_array)) {
         if (!empty($shipping_inside)) {
             $num = 0;
             $ret = OPCTransform::shippingToSelect($shipping_array, $num, $cart);
             if (!empty($num)) {
                 $html .= $ret;
             }
         }
     }
     if (!empty($shipping_array)) {
         if (empty($shipping_inside) || empty($num)) {
             $htmla = array();
             foreach ($shipping_array as $ke => &$html2) {
                 if (strpos($html2, 'virtuemart_shipmentmethod_id') !== false) {
                     $tmp = $tmp2 = $shipping_array[$ke];
                     //substr($shipping_array[$ke], $x1, $x2);
                     if (!empty($default)) {
                         $shipmentid = (string) $default['shipmentid'];
                     } else {
                         $shipmentid = '';
                     }
                     if (strpos($tmp, '"' . $shipmentid . '"') !== false) {
                         $tmp = str_replace('checked="checked"', '', $tmp);
                         $tmp = str_replace('checked', '', $tmp);
                         //virtuemart_shipmentmethod_id
                         $tmp = str_replace('name="virtuemart_shipmentmethod_id"', ' autocomplete="off" name="virtuemart_shipmentmethod_id"', $tmp);
                         if (!empty($default)) {
                             $tmp = $this->str_replace_once('"' . $shipmentid . '"', '"' . $shipmentid . '" checked="checked" ', $tmp);
                         }
                     }
                     $tmp = str_replace('name="virtuemart_shipmentmethod_id"', 'name="virtuemart_shipmentmethod_id" onclick="javascript:Onepage.changeTextOnePage3(op_textinclship, op_currency, op_ordertotal);" ', $tmp);
                     //if (strpos($tmp, 'shipment_id_'.$id.'"')!== false) $tmp.' ok sel ';
                     $shipping_array[$ke] = $tmp;
                     //str_replace($shipping_array[$ke], $tmp, $shipping_array[$ke]);
                     $x1 = strpos($shipping_array[$ke], '<input');
                     $x1a = basketHelper::strposall($shipping_array[$ke], '<input');
                     if (!empty($x1a)) {
                         foreach ($x1a as $x1) {
                             $x2 = strpos($shipping_array[$ke], '>', $x1 + 1);
                             if ($x2 !== false) {
                                 if (substr($shipping_array[$ke], $x2 - 1, 1) != '/') {
                                     // fixed a bug in 2.0.87 !! otherwise the shipping method might be rendered incorrectly
                                     $a1 = substr($shipping_array[$ke], 0, $x2);
                                     $a2 = substr($shipping_array[$ke], $x2);
                                     $shipping_array[$ke] = $a1 . '/' . $a2;
                                 }
                             }
                         }
                     }
                 }
                 //$html .= $shipping_array[$ke].'<br />';
                 //echo 'sa:'.$shipping_array[$ke].'endsa';
                 if (strpos($shipping_array[$ke], '<!--shipping_goes_here-->') === false) {
                     $htmla[] = $shipping_array[$ke] . '<br />';
                 } else {
                     $wrapper = $shipping_array[$ke] . '<br />';
                 }
             }
             $vars = array('shipping' => $htmla, 'cart' => $cart);
             if (!class_exists('OPCrenderer')) {
                 require JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'renderer.php';
             }
             $renderer = OPCrenderer::getInstance();
             $htmlr = $renderer->fetch($renderer, 'list_shipping_methods.tpl', $vars);
             if (empty($htmlr)) {
                 $html .= implode('', $htmla);
             } else {
                 $html .= $htmlr;
             }
             // create html:
         }
     }
     $html = str_replace('<!--shipping_goes_here-->', $html, $wrapper);
     if (strpos($html, 'checked') === false) {
         $html = $this->str_replace_once('"virtuemart_shipmentmethod_id"', '"virtuemart_shipmentmethod_id" checked="checked"', $html);
     }
     include JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'third_party' . DS . 'third_party_clear_shipping.php';
     // clear the settings:
     $cart->virtuemart_shipmentmethod_id = 0;
     $cart->virtuemart_paymentmethod_id = 0;
     $cart->automaticSelectedShipment = false;
     $cart->automaticSelectedPayment = false;
     $cart->setCartIntoSession();
     if (method_exists($calc, 'setCartPrices')) {
         $calc->setCartPrices(array());
     }
     return $html;
 }
コード例 #14
0
ファイル: javascript.php プロジェクト: aldegtyarev/stelsvelo
    public static function getJavascript(&$ref, &$OPCloader, $isexpress = false, $action_url = 'index.php', $option = 'com_virtuemart', $task = 'checkout')
    {
        //include (JPATH_OPC.DS.'ext'.DS.'extension.php');
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'ajaxhelper.php';
        $bhelper = new basketHelper();
        //$extHelper = new opExtension();
        //$extHelper->runExt('before');
        include JPATH_OPC . DS . 'config' . DS . 'onepage.cfg.php';
        // $ccjs = "\n".' var op_general_error = "'.OPCmini::slash(JText->_('CONTACT_FORM_NC')).'"; '."\n";
        // $ccjs .= ' var op_cca = "~';
        // COM_VIRTUEMART_ORDER_PRINT_PAYMENT
        $logged = OPCloader::logged($ref->cart);
        $user = JFactory::getUser();
        if ($user->id > 0) {
            $logged_in_joomla = true;
        } else {
            $logged_in_joomla = false;
        }
        // check if klarna enabled
        // let's include klarna from loadScriptAndCss:
        $db = JFactory::getDBO();
        $q = "select published from #__virtuemart_paymentmethods where payment_element = 'klarna' limit 0,1";
        $db->setQuery($q);
        $enabled = $db->loadResult();
        if (!empty($enabled)) {
            if (file_exists(JPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'klarna' . DS . 'klarna.php')) {
                $path = 'plugins/vmpayment/klarna';
            } else {
                $path = 'plugins/vmpayment';
            }
            $assetsPath = $path . '/klarna/assets/';
            JHTMLOPC::stylesheet('style.css', $assetsPath . 'css/', FALSE);
            JHTMLOPC::stylesheet('klarna.css', $assetsPath . 'css/', FALSE);
            JHTMLOPC::script('klarna_general.js', $assetsPath . 'js/', FALSE);
            JHTMLOPC::script('klarnaConsentNew.js', 'http://static.klarna.com/external/js/', FALSE);
            $document = JFactory::getDocument();
            $document->addScriptDeclaration('
		 klarna.ajaxPath = "' . JURI::root() . '/index.php?option=com_virtuemart&view=plugin&vmtype=vmpayment&name=klarna";
	');
        }
        // end
        // end
        $extJs = " var shipconf = []; var payconf = []; " . "\n";
        $virtuemart_currency_id = OPCloader::getCurrency($ref->cart);
        $extJs .= " var virtuemart_currency_id = '" . $virtuemart_currency_id . "'; ";
        //testing:
        if (!empty($opc_payment_refresh)) {
            $extJs .= " var opc_payment_refresh = true; ";
        } else {
            $extJs .= " var opc_payment_refresh = false; ";
        }
        if (!empty($opc_dynamic_lines)) {
            $extJs .= " var opc_dynamic_lines = true; ";
        } else {
            $extJs .= " var opc_dynamic_lines = false; ";
        }
        $extJs .= " var opc_default_option = '" . $option . "'; ";
        $extJs .= " var opc_default_task = '" . $task . "'; ";
        if ($opc_debug) {
            $extJs .= " var opc_debug = true; ";
        } else {
            $extJs .= " var opc_debug = false; ";
        }
        if (!empty($op_customer_shipping)) {
            $extJs .= " var op_customer_shipping = true; ";
        } else {
            $extJs .= " var op_customer_shipping = false; ";
        }
        if ($opc_async) {
            $extJs .= " var opc_async = true; ";
        } else {
            $extJs .= " var opc_async = false; ";
        }
        if ($payment_inside) {
            $extJs .= " var op_payment_inside = true; ";
        } else {
            $extJs .= " var op_payment_inside = false; ";
        }
        $extJs .= " var op_logged_in = '" . $logged . "'; ";
        $extJs .= " var op_last_payment_extra = null; ";
        $extJs .= " var op_logged_in_joomla = '" . $logged_in_joomla . "'; ";
        $extJs .= ' var op_shipping_div = null; ';
        $extJs .= ' var op_lastq = ""; ';
        $extJs .= ' var op_lastcountry = null; var op_lastcountryst = null; ';
        $extJs .= ' var op_isrunning = false; ';
        $extJs .= ' var COM_ONEPAGE_CLICK_HERE_TO_REFRESH_SHIPPING = "' . OPCloader::slash(OPCLang::_('COM_ONEPAGE_CLICK_HERE_TO_REFRESH_SHIPPING')) . '"; ';
        $extJs .= ' var COM_VIRTUEMART_LIST_EMPTY_OPTION = "' . OPCloader::slash(OPCLang::_('COM_VIRTUEMART_LIST_EMPTY_OPTION')) . '"; ';
        $extJs .= ' var COM_ONEPAGE_PLEASE_WAIT_LOADING = "' . OPCloader::slash(OPCLang::_('COM_ONEPAGE_PLEASE_WAIT_LOADING')) . '"; ';
        $theme = JRequest::getVar('opc_theme', '');
        $theme = preg_replace("/[^a-zA-Z0-9_]/", "", $theme);
        if (empty($theme)) {
            $theme = $selected_template;
        }
        $extJs .= ' var opc_theme = "' . OPCloader::slash($theme) . '"; ';
        $extJs .= ' var NO_PAYMENT_ERROR = "' . OPCloader::slash(JText::_('COM_VIRTUEMART_CART_SELECT_PAYMENT')) . '"; ';
        $extJs .= ' var JERROR_AN_ERROR_HAS_OCCURRED = "' . OPCloader::slash(OPCLang::_('JERROR_AN_ERROR_HAS_OCCURRED')) . '"; ';
        $extJs .= ' var COM_ONEPAGE_PLEASE_WAIT = "' . OPCloader::slash(OPCLang::_('COM_ONEPAGE_PLEASE_WAIT')) . '"; ';
        //$extJs .= ' var USERNAMESYNTAXERROR = "'.JText::_('', true).'"; ';
        if (!empty($op_usernameisemail)) {
            $extJs .= ' var op_usernameisemail = true; ';
        } else {
            $extJs .= ' var op_usernameisemail = false; ';
        }
        $url = OPCloader::getURL(true);
        if (!empty($op_loader)) {
            $extJs .= ' var op_loader = true; ';
        } else {
            $extJs .= ' var op_loader = false; ';
        }
        $extJs .= ' var op_loader_img = "' . $url . 'media/system/images/mootree_loader.gif";';
        if (!empty($double_email)) {
            if (!defined('op_doublemail_js')) {
                JHTMLOPC::script('doublemail.js', 'components/com_onepage/ext/doublemail/js/', false);
                define('op_doublemail_js', '1');
            }
        }
        if (!empty($onlyd)) {
            $extJs .= ' var op_onlydownloadable = "1"; ';
        } else {
            $extJs .= ' var op_onlydownloadable = ""; ';
        }
        if (!empty($op_last_field)) {
            $extJs .= ' var op_last_field = true; ';
        } else {
            $extJs .= ' var op_last_field = false; ';
        }
        $extJs .= ' var op_refresh_html = ""; ';
        if (!empty($no_alerts)) {
            $extJs .= ' var no_alerts = true; ';
        } else {
            $extJs .= ' var no_alerts = false; ';
        }
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        $extJs .= " var username_error = '" . OPCmini::slash(OPCLang::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', OPCLang::_('COM_VIRTUEMART_USERNAME'))) . "';";
        $extJs .= " var email_error = '" . OPCmini::slash(OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL'))) . "';";
        if (!empty($opc_no_duplicit_username)) {
            $extJs .= ' var opc_no_duplicit_username = true; ';
        } else {
            $extJs .= ' var opc_no_duplicit_username = false; ';
        }
        if (!empty($opc_no_duplicit_email)) {
            $extJs .= ' var opc_no_duplicit_email = true; ';
        } else {
            $extJs .= ' var opc_no_duplicit_email = false; ';
        }
        $extJs .= ' var last_username_check = true; ';
        $extJs .= ' var last_email_check = true; ';
        // stAn mod for OPC2
        /*
        if (!empty($op_delay_ship))
        $extJs .= " var op_delay = true; ";
        else $extJs .= " var op_delay = false; ";
        */
        if (!empty($op_delay_ship)) {
            $extJs .= " var op_delay = false; ";
        } else {
            $extJs .= " var op_delay = false; ";
        }
        if (empty($last_ship2_field)) {
            $last_ship2_field = '';
        }
        if (empty($last_ship_field)) {
            $last_ship_field = '';
        }
        $extJs .= " var op_last1 = '" . OPCmini::slash($last_ship_field) . "'; ";
        $extJs .= " var op_last2 = '" . OPCmini::slash($last_ship2_field) . "'; ";
        $url = JURI::root(true);
        if (empty($url)) {
            $url = '/';
        }
        if (substr($url, strlen($url) - 1) !== '/') {
            $url .= '/';
        }
        $actionurl = $url . 'index.php';
        if (version_compare(JVERSION, '2.5.0', 'ge')) {
            $extJs .= " var op_com_user = '******'; ";
            $extJs .= " var op_com_user_task = 'user.login'; ";
            $extJs .= " var op_com_user_action = '" . $actionurl . "?option=com_users&task=user.login&controller=user'; ";
            $extJs .= " var op_com_user_action_logout = '" . $actionurl . "?option=com_users&task=user.logout&controller=user'; ";
            $extJs .= " var op_com_user_task_logout = 'user.logout'; ";
        } else {
            if (version_compare(JVERSION, '1.7.0', 'ge')) {
                $extJs .= " var op_com_user = '******'; ";
                $extJs .= " var op_com_user_task = 'user.login'; ";
                $extJs .= " var op_com_user_action = '" . $actionurl . "?option=com_users&task=user.login&controller=user'; ";
                $extJs .= " var op_com_user_action_logout = '" . $actionurl . "?option=com_users&task=user.logout&controller=user'; ";
                $extJs .= " var op_com_user_task_logout = 'user.logout'; ";
                // Joomla! 1.7 code here
            } elseif (version_compare(JVERSION, '1.6.0', 'ge')) {
                // Joomla! 1.6 code here
            } else {
                $extJs .= " var op_com_user = '******'; ";
                $extJs .= " var op_com_user_task = 'login'; ";
                $extJs .= " var op_com_user_action = '" . $actionurl . "?option=com_user&task=login'; ";
                $extJs .= " var op_com_user_action_logout = '" . $actionurl . "?option=com_user&task=logout'; ";
                $extJs .= " var op_com_user_task_logout = 'logout'; ";
            }
        }
        $op_autosubmit = false;
        //$extHelper->runExt('autosubmit', '', '', $op_autosubmit);
        $extJs .= " var op_userfields_named = new Array(); ";
        if (!empty(OPCloader::$fields_names)) {
            foreach (OPCloader::$fields_names as $key => $val) {
                $extJs .= ' op_userfields_named[\'' . OPCmini::slash($key) . '\'] = \'' . OPCmini::slash($val) . '\'; ';
            }
        }
        $extJs .= " ";
        // let's create all fields here
        if (!class_exists('VirtueMartCart')) {
            require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
        }
        if (!isset($ref->cart)) {
            $ref->cart = $cart = VirtueMartCart::getCart();
        }
        $extJs .= " var op_userfields = new Array(";
        // updated on VM2.0.26D:
        /*
        if (!isset($ref->cart->STaddress)) $ref->cart->STaddress = array(); 
        if (!isset($ref->cart->BTaddress)) $ref->cart->BTaddress = array(); 
        $ref->cart->prepareAddressDataInCart('BTaddress', 0);
        $ref->cart->prepareAddressDataInCart('STaddress', 0);
        
        //$ref->cart->prepareAddressDataInCart('BT', 0);
        //$ref->cart->prepareAddressDataInCart('ST', 0);
        */
        //$userFieldsST = $ref->cart->STaddress;
        $userFieldsST = OPCloader::getUserFields('ST', $ref->cart);
        //$userFieldsBT = $ref->cart->BTaddress;
        $userFieldsBT = OPCloader::getUserFields('BT', $ref->cart);
        $fx = array();
        $ignore = array('delimiter', 'hidden');
        foreach ($userFieldsBT['fields'] as $k2 => $v2) {
            if (in_array($v2['type'], $ignore)) {
                continue;
            }
            $fx[] = '"' . OPCmini::slash($v2['name'], false) . '"';
        }
        foreach ($userFieldsST['fields'] as $k => $v) {
            if (in_array($v['type'], $ignore)) {
                continue;
            }
            $fx[] = '"' . OPCmini::slash($v['name'], false) . '"';
        }
        $fx2 = implode(',', $fx);
        $extJs .= $fx2 . '); ';
        //else
        //$extJs .= " var op_userfields = new Array(); ";
        $extJs .= ' var op_firstrun = true; ';
        //$extHelper->runExt('addjavascript', '', '', $extJs);
        if (!empty($business_fields)) {
            $business_fields2 = array();
            foreach ($business_fields as $k => $line) {
                $business_fields2[$k] = "'" . $line . "'";
            }
            $newa = implode(',', $business_fields2);
            $extJs .= ' var business_fields = [' . $newa . ']; ';
        } else {
            $extJs .= ' var business_fields = new Array(); ';
        }
        if (!empty($custom_rendering_fields)) {
            $custom_rendering_fields2 = array();
            foreach ($custom_rendering_fields as $k => $line) {
                $custom_rendering_fields2[$k] = "'" . $line . "'";
            }
            $newa = implode(',', $custom_rendering_fields2);
            $extJs .= ' var custom_rendering_fields = new Array(' . $newa . '); ';
        } else {
            $extJs .= ' var custom_rendering_fields = new Array(); ';
        }
        //shipping_obligatory_fields
        if (!empty($shipping_obligatory_fields)) {
            $shipping_obligatory_fields2 = array();
            foreach ($shipping_obligatory_fields as $k => $line) {
                $shipping_obligatory_fields2[$k] = "'" . $line . "'";
            }
            $newa = implode(',', $shipping_obligatory_fields2);
            $extJs .= ' var shipping_obligatory_fields = new Array(' . $newa . '); ';
        } else {
            $extJs .= ' var shipping_obligatory_fields = new Array(); ';
        }
        $extJs .= 'var shippingOpenStatus = false; ';
        if (empty($op_autosubmit)) {
            $extJs .= " var op_autosubmit = false; ";
        } else {
            $extJs .= " var op_autosubmit = true; ";
        }
        $db = JFactory::getDBO();
        $q = 'select * from #__virtuemart_vendors where virtuemart_vendor_id = 1 limit 0,1 ';
        $db->setQuery($q);
        $res = $db->loadAssoc();
        if (!empty($res)) {
            extract($res);
        }
        //VmConfig::get('useSSL',0)
        $mainframe = Jfactory::getApplication();
        $vendorId = JRequest::getInt('vendorid', 1);
        /* table vm_vendor */
        if (!class_exists('VirtueMartCart')) {
            require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
        }
        if (!class_exists('CurrencyDisplay')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
        }
        $virtuemart_currency_id = OPCloader::getCurrency($ref->cart);
        if (empty($ref->cart)) {
            $ref->cart = $cart = VirtueMartCart::getCart();
        }
        if (!empty($virtuemart_currency_id)) {
            $c = CurrencyDisplay::getInstance($virtuemart_currency_id);
        } else {
            $c = CurrencyDisplay::getInstance($ref->cart->paymentCurrency);
            $virtuemart_currency_id = $ref->cart->paymentCurrency;
        }
        if (!method_exists($c, 'getNbrDecimals')) {
            $db = JFactory::getDBO();
            $q = 'select * from #__virtuemart_currencies where virtuemart_currency_id = ' . (int) $virtuemart_currency_id . ' limit 0,1';
            $db->setQuery($q);
            $c2 = $db->loadObject();
            if (empty($c2)) {
                $c2 = new stdClass();
                $c2->currency_symbol = '$';
                $c2->currency_decimal_place = 2;
                $c2->currency_decimal_symbol = '.';
                $c2->currency_thousands = ' ';
                $c2->currency_positive_style = '{number} {symbol}';
                $c2->currency_negative_style = '{sign}{number} {symbol}';
            }
            // op_vendor_style = '1|&euro;|2|.|\'|3|0';
            $arr = array();
            $arr[0] = '1';
            $arr[1] = $c2->currency_symbol;
            $arr[2] = $c2->currency_decimal_place;
            $arr[3] = $c2->currency_decimal_symbol;
            $arr[4] = $c2->currency_thousands;
            // for now
            $arr[5] = '3';
            $arr[6] = '8';
            $arr[7] = '8';
            $arr[8] = $c2->currency_positive_style;
            $arr[9] = $c2->currency_negative_style;
            $vendor_currency_display_style = implode('|', $arr);
        } else {
            // op_vendor_style = '1|&euro;|2|.|\'|3|0';
            $arr = array();
            $arr[0] = '1';
            $arr[1] = $c->getSymbol();
            $arr[2] = $c->getNbrDecimals();
            $arr[3] = $c->getDecimalSymbol();
            $arr[4] = $c->getThousandsSeperator();
            // for now
            $arr[5] = '3';
            $arr[6] = '8';
            $arr[7] = '8';
            $arr[8] = $c->getPositiveFormat();
            $arr[9] = $c->getNegativeFormat();
            $vendor_currency_display_style = implode('|', $arr);
        }
        //$arr[2] = $c->
        $extJs .= " var op_saved_shipping = null; var op_saved_payment = null; var op_saved_shipping_vmid = '';";
        $cs = str_replace("'", '\\\'', $vendor_currency_display_style);
        $extJs .= " var op_vendor_style = '" . $cs . "'; ";
        $extJs .= " var op_currency_id = '" . $virtuemart_currency_id . "'; ";
        $extJs .= ' op_override_basket = true; ';
        $extJs .= ' op_basket_override = true; ';
        /*
        else 
        {
         $extJs .= ' op_override_basket = false; ';
         $extJs .= ' op_basket_override = false; ';
        }
        */
        //   if ($onlyindex) return JURI::root(true).'/index.php';
        if (empty($action_url)) {
            $action_url = JURI::root(true) . '/index.php?option=com_virtuemart&amp;view=opc&amp;controller=opc&amp;task=checkout&amp;nosef=1';
        }
        $action_url = html_entity_decode($action_url);
        $lang = JFactory::getLanguage();
        $locales = $lang->getLocale();
        if (!empty($locales[4])) {
            $action_url .= '&lang=' . $locales[4];
        }
        $extJs .= " var opc_action_url = '" . $action_url . "'; ";
        // google adwrods tracking code here
        if (!empty($adwords_enabled[0])) {
            $extJs .= " var acode = '1'; ";
        } else {
            $extJs .= " var acode = '0'; ";
        }
        $lang = JRequest::getVar('lang');
        if (ctype_alnum($lang)) {
            $extJs .= " var op_lang = '" . $lang . "'; ";
        } else {
            $extJs .= " var op_lang = ''; ";
        }
        $ur = JURI::root(true);
        if (substr($ur, strlen($ur) - 1) != '/') {
            $ur .= '/';
        }
        //$ur .= basename($_SERVER['PHP_SELF']);
        $mm_action_url = $ur;
        $isVm202 = false;
        if (!class_exists('VirtueMartModelShopperGroup')) {
            if (file_exists(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'shoppergroup.php')) {
                require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'shoppergroup.php';
            } else {
                $isVm202 = true;
            }
        }
        if (!method_exists('VirtueMartModelShopperGroup', 'appendShopperGroups')) {
            $isVm202 = true;
        }
        if (!$isVm202) {
            $extJs .= " var op_securl = '" . $ur . "index.php?option=com_onepage'; ";
        } else {
            $extJs .= " var op_securl = '" . $ur . "index.php?option=com_virtuemart'; ";
        }
        $extJs .= " var pay_btn = new Array(); ";
        $extJs .= " var pay_msg = new Array(); ";
        $extJs .= " pay_msg['default'] = ''; ";
        $extJs .= " pay_btn['default'] = '" . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU')) . "'; ";
        $extJs .= " var op_timeout = 0; ";
        if (!empty($adwords_timeout)) {
            $extJs .= " var op_maxtimeout = " . $adwords_timeout . "; ";
        } else {
            $extJs .= " var op_maxtimeout = 3000; ";
        }
        $extJs .= " var op_semafor = false; ";
        if (!empty($op_sum_tax)) {
            $extJs .= " var op_sum_tax = true; ";
        } else {
            $extJs .= " var op_sum_tax = false; ";
        }
        if (defined("_MIN_POV_REACHED") && constant("_MIN_POV_REACHED") == '1') {
            $extJs .= " var op_min_pov_reached = true; ";
        } else {
            $extJs .= " var op_min_pov_reached = false; ";
        }
        // this setting says if to show discountAmout together with the classic discount
        if (!empty($payment_discount_before)) {
            $extJs .= " var payment_discount_before = true; ";
        } else {
            $extJs .= " var payment_discount_before = false; ";
        }
        if (empty($hidep) || !empty($payment_inside)) {
            $extJs .= " var op_payment_disabling_disabled = true; ";
        } else {
            $extJs .= " var op_payment_disabling_disabled = false; ";
        }
        //$extJs .= " var op_show_prices_including_tax = '".$auth["show_price_including_tax"]."'; ";
        $extJs .= " var op_show_prices_including_tax = '1'; ";
        $extJs .= " var never_show_total = ";
        if (isset($never_show_total) && $never_show_total == true) {
            $extJs .= ' true; ' . "\n";
        } else {
            $extJs .= ' false; ' . "\n";
        }
        $extJs .= " var op_no_jscheck = ";
        // modified for OPC2
        if (!empty($no_jscheck)) {
            $extJs .= " true; ";
        } else {
            $extJs .= " true; ";
        }
        $extJs .= " var op_no_taxes_show = ";
        if (isset($no_taxes_show) && $no_taxes_show == true) {
            $extJs .= ' true; ' . "\n";
        } else {
            $extJs .= ' false; ' . "\n";
        }
        $extJs .= " var op_no_taxes = ";
        if (isset($no_taxes) && $no_taxes == true) {
            $extJs .= ' true; ' . "\n";
        } else {
            $extJs .= ' false; ' . "\n";
        }
        $selectl = OPCLang::_('COM_VIRTUEMART_LIST_EMPTY_OPTION');
        $extJs .= " var op_lang_select = '(" . $selectl . ")'; ";
        //if ((ps_checkout::tax_based_on_vendor_address()) && ($auth['show_price_including_tax']) && ((!isset($always_show_tax) || ($always_show_tax !== true))))
        //$extJs .= " var op_dont_show_taxes = '1'; ";
        //else
        $extJs .= " var op_dont_show_taxes = '0'; " . "\n";
        $extJs .= ' var op_coupon_amount = "0"; ' . "\n";
        $extJs .= ' var op_shipping_txt = "' . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_ORDER_PRINT_SHIPPING_PRICE_LBL'), false) . '"; ' . "\n";
        $extJs .= ' var op_shipping_tax_txt = "' . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_ORDER_PRINT_SHIPPING_TAX'), false) . '"; ' . "\n";
        $country_ship = array();
        if (false) {
            if (isset($hidep)) {
                foreach ($hidep as &$h) {
                    $h .= ',' . $payments_to_hide . ',';
                    $h = str_replace(' ', '', $h);
                    $h = ',' . $h . ',';
                }
            }
        }
        // found shipping methods
        // $sarr = $bhelper->getShippingArray();
        if (false) {
            foreach ($sarr as $k => $ship) {
                if (isset($hidep[$ship->virtuemart_shipmentmethod_id])) {
                    $extJs .= " payconf['" . $k . "']=\"," . $hidep[$k] . ",\"; ";
                } else {
                    $extJs .= " payconf['" . $k . "']=\",\"; ";
                }
            }
        }
        // old code for standard shipping
        if (!empty($rows)) {
            foreach ($rows as $r) {
                $id = $r['shipping_rate_id'];
                $cs = $r['shipping_rate_country'];
                $car = $r['shipping_rate_carrier_id'];
                $k = explode(';', $cs, 1000);
                foreach ($k as $kk) {
                    if ($kk != '') {
                        $krajiny[] = $kk;
                        if (!isset($country_ship[$id])) {
                            $country_ship[$id] = array();
                        }
                        $country_ship[$id][$kk] = $kk;
                    }
                }
                $extJs .= "shipconf[" . $id . "]=\"" . $cs . '"; ';
            }
        }
        // end of old code for standard shipping
        // country_ship description:
        // country_ship[ship_id][country] = country
        // country_ship will be used for default shipping method for selected default shipping country
        // global variables: ordertotal, currency symbol, text for order total
        //        echo $incship;
        $incship = OPCLang::_('COM_ONEPAGE_ORDER_TOTAL_INCL_SHIPPING');
        if (empty($incship)) {
            $incship = OPCLang::_('COM_VIRTUEMART_ORDER_LIST_TOTAL');
        }
        $incship = OPCmini::slash($incship);
        if (!empty($order_total)) {
            $extJs .= " var op_ordertotal = " . $order_total . "; ";
        } else {
            $extJs .= " var op_ordertotal = 0.0; ";
        }
        $extJs .= " var op_textinclship = '" . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_CART_TOTAL')) . "'; ";
        $extJs .= " var op_currency = '" . OPCmini::slash($c->getSymbol()) . "'; ";
        if (!empty($weight_total)) {
            $extJs .= " var op_weight = " . $weight_total . "; ";
        } else {
            $extJs .= " var op_weight = 0.00; ";
        }
        if (!empty($vars['zone_qty'])) {
            $extJs .= " var op_zone_qty = " . $vars['zone_qty'] . "; ";
        } else {
            $extJs .= " var op_zone_qty = 0.00; ";
        }
        if (!empty($grandSubtotal)) {
            $extJs .= " var op_grand_subtotal = " . $grandSubtotal . "; ";
        } else {
            $extJs .= " var op_grand_subtotal = 0.00; ";
        }
        $extJs .= ' var op_subtotal_txt = "' . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_CART_SUBTOTAL'), false) . '"; ';
        $extJs .= ' var op_tax_txt = "' . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL_TAX'), false) . '"; ';
        $op_disable_shipping = OPCloader::getShippingEnabled($ref->cart);
        if (!empty($op_disable_shipping)) {
            $nos = 'true';
        } else {
            $nos = 'false';
        }
        $extJs .= "var op_noshipping = " . $nos . "; ";
        $extJs .= "var op_autosubmit = false; ";
        //        $extJs .= " var op_tok = '".$_SESSION['__default']['session.token']."'; ";
        // array of avaiable country codes
        if (!empty($krajiny)) {
            $krajiny = array_unique($krajiny);
        }
        $rp_js = '';
        $extJs .= $rp_js . "\n";
        $ship_country_change_msg = OPCLang::_('COM_ONEPAGE_SHIP_COUNTRY_CHANGED');
        $extJs .= ' var shipChangeCountry = "' . OPCmini::slash($ship_country_change_msg, false) . '"; ' . "\n";
        $extJs .= ' var opc_free_text = "' . OPCmini::slash(OPCLang::_('COM_ONEPAGE_FREE', false)) . '"; ' . "\n";
        if (!empty($use_free_text)) {
            $extJs .= " var use_free_text = true; " . "\n";
        } else {
            $extJs .= " var use_free_text = false; " . "\n";
        }
        $ship_country_is_invalid_msg = OPCLang::_('COM_ONEPAGE_SHIP_COUNTRY_INVALID');
        $extJs .= ' var noshiptocmsg = "' . OPCmini::slash($ship_country_is_invalid_msg, false) . '"; ' . "\n";
        $extJs .= " var default_ship = null; " . "\n";
        $extJs .= ' var agreedmsg = "' . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_USER_FORM_BILLTO_TOS_NO', false)) . '"; ' . "\n";
        $extJs .= ' var op_continue_link = ""; ' . "\n";
        if ($must_have_valid_vat) {
            $extJs .= "var op_vat_ok = 2; var vat_input_id = \"" . $vat_input_id . "\"; var vat_must_be_valid = true; " . "\n";
        }
        $default_info_message = OPCLang::_('COM_ONEPAGE_PAYMENT_EXTRA_DEFAULT_INFO');
        $extJs .= ' var payment_default_msg = "' . str_replace('"', '\\"', $default_info_message) . '"; ' . "\n";
        $extJs .= ' var payment_button_def = "' . str_replace('"', '\\"', OPCLang::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU')) . '"; ' . "\n";
        if (empty($op_dontloadajax)) {
            $extJs .= ' var op_dontloadajax = false; ';
        } else {
            $extJs .= ' var op_dontloadajax = true; ';
        }
        $extJs .= ' var op_user_name_checked = false; ';
        $extJs .= ' var op_email_checked = false; ';
        // adds payment discount array
        //if (isset($pscript))
        //$extJs .= $pscript;
        if (isset($payments_to_hide)) {
            $payments_to_hide = str_replace(' ', '', $payments_to_hide);
        } else {
            $payments_to_hide = "";
        }
        // adds script to change text on the button
        if (isset($rp)) {
            $extJs .= $rp;
        }
        if (!(isset($vendor_name) && $vendor_name != '')) {
            $vendor_name = 'E-shop';
        }
        $extJs .= ' var op_vendor_name = "' . OPCmini::slash($vendor_name, false) . '"; ' . "\n";
        /*
        	if (!isset($_SESSION['__default']['session.token']))
        $_SESSION['__default']['session.token'] = md5(uniqid());
        $next_order_id = $bhelper->getNextOrderId(); 
        
        jimport( 'joomla.utilities.utility' );
        if (method_exists('JUtility', 'getToken'))
        $token = JUtility::getToken(); 
        else 
        $token = JSession::getFormToken(); 
        $token = md5($token); 
        $g_order_id = $next_order_id."_".$token;
        $extJs .= ' var g_order_id = "'.$g_order_id.'"; '."\n";
        */
        $extJs .= ' var op_order_total = 0; ' . "\n";
        $extJs .= ' var op_total_total = 0; ' . "\n";
        $extJs .= ' var op_ship_total = 0; ' . "\n";
        $extJs .= ' var op_tax_total = 0; ' . "\n";
        if (empty($op_fix_ins)) {
            $extJs .= 'var op_fix_payment_vat = false; ';
        }
        $extJs .= ' var op_run_google = new Boolean(';
        if (!empty($g_analytics)) {
            $extJs .= 'true); ';
        } else {
            $extJs .= 'false); ';
        }
        if (!isset($pth_js)) {
            $pth_js = '';
        }
        $extJs .= ' var op_always_show_tax = ';
        if (isset($always_show_tax) && $always_show_tax === true) {
            $extJs .= 'true; ' . "\n";
        } else {
            $extJs .= 'false; ' . "\n";
        }
        $extJs .= ' var op_always_show_all = ';
        if (isset($always_show_all) && $always_show_all === true) {
            $extJs .= 'true; ' . "\n";
        } else {
            $extJs .= 'false; ' . "\n";
        }
        $extJs .= ' var op_add_tax = ';
        if (isset($add_tax) && $add_tax === true) {
            $extJs .= 'true; ';
        } else {
            $extJs .= 'false; ';
        }
        $extJs .= ' var op_add_tax_to_shipping = ';
        if (isset($add_tax_to_shipping) && $add_tax_to_shipping === true) {
            $extJs .= 'true; ' . "\n";
        } else {
            $extJs .= 'false; ' . "\n";
        }
        $extJs .= ' var op_add_tax_to_shipping_problem = ';
        if (isset($add_tax_to_shipping_problem) && $add_tax_to_shipping_problem === true) {
            $extJs .= 'true; ' . "\n";
        } else {
            $extJs .= 'false; ' . "\n";
        }
        $extJs .= ' var op_no_decimals = ';
        if (isset($no_decimals) && $no_decimals === true) {
            $extJs .= 'true; ' . "\n";
        } else {
            $extJs .= 'false; ' . "\n";
        }
        $extJs .= ' var op_curr_after = ';
        if (isset($curr_after) && $curr_after === true) {
            $extJs .= 'true; ' . "\n";
        } else {
            $extJs .= 'false; ' . "\n";
        }
        if (empty($op_basket_subtotal_taxonly)) {
            $op_basket_subtotal_taxonly = '0.00';
        }
        $extJs .= ' var op_basket_subtotal_items_tax_only = ' . $op_basket_subtotal_taxonly . '; ';
        /*
        	can be send to js if needed: 
        			$op_basket_subtotal += $price["product_price"] * $cart[$i]["quantity"];
        		$op_basket_subtotal_withtax += ($price["product_price"] * $cart[$i]["quantity"])*($my_taxrate+1);
        		$op_basket_subtotal_taxonly +=  ($price["product_price"] * $cart[$i]["quantity"])*($my_taxrate);
        */
        $extJs .= ' var op_show_only_total = ';
        if (isset($show_only_total) && $show_only_total === true) {
            $extJs .= 'true; ' . "\n";
        } else {
            $extJs .= 'false; ' . "\n";
        }
        $extJs .= ' var op_show_andrea_view = ';
        if (isset($show_andrea_view) && $show_andrea_view === true) {
            $extJs .= 'true; ' . "\n";
        } else {
            $extJs .= 'false; ' . "\n";
        }
        $extJs .= ' var op_detected_tax_rate = "0"; ';
        $extJs .= ' var op_custom_tax_rate = ';
        if (empty($custom_tax_rate)) {
            $custom_tax_rate = '0.00';
        }
        $custom_tax_rate = str_replace(',', '.', $custom_tax_rate);
        $custom_tax_rate = str_replace(' ', '', $custom_tax_rate);
        if (!empty($custom_tax_rate) && is_numeric($custom_tax_rate)) {
            $extJs .= '"' . $custom_tax_rate . '"; ' . "\n";
        } else {
            $extJs .= '""; ' . "\n";
        }
        $extJs .= ' var op_coupon_discount_txt = "' . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_COUPON_DISCOUNT'), false) . '"; ' . "\n";
        $extJs .= ' var op_other_discount_txt = "' . OPCmini::slash(OPCLang::_('COM_ONEPAGE_OTHER_DISCOUNT'), false) . '"; ' . "\n";
        if (!empty($shipping_inside_basket)) {
            $extJs .= " var op_shipping_inside_basket = true; ";
        } else {
            $extJs .= " var op_shipping_inside_basket = false; ";
        }
        if (!empty($payment_inside_basket) && empty($isexpress)) {
            $extJs .= " var op_payment_inside_basket = true; ";
        } else {
            $extJs .= " var op_payment_inside_basket = false; ";
        }
        $extJs .= " var op_disabled_payments = \"{$pth_js}\"; \n";
        $extJs .= "var op_payment_discount = 0; \n var op_ship_cost = 0; \n var pdisc = []; " . "\n";
        $extJs .= 'var op_payment_fee_txt = "' . str_replace('"', '\\"', OPCLang::_('COM_VIRTUEMART_ORDER_PRINT_PAYMENT')) . '"; ' . "\n";
        // fee
        $extJs .= 'var op_payment_discount_txt = "' . str_replace('"', '\\"', OPCLang::_('COM_VIRTUEMART_CART_SUBTOTAL_DISCOUNT_AMOUNT')) . '"; ' . "\n";
        // discount
        //$rp_js = ' var pay_msg = []; var pay_btn = []; ';
        // paypal:
        if (false && $paypalActive) {
            $extJs .= ' var op_paypal_id = "' . ps_paypal_api::getPaymentMethodId() . '"; ';
        } else {
            $extJs .= ' var op_paypal_id = "x"; ';
        }
        if (false && $paypalActive && defined('PAYPAL_API_DIRECT_PAYMENT_ON') && (bool) PAYPAL_API_DIRECT_PAYMENT_ON) {
            $extJs .= ' var op_paypal_direct = true; ';
        } else {
            $extJs .= ' var op_paypal_direct = false; ';
        }
        $extJs .= ' var op_general_error = ' . "'" . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_USER_FORM_MISSING_REQUIRED')) . "';";
        $extJs .= ' var op_email_error = ' . "'" . OPCmini::slash(OPCLang::_('COM_VIRTUEMART_ENTER_A_VALID_EMAIL_ADDRESS')) . "';";
        $err = OPCJavascript::getPwdError();
        $extJs .= ' var op_pwderror = ' . "'" . OPCmini::slash($err) . "';\n";
        if ($double_email) {
            if (!OPCloader::logged($ref->cart)) {
                $extJs .= ' callSubmitFunct.push("Onepage.doubleEmailCheck"); ';
            }
        }
        if (!empty($disable_payment_per_shipping)) {
            $extJs .= ' addOpcTriggerer("callAfterShippingSelect", "Onepage.refreshPayment()"); ';
        }
        if (empty($no_coupon_ajax)) {
            $extJs .= 'jQuery(document).ready(function() {
     jQuery(\'#userForm\').bind(\'submit\',function(){
		 if (userForm.coupon_code != null)
		 if (userForm.coupon_code.value != null)
		 {
		 new_coupon = Onepage.op_escape(userForm.coupon_code.value); 
		 if (typeof Onepage != \'undefined\')
		 if (typeof Onepage.op_runSS != \'undefined\')
		 {
         Onepage.op_runSS(this, false, true, \'process_coupon&new_coupon=\'+new_coupon); 
		 return false; 
		 }
		 }
    });
    });';
        }
        //callAfterShippingSelect.push('hideShipto()');
        $inside = JRequest::getCmd('insideiframe', '');
        $js = '';
        if (!empty($inside)) {
            $js = "\n" . ' 
			if (typeof jQuery != \'undefined\' && (jQuery != null))
			{
			 jQuery(document).ready(function() {

			 if (typeof Onepage.op_runSS == \'undefined\') return;
			 ';
            if (!empty($inside)) {
                $js .= "\n" . ' op_resizeIframe(); ' . "\n";
            }
            $js .= ' 		 });
			}
			else
			 {
			   if ((typeof window != \'undefined\') && (typeof window.addEvent != \'undefined\'))
			   {
			   window.addEvent(\'domready\', function() {
			   ';
            if (!empty($inside)) {
                $js .= ' op_resizeIframe(); ';
            }
            $js .= '
			
			    });
			   } 
			  }';
        }
        $document = JFactory::getDocument();
        $raw_js = "\n" . $extJs . "\n" . $js . "\n";
        $src = '<script>' . "\n" . '//<![CDATA[' . $raw_js . '//]]> ' . "\n" . '</script>';
        $app = JFactory::getApplication();
        $jtouch = $app->getUserStateFromRequest('jtpl', 'jtpl', -1, 'int');
        if ($jtouch > 0) {
            $opc_php_js2 = true;
        }
        // stAn, updated on 2.0.218
        // stan, to support gk gavick mobile themes we had to omit the type
        if (empty($opc_php_js2)) {
            $document->addCustomTag($src);
            return;
        }
        $js_dir = JPATH_CACHE . DS . 'com_onepage';
        $lang = JFactory::getLanguage()->getTag();
        $js_file = 'opc_dynamic_' . $lang . '_' . md5($raw_js) . '.js';
        $js_path = $js_dir . DS . $js_file;
        $add = true;
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        if (!file_exists($js_dir)) {
            if (JFolder::create($js_dir) === false) {
                $add = true;
            }
        }
        if (!file_exists($js_path)) {
            if (JFile::write($js_path, $raw_js) !== false) {
                JHTMLOPC::script($js_file, 'cache/com_onepage/');
                return;
            } else {
                $add = true;
            }
        }
        if (!empty($opc_php_js2)) {
            if (file_exists($js_path)) {
                JHTMLOPC::script($js_file, 'cache/com_onepage/');
                return;
            }
        }
        if ($add) {
            $document->addCustomTag($src);
        }
        //echo $src;
        //$document->addCustomTag('<script type="text/javascript">'."\n".'//<![CDATA[  '."\n".$extJs."\n".$js."\n".'//]]> '."\n".'</script>');
        return;
    }
コード例 #15
0
ファイル: opctracking.php プロジェクト: aldegtyarev/stelsvelo
 public function __construct($orderID, $params2, $status, $params, $file = '')
 {
     $this->errorMsg = '';
     if (empty(OPCtrackingHelper::$config[$status])) {
         $this->errorMsg .= 'Config not found for status: ' . $status . "<br />\n";
         $this->error = true;
         return;
     }
     $this->params = new stdClass();
     if (!empty($params)) {
         $this->params = $params;
     }
     //$this->pingUrl = JRoute::_('index.php?option=com_onepage&task=ping&nosef=1&format=raw&tmpl=component', false);
     $this->pingUrl = OPCtrackingHelper::getUrl() . 'index.php?option=com_onepage&task=ping&nosef=1&format=raw&tmpl=component';
     if (method_exists('JApplication', 'getHash')) {
         $hashn = JApplication::getHash('opctracking');
     } else {
         $hashn = JUtility::getHash('opctracking');
     }
     $opchash = JRequest::getVar($hashn, false, 'COOKIE');
     $this->cookieHash = $opchash;
     $this->pingData = 'hash=' . $this->escapeSingle(str_replace('&', '&amp;', $opchash));
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $orderModel = OPCmini::getModel('orders');
     $this->order = $orderModel->getOrder($orderID);
     if (empty($this->order)) {
         $this->errorMsg .= 'Order not found: ' . var_export($config, true) . "<br />\n";
         $this->error = true;
         return;
     }
     if (empty($this->order['items']) || !is_array($this->order['items'])) {
         $this->errorMsg .= 'Order items not found: ' . var_export($config, true) . "<br />\n";
         $this->error = true;
         return;
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
     $negative_statuses = OPCconfig::getValue('tracking_negative', 'negative_statuses', 0, array());
     if (!empty($negative_statuses)) {
         $copy_negative_statuses = array();
         foreach ($negative_statuses as $key => $ng) {
             $copy_negative_statuses[$key] = $ng;
         }
         $negative_statuses = $copy_negative_statuses;
         if (is_array($negative_statuses)) {
             if (isset($this->order['details']['BT'])) {
                 if (in_array($this->order['details']['BT']->order_status, $negative_statuses)) {
                     OPCtrackingHelper::getNegativeOrder($this->order);
                 }
             }
         }
     }
     if (empty($this->order['details'])) {
         $this->errorMsg .= 'Order details not found: ' . var_export($config, true) . "<br />\n";
         $this->error = true;
         return;
     }
     // check if the tracking was enabled before or after the order was created
     if (is_array($this->order)) {
         if (!empty($this->order['details']['BT'])) {
             $c = $this->order['details']['BT']->created_on;
             $sql = $c;
             $date = new JDate($sql);
             $time = $date->toUnix();
             if (!empty(OPCtrackingHelper::$config)) {
                 if (!empty(OPCtrackingHelper::$config[$status])) {
                     // opc update, old codee:
                     $key = 'since' . $file;
                     if (!empty(OPCtrackingHelper::$config[$status]->{$key})) {
                         $since = OPCtrackingHelper::$config[$status]->{$key};
                         if ($since > $time) {
                             $this->errorMsg .= 'OPC tracking was created AFTER the order was created: ' . var_export(OPCtrackingHelper::$config, true) . 'order created on ' . $c . date(DATE_RFC2822, $time) . ' tracking created on ' . $since . date(DATE_RFC2822, $since) . " <br />\n";
                             $this->error = true;
                             return;
                         }
                     }
                     $key = $file . '_since';
                     if (!empty(OPCtrackingHelper::$config[$status]->{$key})) {
                         $since = OPCtrackingHelper::$config[$status]->{$key};
                         if ($since > $time) {
                             $this->errorMsg .= 'OPC tracking system plugin was set up AFTER the order was created: ' . var_export(OPCtrackingHelper::$config, true) . 'order created on ' . $c . ' ' . date(DATE_RFC2822, $time) . ' tracking created on ' . $since . date(DATE_RFC2822, $since) . " <br />\n";
                             $this->error = true;
                             return;
                         }
                     }
                 }
             }
         }
     }
     $this->error = false;
     $this->pingData .= '&order_status=' . $status;
     $this->pingData .= '&order_id=' . $orderID;
     OPCtrackingHelper::getTextFields($this->order);
     $this->vendor = OPCtrackingHelper::getVendorInfo($this->order['details']['BT']->virtuemart_vendor_id);
 }
コード例 #16
0
ファイル: config.php プロジェクト: aldegtyarev/stelsvelo
 function copylang()
 {
     $err = $this->getlangerr();
     $dbj = JFactory::getDBO();
     $prefix = $dbj->getPrefix();
     // CREATE TABLE recipes_new LIKE production.recipes; INSERT recipes_new SELECT * FROM production.recipes;
     foreach ($err as $table) {
         $table = $prefix . $table;
         $orig = str_replace(VMLANG, 'en_gb', $table);
         if ($this->tableExists($orig)) {
             $q = 'create table ' . $table . ' like ' . $orig;
             $dbj->setQuery($q);
             $dbj->query();
             $err = $dbj->getErrorMsg();
             if (!empty($err)) {
                 echo $err;
                 die('err config.php');
             }
             // INSERT INTO recipes_new SELECT * FROM production.recipes;
             $q = 'insert into ' . $table . ' select * from ' . $orig;
             $dbj->setQuery($q);
             $dbj->query();
             $err = $dbj->getErrorMsg();
             if (!empty($err)) {
                 echo $err;
                 die('err config.php');
             }
         }
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     OPCmini::clearTableExistsCache();
 }
コード例 #17
0
 function getPaymentMethods(&$order)
 {
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
         VmConfig::loadConfig();
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $sm = OPCmini::getModel('paymentmethod');
     $shipments = $sm->getPayments();
     return $shipments;
 }
コード例 #18
0
ファイル: xmlexport.php プロジェクト: aldegtyarev/stelsvelo
 private static function getItems($langs, $shoppergroups)
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'image.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'com_virtuemart_helper.php';
     $from = JRequest::getInt('from', 0);
     $to = JRequest::getInt('to', (int) OPCXmlExport::$config->product_count);
     $db = JFactory::getDBO();
     $lang = 'en_gb';
     //$q = 'select * from #__virtuemart_products as p inner join #__virtuemart_products_'.$lang.' as l on p.virtuemart_product_id = l.virtuemart_product_id and p.published = 1';
     $iter = 400;
     $rounds = 0;
     $rounds++;
     $q = 'select virtuemart_product_id from #__virtuemart_products as p';
     // order by virtuemart_product_id asc ';
     if (!((empty($from) || $from == 1) && $to == OPCXmlExport::$config->product_count)) {
         $q .= ' limit ' . $from . ', ' . $to;
     }
     //$ito =$is+$iter;
     //$q .= ' limit '.$is.', '.$ito;
     //echo $q.'<br />';
     /*
     	SELECT * 
     FROM `rg6ma_virtuemart_product_prices` 
     WHERE `virtuemart_product_id` = "68" 
     AND ( `virtuemart_shoppergroup_id` ="1" OR `virtuemart_shoppergroup_id` IS NULL OR `virtuemart_shoppergroup_id`="0") 
     AND ( (`product_price_publish_up` IS NULL OR `product_price_publish_up` = "0000-00-00 00:00:00" OR `product_price_publish_up` <= "2014-03-24 15:09:57" ) 
     AND (`product_price_publish_down` IS NULL OR `product_price_publish_down` = "0000-00-00 00:00:00" OR product_price_publish_down >= "2014-03-24 15:09:57" ) ) 
     AND( (`price_quantity_start` IS NULL OR `price_quantity_start`="0" OR `price_quantity_start` <= 1) 
     AND (`price_quantity_end` IS NULL OR `price_quantity_end`="0" OR `price_quantity_end` >= 1) )
     */
     $db->setQuery($q);
     //echo '3:'.round(memory_get_usage(FALSE)/1024/1024).'Mb<br />';
     //$products = $db->loadObjectList();
     //$products = $db->loadResultArray();
     $products = $db->loadAssocList();
     //echo '4:'.round(memory_get_usage(FALSE)/1024/1024).'Mb<br />';
     if (empty($products)) {
         return true;
     }
     foreach ($products as $n => $row) {
         $product_id = $row['virtuemart_product_id'];
         //$product_id = $row->virtuemart_product_id;
         //echo '3:'.round(memory_get_usage(FALSE)/1024/1024).'Mb<br />';
         $productModel = OPCmini::getModel('product');
         $product = self::getProduct($productModel, $shoppergroups, $langs, $product_id, true, true, false);
         //echo '4:'.round(memory_get_usage(FALSE)/1024).'Kb<br />';
         if (empty($product)) {
             echo 'x ';
             continue;
         }
         $vm1 = array();
         OPCXmlExport::addItem($product, $vm1);
     }
     if ($to >= OPCXmlExport::$config->product_count) {
         return true;
     }
     return false;
 }
コード例 #19
0
ファイル: renderer.php プロジェクト: aldegtyarev/stelsvelo
    public static function getCustomFields($virtuemart_product_id, $cart_key = '', $quantity = 1)
    {
        $html = '';
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        $product_model = OPCmini::getModel('product');
        $product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity, true);
        $customfieldModel = OPCmini::getModel('Customfields');
        if (!method_exists($customfieldModel, 'getproductCustomslist')) {
            return $html;
        }
        $product->customfields = $customfieldModel->getproductCustomslist($virtuemart_product_id);
        if (empty($product->customfields) and !empty($product->product_parent_id)) {
            //$product->customfields = $this->productCustomsfieldsClone($product->product_parent_id,true) ;
            $product->customfields = $customfieldModel->getproductCustomslist($product->product_parent_id, $virtuemart_product_id);
            $product->customfields_fromParent = TRUE;
        }
        $customfieldModel->getProductCustomsField($product);
        $product->customfields = $customfieldModel->getProductCustomsFieldCart($product);
        foreach ($product->customfields as $k => $custom) {
            if (!empty($custom->layout_pos)) {
                $product->customfieldsSorted[$custom->layout_pos][] = $custom;
                unset($product->customfields[$k]);
            }
        }
        $product->customfieldsSorted['normal'] = $product->customfields;
        unset($product->customfields);
        JHTMLOPC::script('opcattributes.js', 'components/com_onepage/assets/js/');
        $html .= '
		<form method="post" class="opccartproduct opc-recalculate" action="' . JRoute::_('index.php') . '">
		<input name="quantity[0]" class=".quantity-input" type="hidden" value="' . $quantity . '">
		
		<input name="virtuemart_product_id[0]" class="opc_product" type="hidden" value="' . $virtuemart_product_id . '">
		<input name="cart_key" value="' . $cart_key . '" type="hidden" />
		<input name="cart_virtuemart_product_id" value="' . $cart_key . '" type="hidden" />
		<div class="product-fields">';
        $custom_title = null;
        foreach ($product->customfieldsSorted as $positions => $val) {
            foreach ($val as $field) {
                if ($field->is_hidden) {
                    //OSP http://forum.virtuemart.net/index.php?topic=99320.0
                    continue;
                }
                if ($field->display) {
                    $html .= '<div class="product-field product-field-type-' . $field->field_type . '">';
                    if ($field->custom_title != $custom_title && $field->show_title) {
                        $html .= '<span class="product-fields-title" >' . JText::_($field->custom_title) . '</span>';
                        if ($field->custom_tip) {
                            $html .= JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png');
                        }
                    }
                    $display = $field->display;
                    $selected = self::getSelected($cart_key, $field->virtuemart_custom_id);
                    $display = str_replace(JText::_('COM_VIRTUEMART_CART_PRICE_FREE'), '', $display);
                    $display = str_replace('value="' . $selected . '"', ' checked="checked" selected="selected" value="' . $selected . '" ', $display);
                    $html .= '<div class="product-field-display" style="clear:both;">' . $display . '</div>
	    	    <span class="product-field-desc">' . jText::_($field->custom_field_desc) . '</span>
	    	</div>';
                    $custom_title = $field->custom_title;
                }
            }
        }
        $html .= '</div></form>';
        return $html;
    }
コード例 #20
0
ファイル: userfields.php プロジェクト: aldegtyarev/stelsvelo
 public static function hasMissingFields(&$BTaddress)
 {
     $ignore = array('delimiter', 'captcha', 'hidden');
     $types = array();
     foreach ($BTaddress as $key => $val) {
         //if (in_array($val['name'], $corefields)) continue;
         if (in_array($val['type'], $ignore)) {
             continue;
         }
         if (empty($val['value'])) {
             if (!empty($val['required'])) {
                 if ($key == 'virtuemart_state_id') {
                     $c = $BTaddress['virtuemart_country_id']['value'];
                     $stateModel = OPCmini::getModel('state');
                     //new VirtueMartModelState();
                     $states = $stateModel->getStates($c, true, true);
                     if (!empty($states)) {
                         return true;
                     }
                     continue;
                 }
                 return true;
             }
         }
         //$types[] = $val['type'];
     }
     return false;
 }
コード例 #21
0
ファイル: basket.php プロジェクト: aldegtyarev/stelsvelo
    public static function getBasket(&$ref, $OPCloader, $withwrapper = true, &$op_coupon = '', $shipping = '', $payment = '', $isexpress = false)
    {
        include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
        $has_k2 = OPCloader::tableExists('k2mart');
        if (!class_exists('ShopFunctions')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
        }
        if (!method_exists('ShopFunctions', 'convertWeightUnit')) {
            $opc_show_weight = false;
        }
        /*
           if (!class_exists('VirtueMartModelProduct'))
         require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php');
        */
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        $productClass = OPCmini::getModel('product');
        //new VirtueMartModelProduct();
        if (!class_exists('CurrencyDisplay')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
        }
        $currencyDisplay = CurrencyDisplay::getInstance($ref->cart->pricesCurrency);
        $google_html = '';
        $VM_LANG = new op_languageHelper();
        $product_rows = array();
        $p2 = $ref->cart->products;
        if (empty($ref->cart)) {
            $ref->cart = VirtueMartCart::getCart();
        }
        $vm2015 = false;
        $ref->cart->prices = $ref->cart->pricesUnformatted = OPCloader::getCheckoutPrices($ref->cart, false, $vm2015, 'opc');
        $useSSL = VmConfig::get('useSSL', 0);
        $action_url = $OPCloader->getActionUrl($OPCloader, true);
        $xi = 0;
        if (isset($currencyDisplay->_priceConfig)) {
            $savedConfig = $currencyDisplay->_priceConfig;
        }
        if (empty($product_price_display)) {
            $product_price_display = 'salesPrice';
        }
        //$test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax', 'costPrice');
        $test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax');
        // check price config
        $testf = false;
        foreach ($test_product_price_display as $product_price_display_test) {
            $test = $currencyDisplay->createPriceDiv($product_price_display, '', '10', false, false, 1);
            if (empty($test)) {
                if (isset($currencyDisplay->_priceConfig)) {
                    if (isset($currencyDisplay->_priceConfig[$product_price_display_test])) {
                        if (empty($currencyDisplay->_priceConfig[$product_price_display_test][0])) {
                            $currencyDisplay->_priceConfig[$product_price_display_test] = array(1, -1, 1);
                        }
                    }
                }
                $testf = true;
            } else {
                if (!isset($product_price_display_test2)) {
                    $product_price_display_test2 = $product_price_display_test;
                }
            }
        }
        if (empty($testf)) {
            $product_price_display = $product_price_display_test2;
        }
        $totalw = 0;
        $to_weight_unit = VmConfig::get('weight_unit_default', 'KG');
        foreach ($ref->cart->products as $pkey => $prow) {
            if ($opc_show_weight) {
                $totalw += ShopFunctions::convertWeightUnit((double) $prow->product_weight, $prow->product_weight_uom, $to_weight_unit) * (double) $prow->quantity;
            }
            $product = array();
            $id = $prow->virtuemart_media_id;
            if (empty($id)) {
                $imgf = '';
            } else {
                if (is_array($id)) {
                    $id = reset($id);
                }
                $imgf = $OPCloader->getImageFile($id);
            }
            $product['product_full_image'] = $imgf;
            if (!empty($opc_only_parent_links)) {
                if (!empty($prow->product_parent_id)) {
                    $parent = $prow->product_parent_id;
                    $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $parent . '&view=productdetails', true);
                }
            }
            // check if k2 exists:
            if (!isset($prow->url)) {
                if (isset($prow->link)) {
                    $prow->url = $prow->link;
                    if (strpos($prow->url, '&amp;') === false) {
                        $prow->url = str_replace('&', '&amp;', $prow->url);
                    }
                } else {
                    $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $prow->virtuemart_product_id . '&view=productdetails', true);
                }
            }
            if ($has_k2) {
                $db = JFactory::getDBO();
                $q = 'select baseID from #__k2mart where referenceID = ' . (int) $prow->virtuemart_product_id . ' limit 0,1';
                $db->setQuery($q);
                $k2_id = $db->loadResult();
                if (!empty($k2_id)) {
                    $prow->url = JRoute::_('index.php?option=com_k2&id=' . $k2_id . '&view=item', true);
                }
            }
            $product['product_name'] = JHTML::link($prow->url, $prow->product_name, ' class="opc_product_name" ');
            if ((!defined('VM_VERSION') || VM_VERSION < 3) && (isset($prow->customfields) && !is_array($prow->customfields))) {
                if (!empty($opc_editable_attributes)) {
                    $product['product_attributes'] = '<div style="clear:both;">' . OPCrenderer::getCustomFields($prow->virtuemart_product_id, $prow->cart_item_id, $prow->quantity) . '</div>';
                } else {
                    $product['product_attributes'] = $prow->customfields;
                }
            } else {
                $product['product_attributes'] = '';
            }
            /*
            var_dump($prow->customfields); 
            $cart = VirtuemartCart::getCart();
            
            $p = array(); 
            foreach ($cart->products as $k=>$v)
            {
              $p[$k] = $v; 
            } 
            unset($cart->products); 
            
            unset($cart->ST); 
            unset($cart->BT); 
            unset($cart->BTaddress); 
            unset($cart->STaddress); 
            $cart->products = $p; 
            $cart->setCartIntoSession(); 
            var_dump($cart->products); die(); 
            var_dump($cart); 
            JFactory::getApplication()->close(); 
            */
            if (defined('VM_VERSION') && VM_VERSION >= 3) {
            }
            if (isset($prow->customfields) && is_array($prow->customfields)) {
                $customfieldsModel = OPCmini::getModel('Customfields');
                $product['product_attributes'] = $customfieldsModel->CustomsFieldCartDisplay($prow);
            }
            $product['product_sku'] = $prow->product_sku;
            // end price test
            if (isset($prow->quantity)) {
                $product['product_quantity'] = $prow->quantity;
            }
            if (isset($prow->min_order_level)) {
                $product['min_order_level'] = $prow->min_order_level;
            }
            if (isset($prow->max_order_level)) {
                $product['max_order_level'] = $prow->max_order_level;
            }
            //$product_model = $OPCloader->getModel('product');
            $xi++;
            if (empty($no_extra_product_info)) {
                $prowcopy = $productClass->getProduct($prow->virtuemart_product_id, true);
            } else {
                $prowcopy = $prow;
            }
            $product['info'] = $prowcopy;
            $product['product'] = $prow;
            if (isset($ref->cart->prices[$pkey])) {
                $currentPrice = $ref->cart->prices[$pkey];
            } else {
                if (isset($prow->prices)) {
                    $currentPrice = $prow->prices;
                }
            }
            if ($product_price_display == 'salesPrice') {
                if (isset($prow->prices)) {
                    $product['product_price'] = $currentPrice['salesPrice'];
                } else {
                    if (isset($prow->salesPrice)) {
                        $product['product_price'] = $prow->salesPrice;
                    } else {
                        if (isset($prow->basePriceWithTax)) {
                            $product['product_price'] = $prow->basePriceWithTax;
                        } else {
                            if (isset($prow->basePrice)) {
                                $product['product_price'] = $prow->basePrice;
                            }
                        }
                    }
                }
            } else {
                if (isset($prow->prices)) {
                    $product['product_price'] = $currentPrice[$product_price_display];
                } else {
                    if (isset($prow->{$product_price_display})) {
                        $product['product_price'] = $prow->{$product_price_display};
                    } else {
                        if (isset($prow->salesPrice)) {
                            $product['product_price'] = $prow->salesPrice;
                        }
                    }
                }
            }
            if (!isset($product['product_price'])) {
                $price = $ref->cart->pricesUnformatted[$pkey];
                $product['product_price'] = $price[$product_price_display];
            }
            if (empty($product['product_price'])) {
                $product_price_display = 'salesPrice';
                $price = $ref->cart->pricesUnformatted[$pkey];
                $product['product_price'] = $price['salesPrice'];
            }
            $price_raw = $product['product_price'];
            // the quantity is not working up to 2.0.4
            $product['product_id'] = $prow->virtuemart_product_id;
            $google_html .= '<input type="hidden" name="prod_id" value="' . $prow->virtuemart_product_id . '" />
			   <input type="hidden" name="prodsku_' . $prow->virtuemart_product_id . '" id="prodsku_' . $prow->virtuemart_product_id . '" value="' . OPCloader::slash($prow->product_sku, false) . '" />
			   <input type="hidden" name="prodname_' . $prow->virtuemart_product_id . '" id="prodname_' . $prow->virtuemart_product_id . '" value="' . OPCloader::slash($prow->product_name, false) . '" />
			   <input type="hidden" name="prodq_' . $prow->virtuemart_product_id . '" id="prodq_' . $prow->virtuemart_product_id . '" value="' . $prow->quantity . '" />
			   <input type="hidden" name="produprice_' . $prow->virtuemart_product_id . '" id="produprice_' . $prow->virtuemart_product_id . '" value="' . $price_raw . '" />
			    <input type="hidden" name="prodcat_' . $prow->virtuemart_product_id . '" id="prodcat_' . $prow->virtuemart_product_id . '" value="' . $prow->category_name . '" />
			   
			   
			  ';
            if (isset($ref->cart->pricesUnformatted[$pkey])) {
                $price = $ref->cart->pricesUnformatted[$pkey];
            } else {
                $price = $prow->prices;
            }
            $product['prices'] = $price;
            $product['prices_formatted'] = array();
            if ($vm2015) {
                foreach ($price as $key => $pricev) {
                    //if (!isset($price[$key]))
                    if (!empty($pricev)) {
                        $product['prices_formatted'][$key] = $currencyDisplay->createPriceDiv($key, '', $price, false, true, 1);
                    }
                }
            }
            $product['product_price'] = $currencyDisplay->createPriceDiv($product_price_display, '', $price, false, true, 1);
            /*
            if (false)
            if (empty($product['product_price']))
            {
              // ok, we have a wrong type selected here
            				if ($product_price_display == 'salesPrice') 
            				$product['product_price'] = $currencyDisplay->createPriceDiv('basePrice','', $price,false,false, 1);
            				if (empty($product['product_price']))
            				$product['product_price'] = $currencyDisplay->createPriceDiv('priceWithoutTax','', $price,false,false, 1);
            				if (empty($product['product_price']))
            				$product['product_price'] = $currencyDisplay->createPriceDiv('basePriceWithTax','', $price,false,false, 1);
            				if (empty($product['product_price']))
            				$product['product_price'] = $currencyDisplay->createPriceDiv('priceBeforeTax','', $price,false,false, 1);
            				if (empty($product['product_price']))
            				$product['product_price'] = $currencyDisplay->createPriceDiv('costPrice','', $price,false,false, 1);
            				
            
            				 
            }
            */
            $product['product_price'] = str_replace('class="', 'class="opc_price_general opc_', $product['product_price']);
            if (!isset($prow->cart_item_id)) {
                $prow->cart_item_id = $pkey;
            }
            $v = array('product' => $prow, 'action_url' => $action_url, 'use_ssl' => $useSSL, 'useSSL' => $useSSL);
            if (!empty($ajaxify_cart)) {
                $update_form = $OPCloader->fetch($OPCloader, 'update_form_ajax.tpl', $v);
                $delete_form = $OPCloader->fetch($OPCloader, 'delete_form_ajax.tpl', $v);
            } else {
                $update_form = $OPCloader->fetch($OPCloader, 'update_form.tpl', $v);
                $delete_form = $OPCloader->fetch($OPCloader, 'delete_form.tpl', $v);
                $op_coupon_ajax = '';
            }
            if (empty($update_form)) {
                if (!empty($ajaxify_cart)) {
                    $product['update_form'] = '<input type="text" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" class="inputbox" size="3" name="quantity" id="quantity_for_' . md5($prow->cart_item_id) . '" value="' . $prow->quantity . '" /><a class="updatebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="#" rel="' . $prow->cart_item_id . '|' . md5($prow->cart_item_id) . '"> </a>';
                    $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="#" rel="' . $prow->cart_item_id . '"> </a>';
                } else {
                    $product['update_form'] = '<form action="' . $action_url . '" method="post" style="display: inline;">
				<input type="hidden" name="option" value="com_virtuemart" />
				<input type="text" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" class="inputbox" size="3" name="quantity" value="' . $prow->quantity . '" />
				<input type="hidden" name="view" value="cart" />
				<input type="hidden" name="task" value="update" />
				<input type="hidden" name="cart_virtuemart_product_id" value="' . $prow->cart_item_id . '" />
				<input type="submit" class="updatebtn" name="update" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" value=" "/>
			  </form>';
                    if (defined('VM_VERSION') && VM_VERSION >= 3) {
                        $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="' . JRoute::_('index.php?option=com_virtuemart&view=cart&task=delete.' . $prow->cart_item_id . '&cart_virtuemart_product_id=' . $prow->cart_item_id, true, $useSSL) . '"> </a>';
                    } else {
                        $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="' . JRoute::_('index.php?option=com_virtuemart&view=cart&task=delete&cart_virtuemart_product_id=' . $prow->cart_item_id, true, $useSSL) . '"> </a>';
                    }
                }
            } else {
                $product['update_form'] = $update_form;
                $product['delete_form'] = $delete_form;
            }
            if (!empty($ajaxify_cart)) {
                $product['update_form'] = str_replace('href=', 'onclick="return Onepage.updateProduct(this);" href=', $product['update_form']);
                $product['delete_form'] = str_replace('href=', 'onclick="return Onepage.deleteProduct(this);" href=', $product['delete_form']);
            }
            //vm3 update:
            if (defined('VM_VERSION') && VM_VERSION >= 3) {
                $product['update_form'] = str_replace('name="quantity"', 'name="quantity[' . $prow->cart_item_id . ']"', $product['update_form']);
                $product['update_form'] = str_replace('value="update"', 'value="updatecart"', $product['update_form']);
            }
            $product['subtotal'] = $prow->quantity * $price_raw;
            //else
            //$product['subtotal'] = $prow->subtotal_with_tax;
            // this is fixed from 2.0.4 and would not be needed
            if (isset($ref->cart->pricesUnformatted[$pkey])) {
                $copy = $ref->cart->pricesUnformatted[$pkey];
            } else {
                $copy = $prow->prices;
            }
            //$copy['salesPrice'] = $copy['subtotal_with_tax'];
            $copy[$product_price_display] = $product['subtotal'];
            $product['subtotal'] = $currencyDisplay->createPriceDiv($product_price_display, '', $copy, false, true, 1);
            $product['subtotal'] = str_replace('class="', 'class="opc_', $product['subtotal']);
            // opc vars
            $product_rows[] = $product;
            //break;
        }
        //$shipping_inside_basket = false;
        $shipping_select = $shipping;
        $payment_select = $payment;
        if (!empty($ref->cart->prices['salesPriceCoupon'])) {
            if (empty($coupon_price_display)) {
                $coupon_price_display = 'salesPriceCoupon';
            }
            $coupon_display = $currencyDisplay->createPriceDiv($coupon_price_display, '', $ref->cart->prices, false, true, 1);
            //$ref->cart->prices['salesPriceCoupon'];
            $coupon_display = str_replace('class="', 'class="opc_', $coupon_display);
        } else {
            $coupon_display = '';
        }
        if (!empty($coupon_display)) {
            $discount_after = true;
        } else {
            $discount_after = false;
        }
        if (empty($other_discount_display)) {
            $other_discount_display = 'billDiscountAmount';
        }
        switch ($other_discount_display) {
            case 'billDiscountAmount':
                $coupon_display_before = $currencyDisplay->createPriceDiv('billDiscountAmount', '', $ref->cart->prices, false, false, 1);
                if (empty($ref->cart->prices['billDiscountAmount'])) {
                    $coupon_display_before = '';
                }
                break;
            case 'discountAmount':
                $coupon_display_before = $currencyDisplay->createPriceDiv('discountAmount', '', $ref->cart->prices, false, false, 1);
                if (empty($ref->cart->prices['discountAmount'])) {
                    $coupon_display_before = '';
                }
            case 'minus':
                $billD = abs($ref->cart->prices['billDiscountAmount']);
                foreach ($ref->cart->prices as $key => $val) {
                    if (!empty($ref->cart->products[$key])) {
                        if (is_array($val)) {
                            $billD -= abs($val['subtotal_discount']);
                        }
                    }
                }
                $billD = abs($billD) * -1;
                $prices_new['billTotal'] = $billD;
                if (!empty($billD)) {
                    $coupon_display_before = $currencyDisplay->createPriceDiv('billTotal', '', $prices_new, false, false, 1);
                } else {
                    $coupon_display_before = '';
                }
                break;
            case 'sum':
                $billD = 0;
                foreach ($ref->cart->prices as $key => $val) {
                    if (!empty($ref->cart->products[$key])) {
                        if (is_array($val)) {
                            $billD += $val['subtotal_discount'];
                        }
                    }
                }
                $billD = abs($billD) * -1;
                $prices_new['billTotal'] = $billD;
                if (!empty($billD)) {
                    $coupon_display_before = $currencyDisplay->createPriceDiv('billTotal', '', $prices_new, false, false, 1);
                } else {
                    $coupon_display_before = '';
                }
                break;
        }
        $coupon_display_before = str_replace('class="', 'class="opc_', $coupon_display_before);
        //else $coupon_display_before = '';
        $opc_show_weight_display = '';
        if (!empty($opc_show_weight) && !empty($totalw)) {
            $dec = $currencyDisplay->getDecimalSymbol();
            $th = $currencyDisplay->getThousandsSeperator();
            $w = VmConfig::get('weight_unit_default', 'KG');
            $w = strtoupper($w);
            if ($w == 'OZ') {
                $w = 'OUNCE';
            }
            $unit = JText::_('COM_VIRTUEMART_UNIT_SYMBOL_' . $w);
            if ($unit == 'COM_VIRTUEMART_UNIT_SYMBOL_' . $w) {
                $unit = $w = VmConfig('weight_unit_default', 'kg');
            }
            $opc_show_weight_display = number_format($totalw, 2, $dec, $th) . ' ' . $unit;
        }
        if (!empty($ajaxify_cart)) {
            $coupon_text = $ref->cart->couponCode ? OPCLang::_('COM_VIRTUEMART_COUPON_CODE_CHANGE') : OPCLang::_('COM_VIRTUEMART_COUPON_CODE_ENTER');
            $vars = array('coupon_text' => $coupon_text, 'coupon_display' => $coupon_display);
            $op_coupon_ajax = $OPCloader->fetch($OPCloader, 'couponField_ajax', $vars);
            if (stripos($op_coupon_ajax, 'Onepage.setCouponAjax') === false) {
                $op_coupon_ajax = str_replace('type="button', 'onclick="return Onepage.setCouponAjax(this);" type="button', $op_coupon_ajax);
            }
        }
        if (empty($subtotal_price_display)) {
            $subtotal_price_display = 'salesPrice';
        }
        if ($subtotal_price_display != 'diffTotals') {
            $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $ref->cart->prices, false, false, 1);
            if ($subtotal_price_display == 'basePriceWithTax') {
                if (stripos($subtotal_display, ' ></span') !== false) {
                    $subtotal_price_display = 'salesPrice';
                    $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $ref->cart->prices, false, false, 1);
                }
            }
        } else {
            $subtotal = $ref->cart->prices['billTotal'] - $ref->cart->prices['billTaxAmount'];
            $arr = array('diffTotals' => $subtotal);
            $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $arr, false, false, 1);
        }
        //$ref->cart->prices['salesPrice'];
        $subtotal_display = str_replace('class="', 'class="opc_', $subtotal_display);
        $prices = $ref->cart->prices;
        if (!isset($prices[$subtotal_price_display . 'Shipment'])) {
            if ($subtotal_price_display != 'salesPrice') {
                $order_shipping = $prices['shipmentValue'];
            } else {
                $order_shipping = $prices['salesPriceShipment'];
            }
        } else {
            $order_shipping = $prices[$subtotal_price_display . 'Shipment'];
        }
        if (!empty($order_shipping)) {
            $virtuemart_currency_id = OPCloader::getCurrency($ref->cart);
            $order_shipping = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $order_shipping, false);
            $test = $currencyDisplay->createPriceDiv($product_price_display, '', $order_shipping, false, true, 1);
            if (!empty($test)) {
                $order_shipping = $test;
            }
            $order_shipping = str_replace('class="', 'class="opc_', $order_shipping);
        } else {
            $order_shipping = '';
        }
        $continue_link = $OPCloader->getContinueLink($ref);
        $order_total_display = $currencyDisplay->createPriceDiv('billTotal', '', $ref->cart->prices, false, false, 1);
        //$ref->cart->prices['billTotal'];
        $order_total_display = str_replace('class="', 'class="opc_', $order_total_display);
        // this will need a little tuning
        foreach ($ref->cart->cartData['taxRulesBill'] as $rule) {
            $rulename = $rule['calc_name'];
            if (!empty($ref->cart->prices[$rule['virtuemart_calc_id'] . 'Diff'])) {
                $tax_display = $currencyDisplay->createPriceDiv($rule['virtuemart_calc_id'] . 'Diff', '', $ref->cart->prices, false, false, 1);
                //$ref->cart->prices[$rule['virtuemart_calc_id'].'Diff'];
                $tax_display = str_replace('class="', 'class="opc_', $tax_display);
            } else {
                $tax_display = '';
            }
        }
        $op_disable_shipping = OPCloader::getShippingEnabled($ref->cart);
        if (!empty($payment_discount_before) && !empty($coupon_display_before)) {
            $discount_before = true;
        } else {
            $discount_before = false;
        }
        $disable_couponns = VmConfig::get('coupons_enable', true);
        if (empty($disable_couponns)) {
            $op_coupon = $op_coupon_ajax = '';
        }
        if (!empty($op_coupon_ajax)) {
            $op_coupon = $op_coupon_ajax;
        }
        if ($isexpress) {
            $payment_inside_basket = false;
        }
        if (empty($payment_inside_basket)) {
            $payment_select = '';
        }
        if (empty($shipping_inside_basket)) {
            $shipping_select = '';
        }
        if (empty($tax_display)) {
            $tax_display = '';
        }
        if (empty($op_disable_shipping)) {
            $op_disable_shipping = false;
        }
        $no_shipping = $op_disable_shipping;
        $vars = array('product_rows' => $product_rows, 'payment_inside_basket' => $payment_inside_basket, 'shipping_select' => $shipping_select, 'payment_select' => $payment_select, 'shipping_inside_basket' => $shipping_inside_basket, 'coupon_display' => $coupon_display, 'subtotal_display' => $subtotal_display, 'no_shipping' => $no_shipping, 'order_total_display' => $order_total_display, 'tax_display' => $tax_display, 'VM_LANG' => $VM_LANG, 'op_coupon_ajax' => $op_coupon_ajax, 'continue_link' => $continue_link, 'coupon_display_before' => $coupon_display_before, 'discount_before' => $discount_before, 'discount_after' => $discount_after, 'order_shipping' => $order_shipping, 'cart' => $ref->cart, 'op_coupon' => $op_coupon, 'opc_show_weight_display' => $opc_show_weight_display);
        //original cart support:
        $ref->cart->cartData['shipmentName'] = '';
        $ref->cart->cartData['paymentName'] = '';
        $totalInPaymentCurrency = $ref->getTotalInPaymentCurrency();
        $cd = CurrencyDisplay::getInstance($ref->cart->pricesCurrency);
        $layoutName = 'default';
        $confirm = 'confirm';
        $shippingText = '';
        $paymentText = '';
        $checkout_link_html = '';
        $useSSL = VmConfig::get('useSSL', 0);
        $useXHTML = true;
        $checkoutAdvertise = '';
        if (!class_exists('OPCrenderer')) {
            require JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'renderer.php';
        }
        $renderer = OPCrenderer::getInstance();
        if (method_exists($renderer, 'assignRef')) {
            $renderer->assignRef('cart', $renderer->cart);
            $renderer->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
            $renderer->assignRef('layoutName', $layoutName);
            $renderer->assignRef('select_shipment_text', $shippingText);
            $renderer->assignRef('checkout_task', $confirm);
            $renderer->assignRef('currencyDisplay', $cd);
            $renderer->assignRef('select_payment_text', $paymentText);
            $renderer->assignRef('checkout_link_html', $checkout_link_html);
            $renderer->assignRef('useSSL', $useSSL);
            $renderer->assignRef('useXHTML', $useXHTML);
            $renderer->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
            $renderer->assignRef('checkoutAdvertise', $checkoutAdvertise);
        }
        if (empty($use_original_basket)) {
            $html = $renderer->fetch($OPCloader, 'basket.html', $vars);
        } else {
            $html = $renderer->fetchBasket($OPCloader, 'basket.html', $vars);
        }
        if ($withwrapper) {
            $html = '<div id="opc_basket">' . $html . '</div>';
        }
        if (!empty($op_no_basket)) {
            $html = '<div style="display: none;">' . $html . '</div>';
        }
        if (isset($currencyDisplay->_priceConfig)) {
            $currencyDisplay->_priceConfig = $savedConfig;
        }
        $ret = $html . $google_html;
        return $ret;
    }
コード例 #22
0
 public static function addtocartaslink(&$ref)
 {
     $c = get_class($ref->cart);
     if ($c != 'VirtuemartCart') {
         $ref->cart = VirtuemartCart::getCart();
     }
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $rememberhtml = '';
     $rp = JRequest::getVar('randomproduct', 0);
     if (!empty($rp)) {
         if (OPCloader::checkOPCSecret()) {
             $opc_link_type = 1;
             $q = 'select virtuemart_product_id from #__virtuemart_products where published=1 limit 1';
             $db = JFactory::getDBO();
             $db->setQuery($q);
             $temp_id = $db->loadResult();
             JRequest::setVar('add_id', $temp_id);
         }
     }
     if (empty($opc_link_type)) {
         return;
     }
     $p_id = JRequest::getVar('add_id', '');
     if (empty($p_id)) {
         return;
     }
     if (!isset($ref->cart->order_number)) {
         $ref->cart->order_number = '';
     }
     if (!empty($p_id)) {
         $qq = array();
         if (is_array($p_id)) {
             foreach ($p_id as $i => $item) {
                 if (!is_numeric($p_id[$i])) {
                     break;
                 }
                 $q = JRequest::getVar('qadd_' . $p_id[$i], 1);
                 if (!is_numeric($q)) {
                     break;
                 }
                 $rememberhtml .= '<input type="hidden" name="qadd_' . $p_id[$i] . '" value="' . $q . '" />';
                 $rememberhtml .= '<input type="hidden" name="add_id[' . $i . ']" value="' . $p_id[$i] . '" />';
                 $q = (double) $q;
                 $qq[$p_id[$i]] = $q;
             }
         } else {
             // you can use /index.php?option=com_virtuemart&page=shop.cart&add_id=10&quadd=1;
             // to add two products (ids: 10 and 11) of two quantity each (quadd_11=2 for product id 11 set quantity 2)
             // OR /index.php?option=com_virtuemart&page=shop.cart&add_id[]=10&quadd_10=2&add_id[]=11&qadd_11=2
             $q = JRequest::getVar('qadd_' . $p_id, 1);
             $rememberhtml .= '<input type="hidden" name="qadd_' . $p_id . '" value="' . $q . '" />';
             $rememberhtml .= '<input type="hidden" name="add_id" value="' . $p_id . '" />';
             $q = (double) $q;
             $q2 = JRequest::getVar('qadd', 1);
             //$rememberhtml .= '<input type="hidden" name="qadd" value="'.$q2.'" />';
             if (!is_numeric($p_id)) {
                 return;
             }
             $qq[$p_id] = $q;
             $a = array();
             $a[$p_id] = $p_id;
             $p_id = $a;
         }
     } else {
         return;
     }
     $post = JRequest::get('default');
     /*
     	if (!class_exists('VirtueMartModelProduct'))
     require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php');
     */
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $productClass = OPCmini::getModel('product');
     //new VirtueMartModelProduct();
     //$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array'); //is sanitized then
     $newp = array();
     $rr2 = array();
     foreach ($p_id as $pid) {
         $newp[$pid] = $pid;
         $product = $productClass->getProductSingle($pid, true, true, true);
         $rr = OPCAddToCartAsLink::getProductCustomsFieldCart($product);
         $rr2[] = $rr;
     }
     if ($opc_link_type == 2 || $opc_link_type == 1) {
         if (!empty($ref->cart->products)) {
             $p = $ref->cart->products;
             foreach ($p as $key => $pr) {
                 $id = $pr->virtuemart_product_id;
                 // delete cart content
                 if ($opc_link_type == 1) {
                     if (isset($ref->cart->products[$key])) {
                         $ref->cart->removeProductCart($key);
                     } else {
                         if (isset($ref->cart->product[$id])) {
                             $ref->cart->removeProductCart($id);
                         }
                     }
                     continue;
                 }
                 // do not increment quantity:
                 if ($opc_link_type == 2) {
                     if (in_array($id, $newp)) {
                         return;
                     }
                 }
             }
         }
     }
     $virtuemart_product_ids = JRequest::setVar('virtuemart_product_id', $newp);
     //is sanitized then
     $virtuemart_product_ids = JRequest::setVar('quantity', $qq);
     //is sanitized then
     if (!empty($rr2)) {
         foreach ($rr2 as $rr1) {
             foreach ($rr1 as $post) {
                 $x = JRequest::getVar($post['name']);
                 if (empty($x)) {
                     $test = array();
                     if (strpos($post['name'], ']') !== false) {
                         $post['name'] = parse_str($post['name'] . '=' . $post['value'], $test);
                         $firstkey = 0;
                         if (!empty($test)) {
                             foreach ($test as $key => $val) {
                                 $firstkey = $key;
                                 break;
                             }
                         }
                         $name = $firstkey;
                         $value = $test[$name];
                         JRequest::setVar($name, $value);
                     } else {
                         JRequest::setVar($post['name'], $post['value']);
                     }
                 }
             }
         }
     }
     if (!empty($opc_auto_coupon)) {
         $ref->cart->couponCode = $opc_auto_coupon;
     }
     $ref->cart->add();
     JRequest::setVar('virtuemart_product_id', '');
     JRequest::setVar('add_id', '');
     JRequest::setVar('opc_adc', 1);
     //$quantityPost = (int) $post['quantity'][$p_key];
     return $rememberhtml;
 }
コード例 #23
0
ファイル: loader.php プロジェクト: aldegtyarev/stelsvelo
 /**
  * Check if a minimum purchase value for this order has been set, and if so, if the current
  * value is equal or hight than that value.
  * @author Oscar van Eijk
  * @return An error message when a minimum value was set that was not eached, null otherwise
  */
 public static function checkPurchaseValue($cart)
 {
     $s = $cart->virtuemart_shipmentmethod_id;
     $p = $cart->virtuemart_paymentmethod_id;
     $cart->virtuemart_shipmentmethod_id = 0;
     $cart->virtuemart_paymentmethod_id = 0;
     $ret = '';
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $vendor = OPCmini::getModel('vendor');
     if (empty($vendor)) {
         return;
     }
     $vendor->setId($cart->vendorId);
     $store = $vendor->getVendor();
     if ($store->vendor_min_pov > 0) {
         $vm2015 = true;
         $prices = OPCloader::getCheckoutPrices($cart, false, $vm2015, null);
         if (!empty($prices['couponValue']) || !empty($prices['salesPriceCoupon'])) {
             $ret = '';
         } else {
             if ($prices['salesPrice'] < $store->vendor_min_pov) {
                 if (!class_exists('CurrencyDisplay')) {
                     require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
                 }
                 $currency = CurrencyDisplay::getInstance();
                 $ret = JText::sprintf('COM_VIRTUEMART_CART_MIN_PURCHASE', $currency->priceDisplay($store->vendor_min_pov));
             }
         }
     }
     $cart->virtuemart_shipmentmethod_id = $s;
     $cart->virtuemart_paymentmethod_id = $p;
     return $ret;
 }
コード例 #24
0
ファイル: tracking.php プロジェクト: aldegtyarev/stelsvelo
    function setEnabled($enabled = null, $order = null)
    {
        if (is_null($enabled)) {
            $enabled = JRequest::getVar('adwords_enabled_0', false);
        }
        $order = JRequest::getInt('tracking_order', 9999);
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        OPCmini::clearTableExistsCache();
        if (!OPCmini::tableExists('virtuemart_plg_opctracking')) {
            $db = JFactory::getDBO();
            $q = '
	CREATE TABLE IF NOT EXISTS `#__virtuemart_plg_opctracking` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`virtuemart_order_id` int(11) NOT NULL,
	`hash` varchar(32) NOT NULL,
	`shown` text NOT NULL,
	`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
	`created_by` int(11) NOT NULL,
	`modified` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
	`modified_by` int(11) NOT NULL,
	PRIMARY KEY (`id`),
	UNIQUE KEY `hash_2` (`hash`,`virtuemart_order_id`),
	KEY `virtuemart_order_id` (`virtuemart_order_id`),
	KEY `hash` (`hash`)
	) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=27 ;';
            $db->setQuery($q);
            $db->query();
            $e = $db->getErrorMsg();
            if (!empty($e)) {
                return $e;
            }
        }
        //update from prior opc versions:
        $db = JFactory::getDBO();
        $q = "delete from `#__extensions` WHERE  element = 'opctracking' and folder = 'system' ";
        $db->setQuery($q);
        $db->query();
        OPCmini::clearTableExistsCache();
        if (!file_exists(JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'opctracking')) {
            jimport('joomla.filesystem.folder');
            jimport('joomla.filesystem.file');
            if (JFolder::create(JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'opctracking') !== false) {
                JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'install' . DS . 'opctracking' . DS . 'opctracking.php', JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'opctracking' . DS . 'opctracking.php');
                JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'install' . DS . 'opctracking' . DS . 'opctracking.xml', JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'opctracking' . DS . 'opctracking.xml');
                JFile::copy(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'install' . DS . 'opctracking' . DS . 'index.html', JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'opctracking' . DS . 'index.html');
            } else {
                return JText::sprintf('COM_ONEPAGE_CANNOT_CREATE_DIRECTORY', JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'opctracking');
            }
        }
        if (!empty($enabled)) {
            $db = JFactory::getDBO();
            $q = "select * from #__extensions where element = 'opctracking' and type='plugin' and folder='vmpayment' limit 0,1";
            $db->setQuery($q);
            $isInstalled = $db->loadAssoc();
            if (empty($isInstalled)) {
                $q = ' INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES ';
                $q .= " (NULL, 'plg_vmpayment_opctracking', 'plugin', 'opctracking', 'vmpayment', 0, 1, 1, 0, '{\"legacy\":false,\"name\":\"plg_vmpayment_opctracking\",\"type\":\"plugin\",\"creationDate\":\"December 2013\",\"author\":\"RuposTel s.r.o.\",\"copyright\":\"RuposTel s.r.o.\",\"authorEmail\":\"admin@rupostel.com\",\"authorUrl\":\"www.rupostel.com\",\"version\":\"1.7.0\",\"description\":\"One Page Checkout Affiliate Tracking support for VirtueMart 2\",\"group\":\"\"}', '{}', '', '', 0, '0000-00-00 00:00:00', '" . $order . "', 0) ";
                $db->setQuery($q);
                $db->query();
                $e = $db->getErrorMsg();
                if (!empty($e)) {
                    return $e;
                }
            } else {
                $order = JRequest::getVar('tracking_order', null);
                if (!empty($order)) {
                    $q = " UPDATE `#__extensions` SET  `enabled` =  '1', `ordering`='" . $order . "', state = 0 WHERE  element = 'opctracking' and folder = 'vmpayment' ";
                    $db->setQuery($q);
                    $db->query();
                    $e = $db->getErrorMsg();
                    if (!empty($e)) {
                        return $e;
                    }
                }
            }
        } else {
            $db = JFactory::getDBO();
            $q = "select * from #__extensions where element = 'opctracking' and type='plugin' and folder='vmpayment' limit 0,1";
            $db->setQuery($q);
            $isInstalled = $db->loadAssoc();
            if (!empty($isInstalled)) {
                $db = JFactory::getDBO();
                $q = " UPDATE `#__extensions` SET  enabled =  '0', ordering='" . $order . "', state = 0 WHERE  element = 'opctracking' and folder = 'vmpayment' ";
                $db->setQuery($q);
                $db->query();
                $e = $db->getErrorMsg();
                if (!empty($e)) {
                    return $e;
                }
            }
        }
        OPCmini::clearTableExistsCache();
        return '';
    }