* @subpackage themes
* @copyright Copyright (C) 2008 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
* @author Erich Vinson
* http://virtuemart.net
*/
mm_showMyFileName(__FILE__);
require_once CLASSPATH . 'payment/ps_paypal_api.cfg.php';
require_once CLASSPATH . 'payment/ps_paypal_api.php';
if ($_REQUEST['page'] == 'shop.cart') {
    ps_paypal_api::destroyPaypalSession();
}
// Paypal API / Express
// ToDo: Replace Text with Language Variable
if (!defined('_MIN_POV_REACHED')) {
    ?>
    <span style="font-weight:bold;"><?php 
    echo $VM_LANG->_('PHPSHOP_CHECKOUT_ERR_MIN_POV2') . " " . $CURRENCY_DISPLAY->getFullValue($_SESSION['minimum_pov']);
    ?>
</span>
<?php 
} else {
    if ($_REQUEST['page'] == 'shop.cart' && (PAYPAL_API_CART_BUTTON_ON == '1' || PAYPAL_API_CART_BUTTON_ON == 1)) {
        $paypal_express_href = $sess->url($_SERVER['PHP_SELF'] . '?page=checkout.index&ssl_redirect=1&ppex=1', true);
        echo '<a href="' . $paypal_express_href . '"><img src="https://www.paypal.com/' . $ppex_img_iso . '/i/btn/btn_xpressCheckout.gif" align="left" style="float: right;" alt="Paypal Express Checkout" title="Click here for Paypal Express Checkout!" align="right"></a>';
    }
Beispiel #2
0
 function NVP_DoDirectPaymentRequest(&$d, $dbbt, $dbst, $order_total, $payment_action, $ordernum, $requireCVV)
 {
     global $vendor_mail, $vendor_currency, $VM_LANG;
     if (isset($_SESSION['ccdata']['order_payment_number'])) {
         $cc_first_digit = substr($_SESSION['ccdata']['order_payment_number'], 0, 1);
         $cc_first_2_digits = substr($_SESSION['ccdata']['order_payment_number'], 0, 2);
         // Figure out the card type.
         switch ($cc_first_digit) {
             case "4":
                 $cc_type = urlencode("Visa");
                 break;
             case "5":
                 $cc_type = urlencode("MasterCard");
                 break;
             case "3":
                 switch ($cc_first_2_digits) {
                     case "34":
                         $cc_type = urlencode("Amex");
                         break;
                     case "37":
                         $cc_type = urlencode("Amex");
                         break;
                     case "30":
                         $cc_type = urlencode("Discover");
                         break;
                     case "36":
                         $cc_type = urlencode("Discover");
                         break;
                     case "38":
                         $cc_type = urlencode("Discover");
                         break;
                     default:
                         return false;
                         break;
                 }
                 break;
             case "6":
                 $cc_type = urlencode("Discover");
                 break;
             default:
                 return false;
                 break;
         }
         //Gather all required data
         //Remove any dashes or spaces in the credit card number
         $tmp_number = str_replace('-', '', $_SESSION['ccdata']['order_payment_number']);
         $tmp_number = str_replace(' ', '', $tmp_number);
         $cc_number = urlencode($tmp_number);
         if (isset($_SESSION['ccdata']['credit_card_code'])) {
             $cc_cvv2 = urlencode($_SESSION['ccdata']['credit_card_code']);
         } else {
             if ($requireCVV == 'YES') {
                 return false;
             }
         }
         $cc_expires_month = $_SESSION['ccdata']['order_payment_expire_month'];
         $cc_expires_year = $_SESSION['ccdata']['order_payment_expire_year'];
         //$cc_owner = ($_SESSION['ccdata']['order_payment_name']);
         //$cc_first = urlencode(substr($cc_owner, 0,(strrpos($cc_owner, " "))));
         //$cc_last = urlencode(substr($cc_owner,(strrpos($cc_owner, ' ') + 1),strlen($cc_owner)));
         $cc_expDate = urlencode($cc_expires_month . $cc_expires_year);
         $subject = urlencode('');
         $payer = urlencode($dbbt->f("user_email"));
         $first_name = urlencode(substr($dbbt->f("first_name"), 0, 50));
         $last_name = urlencode(substr($dbbt->f("last_name"), 0, 50));
         $currency_type = $GLOBALS['product_currency'];
         $ps_checkout = new ps_checkout();
         $order_totals = $ps_checkout->calc_order_totals($d);
         $tax_total = round($d['order_tax'], 2);
         $ship_total = isset($d['shipping_total']) ? round($d['shipping_total'], 2) : 0;
         $useshipping = PAYPAL_API_USE_SHIPPING;
         $db_new = new ps_DB();
         $query_str = "SELECT * FROM #__{vm}_country WHERE country_3_code='" . substr($dbbt->f("country"), 0, 60) . "'";
         $db_new->setQuery($query_str);
         $db_new->query();
         $db_new->next_record();
         $address_street1 = urlencode(substr($dbbt->f("address_1"), 0, 60));
         $address_city = urlencode(substr($dbbt->f("city"), 0, 40));
         $address_state = urlencode(substr($dbbt->f("state"), 0, 40));
         $address_country = urlencode($db_new->f("country_2_code"));
         $address_zip = urlencode(substr($dbbt->f("zip"), 0, 20));
         $query_str = "SELECT * FROM #__{vm}_country WHERE country_3_code='" . substr($dbst->f("country"), 0, 60) . "'";
         $db_new->setQuery($query_str);
         $db_new->query();
         $db_new->next_record();
         $ship_name = urlencode(trim(substr($dbst->f("first_name"), 0, 50) . ' ' . substr($dbst->f("last_name"), 0, 50)));
         $ship_street1 = urlencode(substr($dbst->f("address_1"), 0, 60));
         $ship_street2 = urlencode(substr($dbst->f("address_2"), 0, 60));
         $ship_city = urlencode(substr($dbst->f("city"), 0, 40));
         $ship_state = urlencode(substr($dbst->f("state"), 0, 40));
         $ship_country = urlencode($db_new->f("country_2_code"));
         $ship_zip = urlencode(substr($dbst->f("zip"), 0, 20));
         //Begin putting together our NVP Request
         $nvpreq = "&PAYMENTACTION={$payment_action}" . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'] . "&CREDITCARDTYPE={$cc_type}" . "&ACCT={$cc_number}" . "&EXPDATE={$cc_expDate}" . "&EMAIL={$payer}" . "&FIRSTNAME={$first_name}" . "&LASTNAME={$last_name}";
         if ($requireCVV == 'YES') {
             if (isset($cc_cvv2)) {
                 $nvpreq .= "&CVV2={$cc_cvv2}";
             } else {
                 return false;
             }
         }
         $nvpreq .= "&STREET={$address_street1}" . "&CITY={$address_city}" . "&STATE={$address_state}" . "&COUNTRYCODE={$address_country}" . "&ZIP={$address_zip}" . "&SHIPPINGAMT={$ship_total}";
         $nvpreq .= "&CURRENCYCODE={$currency_type}&TAXAMT={$tax_total}&DESC={$subject}&INVNUM={$ordernum}&BUTTONSOURCE=Virtuemart_Cart_DP";
         $nvpreq .= ps_paypal_api::getCartnvpstr($order_totals);
         //Put together Shipping NVP request
         $nvpreq .= "&AMT={$order_total}";
         if ($useshipping == '1') {
             $nvpreq .= "&SHIPTONAME={$ship_name}" . "&SHIPTOSTREET={$ship_street1}" . "&SHIPTOSTREET2={$ship_street2}" . "&SHIPTOCITY={$ship_city}" . "&SHIPTOSTATE={$ship_state}" . "&SHIPTOZIP={$ship_zip}" . "&SHIPTOCOUNTRYCODE={$ship_country}";
         }
         //return response to ps_paypal_wpp.php
         return $nvpreq;
     } else {
         return false;
     }
 }
Beispiel #3
0
$ps_product_category = new ps_product_category();
$ps_product = new ps_product();
// Show only top level categories and categories that are
// being published
$tpl = new $GLOBALS['VM_THEMECLASS']();
$category_childs = $ps_product_category->get_child_list(0);
$tpl->set('categories', $category_childs);
//echo $vendor_store_desc;
$categories = $tpl->fetch('common/categoryChildlist.tpl.php');
$tpl->set('vendor_store_desc', $vendor_store_desc);
$tpl->set('categories', $categories);
$tpl->set('ps_product', $ps_product);
$tpl->set('recent_products', $ps_product->recentProducts(null, $tpl->get_cfg('showRecent', 5)));
if (file_exists(CLASSPATH . 'payment/ps_paypal_api.php')) {
    require_once CLASSPATH . 'payment/ps_paypal_api.php';
    if (ps_paypal_api::getPaymentMethodId() && ps_paypal_api::isActive()) {
        // Paypal API / Express
        $lang = jfactory::getLanguage();
        $lang_iso = str_replace('-', '_', $lang->gettag());
        $paypal_buttonurls = array('en_US' => 'https://www.paypal.com/en_US/i/logo/PayPal_mark_60x38.gif', 'en_GB' => 'https://www.paypal.com/en_GB/i/bnr/horizontal_solution_PP.gif', 'de_DE' => 'https://www.paypal.com/de_DE/DE/i/logo/lockbox_150x47.gif', 'es_ES' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'pl_PL' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'nl_NL' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'fr_FR' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'it_IT' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/it_IT/IT/i/bnr/bnr_horizontal_solution_PP_178wx80h.gif', 'zn_CN' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif');
        $paypal_infolink = array('en_US' => 'https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'en_GB' => 'https://www.paypal.com/uk/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'de_DE' => 'https://www.paypal.com/de/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'es_ES' => 'https://www.paypal.com/es/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'pl_PL' => 'https://www.paypal.com/pl/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'nl_NL' => 'https://www.paypal.com/nl/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'fr_FR' => 'https://www.paypal.com/fr/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'it_IT' => 'https://www.paypal.com/it/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'zn_CN' => 'https://www.paypal.com/cn/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside');
        if (!isset($paypal_buttonurls[$lang_iso])) {
            $lang_iso = 'en_US';
        }
        $html = '<img id="paypalLogo" src="' . $paypal_buttonurls[$lang_iso] . '" alt="PayPal Checkout Available" border="0" style="cursor:pointer;" /></a>';
        $html .= '<script type="text/javascript">window.addEvent("domready", function() {
			$("paypalLogo").addEvent("click", function() {
				window.open(\'' . $paypal_infolink[$lang_iso] . '\',\'olcwhatispaypal\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=500\');
				});
			});
			</script>';
			{
				$("paypalExpress_ecm").value="2";
			} 
			else 
			{	
				$("paypalExpress_ecm").value="";
			}
		});
	});
	</script>';
?>
	<fieldset><legend><strong>PayPal</strong></legend>
		<table border="0" cellspacing="0" cellpadding="2" width="100%">
		    <tr>
		        <td>
					<input type="hidden" id="paypalExpress_ecm" name="payment_method_ppex" value="" />
					<input type="radio" id="paypalExpressID_ecm" name="payment_method_id" value="<?php 
echo ps_paypal_api::getPaymentMethodId();
?>
" />
					<?php 
echo $html;
?>
		        </td>
		    </tr>
		</table>
	</fieldset>


<?php 
echo ps_checkout::list_payment_methods($payment_method_id);
        $show_basket = false;
    }
    $current_stage = ps_checkout::get_current_stage();
    $checkout_steps = ps_checkout::get_checkout_steps();
}
if (!empty($paypal_api_payment_method_id) && in_array('CHECK_OUT_GET_PAYMENT_METHOD', $checkout_steps[$current_stage])) {
    if ($paypalActive) {
        // Paypal API / Express
        echo '<script type="text/javascript">window.addEvent("domready", function() {
		$$(\'label\').each( function(el) { if(el.htmlFor == "' . ps_paypal_api::getPaymentMethodName() . '") { el.innerHTML = "Credit Card";} });
		});</script>';
    }
}
if (in_array('CHECK_OUT_GET_FINAL_CONFIRMATION', $checkout_steps[$current_stage])) {
    if ($paypalActive && !empty($paypal_api_payment_method_id) && $paypal_api_payment_method_id == $payment_method_id && empty($_SESSION['ppex_token'])) {
        ps_paypal_api::gettoken(2);
    }
    $next_page = 'checkout.thankyou';
    if (sizeof($checkout_steps[$current_stage]) > 1) {
        include_once PAGEPATH . 'basket.php';
    } else {
        include_once PAGEPATH . 'ro_basket.php';
    }
} else {
    $next_page = 'checkout.index';
    include_once PAGEPATH . 'basket.php';
}
// Get the zone quantity after it has been calculated in the basket
$zone_qty = vmGet($vars, 'zone_qty');
//Check for express checkout from paypal
if (isset($_SESSION['ppex_userdata']) && is_array($_SESSION['ppex_userdata']) && isset($_SESSION['ppex_token']) && $paypalActive) {
Beispiel #6
0
    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;
    }
Beispiel #7
0
     * -CHECK_OUT_GET_FINAL_CONFIRMATION
     * shows a total summary including all payments, taxes, fees etc. and let the user confirm
     */
    if ($auth['user_id'] > 0) {
        $show_basket = true;
    } else {
        $show_basket = false;
    }
    $current_stage = ps_checkout::get_current_stage();
    $checkout_steps = ps_checkout::get_checkout_steps();
}
if (!empty($paypal_api_payment_method_id) && in_array('CHECK_OUT_GET_PAYMENT_METHOD', $checkout_steps[$current_stage])) {
    if ($paypalActive) {
        // Paypal API / Express
        echo '<script type="text/javascript">window.addEvent("domready", function() {
		$$(\'label\').each( function(el) { if(el.htmlFor == "' . ps_paypal_api::getPaymentMethodName() . '") { el.innerHTML = "Credit Card";} });
		});</script>';
    }
}
if (in_array('CHECK_OUT_GET_FINAL_CONFIRMATION', $checkout_steps[$current_stage])) {
    $next_page = 'checkout.thankyou';
    if (sizeof($checkout_steps[$current_stage]) > 1) {
        include_once PAGEPATH . 'basket.php';
    } else {
        include_once PAGEPATH . 'ro_basket.php';
    }
} else {
    $next_page = 'checkout.index';
    include_once PAGEPATH . 'basket.php';
}
// Get the zone quantity after it has been calculated in the basket