function getShipping(&$ref, &$cart, $ajax = false) { if (empty($cart)) { if (!empty($ref->cart)) { $cart =& $ref->cart; } else { $cart = VirtueMartCart::getCart(false, false); } } include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; $cmd = JRequest::getVar('cmd', false); //$methods = OPCloader::getPluginMethods(); if (!$ajax) { if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); if (!isset($cart)) { $cart = VirtueMartCart::getCart(); } $plugins = array(); $html = ''; $results = $dispatcher->trigger('loadPluginJavascriptOPC', array(&$cart, &$plugins, &$html)); //include(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'helpers'.DS.'third_party'.DS.'third_party_shipping_javascript.php'); if (!empty($html)) { OPCloader::$extrahtml .= $html; } unset($html); // so we don't update the address twice require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'controllers' . DS . 'opc.php'; $c = new VirtueMartControllerOpc(); $c->setAddress($cart, true, false, true); } if ($cmd != 'customershipping' && $cmd != 'runpay') { if (!empty($op_customer_shipping)) { $onclick = 'onclick="javascript: return Onepage.op_runSS(null, false, true, \'customershipping\');" '; $html = $this->fetch($ref, 'customer_shipping', array('onclick' => $onclick)); if (empty($html)) { $html = '<a href="#" ' . $onclick . ' >' . OPClang::_('COM_ONEPAGE_CLICK_HERE_TO_DISPLAY_SHIPPING') . '</a>'; } $html .= '<input type="hidden" name="invalid_country" id="invalid_country" value="invalid_country" /><input type="hidden" name="virtuemart_shipmentmethod_id" checked="checked" id="shipment_id_0" value="choose_shipping" />'; $shipping_choose_html = '<div id="customer_shipping_wrapper">' . $html . '</div>'; $shipping_choose_html_a = array(); $shipping_choose_html_a[] = $shipping_choose_html; } } require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'ajaxhelper.php'; $bhelper = new basketHelper(); if (!isset($shipping_choose_html_a)) { $sh = $bhelper->getShippingArrayHtml($ref, $cart, $ajax); } else { $sh = $shipping_choose_html_a; } if (empty($cart) || empty($cart->products)) { $op_disable_shipping = OPCloader::getShippingEnabled($cart); if (empty($op_disable_shipping)) { $html = '<input type="hidden" name="invalid_country" id="invalid_country" value="invalid_country" /><input type="hidden" name="virtuemart_shipmentmethod_id" checked="checked" id="shipment_id_0" value="choose_shipping" />'; } $html .= '<div style="color: red; font-weight: bold;">' . OPCLang::_('COM_VIRTUEMART_EMPTY_CART') . '</div>'; $sh = array($html); } if (!empty($disable_payment_per_shipping)) { $session = JFactory::getSession(); $dpps = array(); require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'transform.php'; foreach ($sh as $k => $cs) { foreach ($dpps_search as $key => $val) { // if we find the need in the shipping, let's associate it with an id $val = urldecode($val); if (strpos($cs, $val) !== false) { //if (!empty($dpps[$key])) continue; $id = OPCTransform::getFT($cs, 'input', 'virtuemart_shipmentmethod_id', 'name', 'virtuemart_shipmentmethod_id', '>', 'value'); if (is_array($id)) { $id = reset($id); } if (empty($dpps[$key])) { $dpps[$key] = array(); } $dpps[$key][] = $id; } } } $session->set('dpps', $dpps); } if ($cart->pricesUnformatted['billTotal'] && empty($cart->pricesUnformatted['billTotal'])) { $ph = array(); } else { $ph = $bhelper->getPaymentArray(); } $bhelper->createDefaultAddress($ref, $cart); $html = $bhelper->getPaymentArrayHtml($ref->cart, $ph, $sh); self::$totals_html = basketHelper::$totals_html; $bhelper->restoreDefaultAddress($ref, $cart); //$ret = implode('<br />', $sh); $ret = ''; $ret .= $html; return $ret; }
function opc() { if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php'; OPCloader::$debugMsg = ''; //mobile handling: if (!defined('OPC_DETECTED_DEVICE')) { if (class_exists('OPCplugin')) { OPCplugin::detectMobile(); } } if (!class_exists('OPCLang')) { require JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php'; } OPCLang::loadLang(); require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php'; //$this->setShopperGroups(); $userModel = OPCmini::getModel('user'); $cmd = JRequest::getVar('cmd', ''); if ($cmd === 'checkbitvat') { $checkvat = $this->checkBitVat(); } if ($cmd === 'checkvatopc') { $checkvat = $this->checkOPCVat(); } OPCShopperGroups::setShopperGroupsController(); if (method_exists($userModel, 'getCurrentUser')) { $user = $userModel->getCurrentUser(); self::$shopper_groups = $user->shopper_groups; if (!empty($user->virtuemart_shipmentmethod_id)) { $user->virtuemart_shipmentmethod_id = 0; $user->virtuemart_paymentmethod_id = 0; } } $session = JFactory::getSession(); $b = $session->set('eurobnk', null, 'vm'); if (empty($euvat_shopper_group)) { jimport('joomla.html.parameter'); if (class_exists('plgSystemBit_vm_change_shoppergroup')) { $session = JFactory::getSession(); $sg = $session->get('vm_shoppergroups_add', array(), 'vm'); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system', 'plgSystemBit_vm_change_shoppergroup', true, $dispatcher); // very important $document = JFactory::getDocument(); JRequest::setVar('format_override', 'html'); $_REQUEST['view'] = 'cart'; $_REQUEST['option'] = 'com_virtuemart'; $doctype = $document->getType(); $dispatcher->trigger('onAfterRender'); JRequest::setVar('format_override', 'raw'); $sg = $session->get('vm_shoppergroups_add', array(), 'vm'); } } JResponse::setBody(''); // security: JRequest::setVar('virtuemart_shoppergroup_id', null, 'post'); if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(true); // since vm2.0.21a we need to load the language files here if (method_exists('VmConfig', 'loadJLang')) { $lang = JFactory::getLanguage(); $extension = 'com_virtuemart'; $lang->load($extension); // when AJAX it needs to be loaded manually here >> in case you are outside virtuemart !!! VmConfig::loadJLang('com_virtuemart_orders', true); VmConfig::loadJLang('com_virtuemart_shoppers', true); } /// load shipping here $vars = JRequest::get('post'); // custom tag test $cmd = JRequest::getVar('cmd', 'get_shipping'); $doc = JFactory::getDocument(); $type = get_class($doc); if ($type == 'JDocumentRAW') { //C:\Documents and Settings\Rupos\Local Settings\Temp\scp02371\srv\www\clients\client1\web90\web\vm2\components\com_onepage\overrides\ //require_once(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'overrides'.DS.'opchtml.php'); //JFactory::$instance = new JDocumentOpchtml(); //JFactory::$document = new JDocumentOpchtml(); } /* $doc->addCustomTag = create_function('$string', 'return;'); $doc->addCustomTag( '<!-- This is a comment. -->' ); */ $c = JRequest::getVar('virtuemart_currency_id', 0); JRequest::setVar('virtuemart_currency_id', (int) JRequest::getVar('virtuemart_currency_id')); /* to test the currency: */ $mainframe = Jfactory::getApplication(); $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id')); // end custom tag test $view = $this->getView('cart', 'html'); $cmd = JRequest::getCmd('cmd', 'get_shipping'); $return = array(); $return['cmd'] = $cmd; if (!empty($checkvat)) { $return['checkvat'] = $checkvat; } $db = JFactory::getDBO(); $username = JRequest::getVar('username', ''); $user = JFactory::getUser(); $un = $user->get('username'); if ($un == $username) { // do not complain if entering the same username of already registered $return['username_exists'] = false; } else { if (!empty($username)) { $q = "select username from #__users where username = '******' limit 0,1"; $db->setQuery($q); $r = $db->loadResult(); if (!empty($r)) { $return['username_exists'] = true; } else { $return['username_exists'] = false; } } } if ($cmd === 'checkemail') { $email = JRequest::getVar('email', ''); $return['email'] = $email; $user = JFactory::getUser(); $ue = $user->get('email'); if ($email == $ue) { // do not complain if user is logged in and enters the same email address $return['email_exists'] = false; } else { if (!empty($email)) { $q = "select email from #__users where username = '******' or email = '" . $db->getEscaped($email) . "' limit 0,1"; $db->setQuery($q); $r = $db->loadResult(); if (!empty($r)) { $return['email_exists'] = true; } else { $return['email_exists'] = false; } } } } if ($cmd === 'get_klarna_address') { if (file_exists(JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'klarna' . DS . 'klarna' . DS . 'api' . DS . 'klarna.php')) { $klarnaaddress = $this->getKlarnaAddress(); if (!empty($klarnaaddress)) { echo json_encode(array('cmd' => 'getKlarna', 'shipping' => 'opc_do_not_update', 'klarna' => $klarnaaddress, 'totals_html' => '', 'payment' => '')); $mainframe = JFactory::getApplication(); // do not allow further processing $mainframe->close(); } } } if (!defined('JPATH_OPC')) { define('JPATH_OPC', JPATH_SITE . DS . 'components' . DS . 'com_onepage'); } require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php'; require_once JPATH_OPC . DS . 'helpers' . DS . 'ajaxhelper.php'; include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; $OPCloader = new OPCloader(); $cart = VirtueMartCart::getCart(false); $opcsavedST = $cart->ST; $opcsavedBT = $cart->BT; $stopen = JRequest::getVar('shiptoopen', 0); if ($stopen === 'false') { $stopen = 0; } if (empty($stopen)) { $sa = JRequest::getVar('sa', ''); if ($sa == 'adresaina') { $stopen = 1; } } if ($stopen) { $restoreST = false; $restoreBT = true; } else { $cart->ST = 0; $restoreST = true; $restoreBT = false; } //$virtuemart_currency_id; = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id',JRequest::getInt('virtuemart_currency_id') ); $cart->paymentCurrency = $virtuemart_currency_id; if (defined('VM_VERSION') && VM_VERSION >= 3) { if (method_exists($cart, 'prepareCartProducts')) { $cart->prepareCartProducts(); } } if ($cmd === 'getST') { require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loggedshopper.php'; $return['sthtml'] = OPCLoggedShopper::getSTHtml($cart); } if (!isset($cart->vendorId)) { $cart->vendorId = 1; } if ($cmd == 'updateattributes') { $arr = $this->updateattributes($cart); if (!empty($arr)) { foreach ($arr as $key => $val) { $return[$key] = $val; } } } if ($cmd == 'update_product') { if (defined('VM_VERSION') && VM_VERSION >= 3) { $quantity = JRequest::getVar('quantity'); if (!is_array($quantity)) { $cart_virtuemart_product_id = JRequest::getVar('cart_virtuemart_product_id'); $arr = array($cart_virtuemart_product_id => (int) $quantity); JRequest::setVar('quantity', $arr); $x = JRequest::getVar('quantity'); } } $cart->updateProductCart(); } if ($cmd == 'delete_product') { $cart->updateProductCart(); } if ($cmd == 'removecoupon') { JRequest::setVar('coupon_code', ''); $_REQUEST['coupon_code'] = $_POST['coupon_code'] = $_GET['coupon_code'] = ''; $cart->couponCode = ''; //$this->setCoupon($cart); $deletecouponmsg = true; } $cp = 0; if (method_exists($cart, 'prepareCartProducts')) { $cart->prepareCartProducts(); } $cart->setCartIntoSession(); $stopen = JRequest::getVar('shiptoopen', false); //if (!empty($stopen)) if ($stopen === 'true' || $stopen === '1') { $stopen = true; $sa = JRequest::setVar('sa', 'adresaina'); } else { $stopen = false; } //$this->setAddress($cart, true, $stopen); $this->setAddress($cart); $BT = $cart->BT; if ($stopen) { $this->setAddress($cart, true, $stopen); $cart->BT = $BT; } else { $cart->ST = 0; } //die('h'); $this->setExtAddress($cart, false, $stopen); $zip = JRequest::getVar('shipto_zip'); // IMPORTANT: this function calls shipping if Vm's automatic enabled if (method_exists($cart, 'prepareCartData')) { $cart->prepareCartData(false); } // US and Canada fix, show no tax for no state selected if (!isset($cart->BT['virtuemart_state_id'])) { $cart->BT['virtuemart_state_id'] = ''; } if (!empty($cart->ST)) { // if the VM uses BT address instead of ST address in calculation, uncomment the following line: // $cart->BT = $cart->ST; // this only applies to the display of the checkout, not actual saving of the data if (!isset($cart->ST['virtuemart_state_id'])) { $cart->ST['virtuemart_state_id'] = ''; } } @header('Content-Type: text/html; charset=utf-8'); @header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past // run vm main controlle due to compatibilty JPluginHelper::importPlugin('vmextended'); JPluginHelper::importPlugin('vmuserfield'); $dispatcher = JDispatcher::getInstance(); $_controller = 'cart'; $trigger = 'onVmSiteController'; $trigger = 'plgVmOnMainController'; $dispatcher->trigger($trigger, array($_controller)); // this function will reload the taxes on products per country // this calls api methods as well, let's disable it for now: $cart->virtuemart_shipmentmethod_id = 0; if (method_exists($cart, 'prepareCartViewData')) { $cart->prepareCartViewData(); } if (!empty($virtuemart_currency_id)) { $cart->paymentCurrency = $virtuemart_currency_id; } if ($cmd == 'process_coupon') { $cart->couponCode = JRequest::getVar('coupon_code', ''); $this->setCoupon($cart); // set coupon } $view->cart = $cart; $view->assignRef('cart', $cart); //if (($cmd != 'runpay') && ($cmd != 'refreshPayment')) // this influences the recalculation of the basket: $cmds = array('process_coupon', 'refresh-totals', 'refresh_totals', 'removecoupon', 'delete_product', 'update_product', 'checkvatopc', 'delete_product', 'update_product', 'updateattributes', 'get_shipping'); if (empty($cmd) || in_array($cmd, $cmds) || stripos($cmd, 'shipping') !== false) { $shipping = $OPCloader->getShipping($view, $cart, true); $saved_totals = OPCloader::$totals_html; } else { $shipping = 'opc_do_not_update'; OPCloader::$totals_html = ''; } $return['shipping'] = $shipping; if (empty(OPCloader::$inform_html)) { OPCloader::$inform_html = array(); } $return['inform_html'] = implode('', OPCloader::$inform_html); if (!empty($cart->couponCode)) { $db = JFactory::getDBO(); $q = "select * from #__virtuemart_coupons where coupon_code = '" . $db->getEscaped($cart->couponCode) . "' limit 0,1"; $db->setQuery($q); $res = $db->loadAssoc(); if (!empty($res)) { if ($res['percent_or_total'] == 'percent') { $cp = $res['coupon_value']; } } if (empty($cp)) { if (OPCloader::tableExists('awocoupon')) { $db = JFactory::getDBO(); $q = "select * from #__awocoupon where coupon_code = '" . $db->getEscaped($cart->couponCode) . "' and coupon_value_type = 'percent' limit 0,1"; $db->setQuery($q); $res = $db->loadAssoc(); if (!empty($res)) { $cp = $res['coupon_value']; } } } } if (!empty($cp)) { $cp = (double) $cp; if (round($cp) == $cp) { $cp = (int) $cp . ' %'; } else { $cp = number_format($cp, 2, '.', ' ') . ' %'; } } $return['couponpercent'] = $cp; // get payment html $num = 0; if ($cmd == 'runpay') { $view->cart->virtuemart_shipmentmethod_id = JRequest::getVar('shipping_rate_id', ''); } $isexpress = OPCloader::isExpress($cart); $ph2_a = $OPCloader->getPayment($view, $num, false, $isexpress); $ph2 = $ph2_a['html']; $return['payment_extra'] = $ph2_a['extra']; /* if (!empty($ph_a['extra'])) { foreach ($ph_a['extra'] as $key=>$val) { $return['payment_extra'].$val; } } */ if ($cmd == 'runpay') { $cart->virtuemart_shipmentmethod_id = null; } if (!empty(OPCloader::$totalIsZero)) { $hide_payment_if_one = true; $num = 1; $ph2 = '<input type="hidden" value="0" name="virtuemart_paymentmethod_id" id="virtuemart_paymentmethod_id_0" />'; } if (!empty($hide_payment_if_one) && $num === 1 || $isexpress) { $ph = '<div class="payment_inner_html" rel="force_hide_payments">' . $ph2; } else { $ph = '<div class="payment_inner_html" rel="force_show_payments">' . $ph2; } $ph .= '</div>'; $return['payment'] = $ph; if (isset($saved_totals)) { $return['totals_html'] = $saved_totals; } else { $return['totals_html'] = OPCloader::$totals_html; } $return['min_pov'] = OPCloader::checkPurchaseValue($cart); if (!empty($return['totals_html'])) { $session = JFactory::getSession(); /* $r = $session->get('opcuniq'); if (empty($r)) { $rand = uniqid('', true); $session->set('opcuniq', $rand); $session->set($rand, '0'); } */ $rand = uniqid('', true); $return['totals_html'] .= '<input type="hidden" name="opcuniq" value="' . $rand . '" />'; } $t = $return['shipping'] . ' ' . $return['payment']; $t = str_replace('//<![CDATA[', '', $t); $t = str_replace('//]]> ', '', $t); $t = str_replace('<![CDATA[', '', $t); $t = str_replace(']]> ', '', $t); $t = str_replace('#paymentForm', '#adminForm', $t); //$t = str_replace('jQuery(document).ready(', ' jQuery( ', $t); $js = array(); if (strpos($t, '<script') !== false) { $xa = basketHelper::strposall($t, '<script'); foreach ($xa as $st) { // end of <script tag $x1 = strpos($t, '>', $st + 1); // end of </scrip tag $x2 = strpos($t, '</scrip', $st + 1); $js1 = substr($t, $x1 + 1, $x2 - $x1 - 1); $js[] = $js1; } } $return['shipping'] .= JHtml::_('form.token'); $return['payment'] .= JHtml::_('form.token'); if (isset(VmPlugin::$ccount)) { if (!empty($opc_debug)) { $js[] = "\n" . 'op_log("Positive cache match: ' . VmPlugin::$ccount . '");'; } } if (!empty($opc_debug)) { if (defined('OPCMEMSTART')) { $mem = memory_get_usage(true); $memd = $mem - OPCMEMSTART; $memd = (double) ($memd / 1024); $memd = number_format($memd, 0, '.', ' '); if (!defined('debugmem')) { $debugmem = $mem - OPCMEMSTART; $debugmem = (double) ($debugmem / 1024); } else { $debugmem = (double) (debugmem / 1024); } $debugmem = number_format($debugmem, 0, '.', ' '); $mem = (double) ($mem / 1024); $mem = number_format($mem, 0, '.', ' '); $js[] = "\n" . 'op_log("Memory usage: ' . $memd . 'kb of ' . $mem . 'kb, debug mem: ' . $debugmem . 'kb ");'; } } $return['javascript'] = $js; $return['opcplugins'] = OPCloader::getPluginData($cart); require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'removemsgs.php'; OPCremoveMsgs::removeMsgs($cart); $x = JFactory::getApplication()->getMessageQueue(); $arr = array(); $disablarray = array('Unrecognised mathop', JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS')); include JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'third_party' . DS . 'third_party_disable_msgs.php'; $euvat_text = array('VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_VALID', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_COUNTRYCODE', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_FORMAT_REASON', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_FORMAT', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_SERVICE_UNAVAILABLE', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_COMPANYNAME_REQUIRED'); foreach ($euvat_text as $k => $t) { $tt = JText::_($t); $euvat_text[$k] = substr($tt, 0, 20); } $euvatinfo = ''; $remove = array(); foreach ($x as $key => $val) { foreach ($euvat_text as $kx => $eutext) { // echo 'comparing '.$eutext.' with '.$val['message']."<br />\n"; if (stripos($val['message'], $eutext) !== false) { $euvatinfo .= $val['message']; $remove[] = $key; break; } } foreach ($disablarray as $msg) { if (stripos($val['message'], $msg) !== false) { $remove[] = $key; } if (stripos($val['message'], JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID')) !== false) { $cart->couponCode = ''; $cart->setCartIntoSession(); } } } if (!empty($euvatinfo)) { $return['checkvat'] = $euvatinfo; } foreach ($x as $key => $val) { if (!in_array($key, $remove)) { $arr[] = $val['message']; } } $return['msgs'] = $arr; if (!empty($opc_debug)) { if (!empty(OPCloader::$debugMsg)) { $return['debug_msgs'] = OPCloader::$debugMsg; } } if (!empty($cart->couponCode)) { $return['couponcode'] = $cart->couponCode; } else { $return['couponcode'] = ''; } require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php'; OPCShopperGroups::setShopperGroupsController($cart); $upd = array('update_product', 'delete_product', 'process_coupon', 'removecoupon', 'updateattribute', 'refreshall', 'updateattributes', 'checkvatopc', 'checkvat', 'vat_info'); if (in_array($cmd, $upd) || stripos($cmd, 'shipping') !== false || !empty($ajaxify_cart)) { if ($shipping == 'opc_do_not_update') { $shipping = ''; } if (!empty($ph2_a['html'])) { $payment_html = $op_payment = '<div id="payment_html">' . $ph2_a['html'] . '</div>'; } else { $payment_html = $op_payment = '<div id="payment_html"> </div>'; } $html = $this->getCartHtml($cart, $OPCloader, $shipping, $payment_html); $return['basket'] = $html; } $cart->virtuemart_shipmentmethod_id = 0; $cart->virtuemart_paymentmethod_id = 0; $cart->setCartIntoSession(); $x = @ob_get_clean(); $x = @ob_get_clean(); $x = @ob_get_clean(); $x = @ob_get_clean(); //echo json_encode(''); echo json_encode($return); //echo $shipping; $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('updateAbaData', array()); if ($restoreBT) { $cart->BT = $opcsavedBT; } if ($restoreST) { $cart->ST = $opcsavedST; } $cart->setCartIntoSession(); $mainframe = JFactory::getApplication(); // do not allow further processing $mainframe->close(); die; }
public static function getValFT($temp, $mustProp) { // example data-usps='{"service":"Parcel Post","rate":15.09}' // or id="xyz" if (substr($mustProp, strlen($mustProp) - 1) == '*') { $sb = substr($mustProp, 0, -1); $x51 = stripos($temp, $sb); if ($x51 === false) { return false; } $x5 = stripos($temp, '=', $x51); } else { $x5 = stripos($temp, $mustProp . '='); } if ($x5 === false) { return false; } $single = false; $x4 = stripos($temp, '"', $x5); $x42 = stripos($temp, "'", $x5); if ($x42 !== false && $x4 !== false) { if ($x42 < $x4) { // we will start with ' instead of " $x4 = $x42; $single = true; } } // search for start and end by ' if ($single) { //$x4 = stripos($temp, "'", $x5); if ($x4 !== false) { //$single = true; if ($single) { $x6e = basketHelper::strposall($temp, "'", $x4 + 1); } else { $x6e = basketHelper::strposall($temp, '"', $x4 + 1); } if (!empty($x6e)) { foreach ($x6e as $x6test) { if (substr($temp, $x6test - 1, 1) != urldecode('%5C')) { $x6 = $x6test; break; } } } //$x6 = stripos($temp, "'", $x4+1); } } if ($x4 === false) { return ""; } // search for end by " if (!$single) { if (!isset($x6)) { $x6e = basketHelper::strposall($temp, '"', $x4 + 1); foreach ($x6e as $x6test) { if (substr($temp, $x6test - 1, 1) != urldecode('%5C')) { $x6 = $x6test; break; } } //$x6 = stripos($temp, '"', $x4+1); } } if (!isset($x6)) { return ""; echo $mustProp . ' in: ' . $temp . ' ' . $x4; } if ($x6 === false) { return ""; } $val = substr($temp, $x4 + 1, $x6 - $x4 - 1); return $val; return false; }
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; }