public static function getBasket(&$ref, $OPCloader, $withwrapper = true, &$op_coupon = '', $shipping = '', $payment = '', $isexpress = false) { include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; $has_k2 = OPCloader::tableExists('k2mart'); if (!class_exists('ShopFunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } if (!method_exists('ShopFunctions', 'convertWeightUnit')) { $opc_show_weight = false; } /* if (!class_exists('VirtueMartModelProduct')) require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php'); */ require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $productClass = OPCmini::getModel('product'); //new VirtueMartModelProduct(); if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } $currencyDisplay = CurrencyDisplay::getInstance($ref->cart->pricesCurrency); $google_html = ''; $VM_LANG = new op_languageHelper(); $product_rows = array(); $p2 = $ref->cart->products; if (empty($ref->cart)) { $ref->cart = VirtueMartCart::getCart(); } $vm2015 = false; $ref->cart->prices = $ref->cart->pricesUnformatted = OPCloader::getCheckoutPrices($ref->cart, false, $vm2015, 'opc'); $useSSL = VmConfig::get('useSSL', 0); $action_url = $OPCloader->getActionUrl($OPCloader, true); $xi = 0; if (isset($currencyDisplay->_priceConfig)) { $savedConfig = $currencyDisplay->_priceConfig; } if (empty($product_price_display)) { $product_price_display = 'salesPrice'; } //$test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax', 'costPrice'); $test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax'); // check price config $testf = false; foreach ($test_product_price_display as $product_price_display_test) { $test = $currencyDisplay->createPriceDiv($product_price_display, '', '10', false, false, 1); if (empty($test)) { if (isset($currencyDisplay->_priceConfig)) { if (isset($currencyDisplay->_priceConfig[$product_price_display_test])) { if (empty($currencyDisplay->_priceConfig[$product_price_display_test][0])) { $currencyDisplay->_priceConfig[$product_price_display_test] = array(1, -1, 1); } } } $testf = true; } else { if (!isset($product_price_display_test2)) { $product_price_display_test2 = $product_price_display_test; } } } if (empty($testf)) { $product_price_display = $product_price_display_test2; } $totalw = 0; $to_weight_unit = VmConfig::get('weight_unit_default', 'KG'); foreach ($ref->cart->products as $pkey => $prow) { if ($opc_show_weight) { $totalw += ShopFunctions::convertWeightUnit((double) $prow->product_weight, $prow->product_weight_uom, $to_weight_unit) * (double) $prow->quantity; } $product = array(); $id = $prow->virtuemart_media_id; if (empty($id)) { $imgf = ''; } else { if (is_array($id)) { $id = reset($id); } $imgf = $OPCloader->getImageFile($id); } $product['product_full_image'] = $imgf; if (!empty($opc_only_parent_links)) { if (!empty($prow->product_parent_id)) { $parent = $prow->product_parent_id; $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $parent . '&view=productdetails', true); } } // check if k2 exists: if (!isset($prow->url)) { if (isset($prow->link)) { $prow->url = $prow->link; if (strpos($prow->url, '&') === false) { $prow->url = str_replace('&', '&', $prow->url); } } else { $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $prow->virtuemart_product_id . '&view=productdetails', true); } } if ($has_k2) { $db = JFactory::getDBO(); $q = 'select baseID from #__k2mart where referenceID = ' . (int) $prow->virtuemart_product_id . ' limit 0,1'; $db->setQuery($q); $k2_id = $db->loadResult(); if (!empty($k2_id)) { $prow->url = JRoute::_('index.php?option=com_k2&id=' . $k2_id . '&view=item', true); } } $product['product_name'] = JHTML::link($prow->url, $prow->product_name, ' class="opc_product_name" '); if ((!defined('VM_VERSION') || VM_VERSION < 3) && (isset($prow->customfields) && !is_array($prow->customfields))) { if (!empty($opc_editable_attributes)) { $product['product_attributes'] = '<div style="clear:both;">' . OPCrenderer::getCustomFields($prow->virtuemart_product_id, $prow->cart_item_id, $prow->quantity) . '</div>'; } else { $product['product_attributes'] = $prow->customfields; } } else { $product['product_attributes'] = ''; } /* var_dump($prow->customfields); $cart = VirtuemartCart::getCart(); $p = array(); foreach ($cart->products as $k=>$v) { $p[$k] = $v; } unset($cart->products); unset($cart->ST); unset($cart->BT); unset($cart->BTaddress); unset($cart->STaddress); $cart->products = $p; $cart->setCartIntoSession(); var_dump($cart->products); die(); var_dump($cart); JFactory::getApplication()->close(); */ if (defined('VM_VERSION') && VM_VERSION >= 3) { } if (isset($prow->customfields) && is_array($prow->customfields)) { $customfieldsModel = OPCmini::getModel('Customfields'); $product['product_attributes'] = $customfieldsModel->CustomsFieldCartDisplay($prow); } $product['product_sku'] = $prow->product_sku; // end price test if (isset($prow->quantity)) { $product['product_quantity'] = $prow->quantity; } if (isset($prow->min_order_level)) { $product['min_order_level'] = $prow->min_order_level; } if (isset($prow->max_order_level)) { $product['max_order_level'] = $prow->max_order_level; } //$product_model = $OPCloader->getModel('product'); $xi++; if (empty($no_extra_product_info)) { $prowcopy = $productClass->getProduct($prow->virtuemart_product_id, true); } else { $prowcopy = $prow; } $product['info'] = $prowcopy; $product['product'] = $prow; if (isset($ref->cart->prices[$pkey])) { $currentPrice = $ref->cart->prices[$pkey]; } else { if (isset($prow->prices)) { $currentPrice = $prow->prices; } } if ($product_price_display == 'salesPrice') { if (isset($prow->prices)) { $product['product_price'] = $currentPrice['salesPrice']; } else { if (isset($prow->salesPrice)) { $product['product_price'] = $prow->salesPrice; } else { if (isset($prow->basePriceWithTax)) { $product['product_price'] = $prow->basePriceWithTax; } else { if (isset($prow->basePrice)) { $product['product_price'] = $prow->basePrice; } } } } } else { if (isset($prow->prices)) { $product['product_price'] = $currentPrice[$product_price_display]; } else { if (isset($prow->{$product_price_display})) { $product['product_price'] = $prow->{$product_price_display}; } else { if (isset($prow->salesPrice)) { $product['product_price'] = $prow->salesPrice; } } } } if (!isset($product['product_price'])) { $price = $ref->cart->pricesUnformatted[$pkey]; $product['product_price'] = $price[$product_price_display]; } if (empty($product['product_price'])) { $product_price_display = 'salesPrice'; $price = $ref->cart->pricesUnformatted[$pkey]; $product['product_price'] = $price['salesPrice']; } $price_raw = $product['product_price']; // the quantity is not working up to 2.0.4 $product['product_id'] = $prow->virtuemart_product_id; $google_html .= '<input type="hidden" name="prod_id" value="' . $prow->virtuemart_product_id . '" /> <input type="hidden" name="prodsku_' . $prow->virtuemart_product_id . '" id="prodsku_' . $prow->virtuemart_product_id . '" value="' . OPCloader::slash($prow->product_sku, false) . '" /> <input type="hidden" name="prodname_' . $prow->virtuemart_product_id . '" id="prodname_' . $prow->virtuemart_product_id . '" value="' . OPCloader::slash($prow->product_name, false) . '" /> <input type="hidden" name="prodq_' . $prow->virtuemart_product_id . '" id="prodq_' . $prow->virtuemart_product_id . '" value="' . $prow->quantity . '" /> <input type="hidden" name="produprice_' . $prow->virtuemart_product_id . '" id="produprice_' . $prow->virtuemart_product_id . '" value="' . $price_raw . '" /> <input type="hidden" name="prodcat_' . $prow->virtuemart_product_id . '" id="prodcat_' . $prow->virtuemart_product_id . '" value="' . $prow->category_name . '" /> '; if (isset($ref->cart->pricesUnformatted[$pkey])) { $price = $ref->cart->pricesUnformatted[$pkey]; } else { $price = $prow->prices; } $product['prices'] = $price; $product['prices_formatted'] = array(); if ($vm2015) { foreach ($price as $key => $pricev) { //if (!isset($price[$key])) if (!empty($pricev)) { $product['prices_formatted'][$key] = $currencyDisplay->createPriceDiv($key, '', $price, false, true, 1); } } } $product['product_price'] = $currencyDisplay->createPriceDiv($product_price_display, '', $price, false, true, 1); /* if (false) if (empty($product['product_price'])) { // ok, we have a wrong type selected here if ($product_price_display == 'salesPrice') $product['product_price'] = $currencyDisplay->createPriceDiv('basePrice','', $price,false,false, 1); if (empty($product['product_price'])) $product['product_price'] = $currencyDisplay->createPriceDiv('priceWithoutTax','', $price,false,false, 1); if (empty($product['product_price'])) $product['product_price'] = $currencyDisplay->createPriceDiv('basePriceWithTax','', $price,false,false, 1); if (empty($product['product_price'])) $product['product_price'] = $currencyDisplay->createPriceDiv('priceBeforeTax','', $price,false,false, 1); if (empty($product['product_price'])) $product['product_price'] = $currencyDisplay->createPriceDiv('costPrice','', $price,false,false, 1); } */ $product['product_price'] = str_replace('class="', 'class="opc_price_general opc_', $product['product_price']); if (!isset($prow->cart_item_id)) { $prow->cart_item_id = $pkey; } $v = array('product' => $prow, 'action_url' => $action_url, 'use_ssl' => $useSSL, 'useSSL' => $useSSL); if (!empty($ajaxify_cart)) { $update_form = $OPCloader->fetch($OPCloader, 'update_form_ajax.tpl', $v); $delete_form = $OPCloader->fetch($OPCloader, 'delete_form_ajax.tpl', $v); } else { $update_form = $OPCloader->fetch($OPCloader, 'update_form.tpl', $v); $delete_form = $OPCloader->fetch($OPCloader, 'delete_form.tpl', $v); $op_coupon_ajax = ''; } if (empty($update_form)) { if (!empty($ajaxify_cart)) { $product['update_form'] = '<input type="text" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" class="inputbox" size="3" name="quantity" id="quantity_for_' . md5($prow->cart_item_id) . '" value="' . $prow->quantity . '" /><a class="updatebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="#" rel="' . $prow->cart_item_id . '|' . md5($prow->cart_item_id) . '"> </a>'; $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="#" rel="' . $prow->cart_item_id . '"> </a>'; } else { $product['update_form'] = '<form action="' . $action_url . '" method="post" style="display: inline;"> <input type="hidden" name="option" value="com_virtuemart" /> <input type="text" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" class="inputbox" size="3" name="quantity" value="' . $prow->quantity . '" /> <input type="hidden" name="view" value="cart" /> <input type="hidden" name="task" value="update" /> <input type="hidden" name="cart_virtuemart_product_id" value="' . $prow->cart_item_id . '" /> <input type="submit" class="updatebtn" name="update" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" value=" "/> </form>'; if (defined('VM_VERSION') && VM_VERSION >= 3) { $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="' . JRoute::_('index.php?option=com_virtuemart&view=cart&task=delete.' . $prow->cart_item_id . '&cart_virtuemart_product_id=' . $prow->cart_item_id, true, $useSSL) . '"> </a>'; } else { $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="' . JRoute::_('index.php?option=com_virtuemart&view=cart&task=delete&cart_virtuemart_product_id=' . $prow->cart_item_id, true, $useSSL) . '"> </a>'; } } } else { $product['update_form'] = $update_form; $product['delete_form'] = $delete_form; } if (!empty($ajaxify_cart)) { $product['update_form'] = str_replace('href=', 'onclick="return Onepage.updateProduct(this);" href=', $product['update_form']); $product['delete_form'] = str_replace('href=', 'onclick="return Onepage.deleteProduct(this);" href=', $product['delete_form']); } //vm3 update: if (defined('VM_VERSION') && VM_VERSION >= 3) { $product['update_form'] = str_replace('name="quantity"', 'name="quantity[' . $prow->cart_item_id . ']"', $product['update_form']); $product['update_form'] = str_replace('value="update"', 'value="updatecart"', $product['update_form']); } $product['subtotal'] = $prow->quantity * $price_raw; //else //$product['subtotal'] = $prow->subtotal_with_tax; // this is fixed from 2.0.4 and would not be needed if (isset($ref->cart->pricesUnformatted[$pkey])) { $copy = $ref->cart->pricesUnformatted[$pkey]; } else { $copy = $prow->prices; } //$copy['salesPrice'] = $copy['subtotal_with_tax']; $copy[$product_price_display] = $product['subtotal']; $product['subtotal'] = $currencyDisplay->createPriceDiv($product_price_display, '', $copy, false, true, 1); $product['subtotal'] = str_replace('class="', 'class="opc_', $product['subtotal']); // opc vars $product_rows[] = $product; //break; } //$shipping_inside_basket = false; $shipping_select = $shipping; $payment_select = $payment; if (!empty($ref->cart->prices['salesPriceCoupon'])) { if (empty($coupon_price_display)) { $coupon_price_display = 'salesPriceCoupon'; } $coupon_display = $currencyDisplay->createPriceDiv($coupon_price_display, '', $ref->cart->prices, false, true, 1); //$ref->cart->prices['salesPriceCoupon']; $coupon_display = str_replace('class="', 'class="opc_', $coupon_display); } else { $coupon_display = ''; } if (!empty($coupon_display)) { $discount_after = true; } else { $discount_after = false; } if (empty($other_discount_display)) { $other_discount_display = 'billDiscountAmount'; } switch ($other_discount_display) { case 'billDiscountAmount': $coupon_display_before = $currencyDisplay->createPriceDiv('billDiscountAmount', '', $ref->cart->prices, false, false, 1); if (empty($ref->cart->prices['billDiscountAmount'])) { $coupon_display_before = ''; } break; case 'discountAmount': $coupon_display_before = $currencyDisplay->createPriceDiv('discountAmount', '', $ref->cart->prices, false, false, 1); if (empty($ref->cart->prices['discountAmount'])) { $coupon_display_before = ''; } case 'minus': $billD = abs($ref->cart->prices['billDiscountAmount']); foreach ($ref->cart->prices as $key => $val) { if (!empty($ref->cart->products[$key])) { if (is_array($val)) { $billD -= abs($val['subtotal_discount']); } } } $billD = abs($billD) * -1; $prices_new['billTotal'] = $billD; if (!empty($billD)) { $coupon_display_before = $currencyDisplay->createPriceDiv('billTotal', '', $prices_new, false, false, 1); } else { $coupon_display_before = ''; } break; case 'sum': $billD = 0; foreach ($ref->cart->prices as $key => $val) { if (!empty($ref->cart->products[$key])) { if (is_array($val)) { $billD += $val['subtotal_discount']; } } } $billD = abs($billD) * -1; $prices_new['billTotal'] = $billD; if (!empty($billD)) { $coupon_display_before = $currencyDisplay->createPriceDiv('billTotal', '', $prices_new, false, false, 1); } else { $coupon_display_before = ''; } break; } $coupon_display_before = str_replace('class="', 'class="opc_', $coupon_display_before); //else $coupon_display_before = ''; $opc_show_weight_display = ''; if (!empty($opc_show_weight) && !empty($totalw)) { $dec = $currencyDisplay->getDecimalSymbol(); $th = $currencyDisplay->getThousandsSeperator(); $w = VmConfig::get('weight_unit_default', 'KG'); $w = strtoupper($w); if ($w == 'OZ') { $w = 'OUNCE'; } $unit = JText::_('COM_VIRTUEMART_UNIT_SYMBOL_' . $w); if ($unit == 'COM_VIRTUEMART_UNIT_SYMBOL_' . $w) { $unit = $w = VmConfig('weight_unit_default', 'kg'); } $opc_show_weight_display = number_format($totalw, 2, $dec, $th) . ' ' . $unit; } if (!empty($ajaxify_cart)) { $coupon_text = $ref->cart->couponCode ? OPCLang::_('COM_VIRTUEMART_COUPON_CODE_CHANGE') : OPCLang::_('COM_VIRTUEMART_COUPON_CODE_ENTER'); $vars = array('coupon_text' => $coupon_text, 'coupon_display' => $coupon_display); $op_coupon_ajax = $OPCloader->fetch($OPCloader, 'couponField_ajax', $vars); if (stripos($op_coupon_ajax, 'Onepage.setCouponAjax') === false) { $op_coupon_ajax = str_replace('type="button', 'onclick="return Onepage.setCouponAjax(this);" type="button', $op_coupon_ajax); } } if (empty($subtotal_price_display)) { $subtotal_price_display = 'salesPrice'; } if ($subtotal_price_display != 'diffTotals') { $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $ref->cart->prices, false, false, 1); if ($subtotal_price_display == 'basePriceWithTax') { if (stripos($subtotal_display, ' ></span') !== false) { $subtotal_price_display = 'salesPrice'; $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $ref->cart->prices, false, false, 1); } } } else { $subtotal = $ref->cart->prices['billTotal'] - $ref->cart->prices['billTaxAmount']; $arr = array('diffTotals' => $subtotal); $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $arr, false, false, 1); } //$ref->cart->prices['salesPrice']; $subtotal_display = str_replace('class="', 'class="opc_', $subtotal_display); $prices = $ref->cart->prices; if (!isset($prices[$subtotal_price_display . 'Shipment'])) { if ($subtotal_price_display != 'salesPrice') { $order_shipping = $prices['shipmentValue']; } else { $order_shipping = $prices['salesPriceShipment']; } } else { $order_shipping = $prices[$subtotal_price_display . 'Shipment']; } if (!empty($order_shipping)) { $virtuemart_currency_id = OPCloader::getCurrency($ref->cart); $order_shipping = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $order_shipping, false); $test = $currencyDisplay->createPriceDiv($product_price_display, '', $order_shipping, false, true, 1); if (!empty($test)) { $order_shipping = $test; } $order_shipping = str_replace('class="', 'class="opc_', $order_shipping); } else { $order_shipping = ''; } $continue_link = $OPCloader->getContinueLink($ref); $order_total_display = $currencyDisplay->createPriceDiv('billTotal', '', $ref->cart->prices, false, false, 1); //$ref->cart->prices['billTotal']; $order_total_display = str_replace('class="', 'class="opc_', $order_total_display); // this will need a little tuning foreach ($ref->cart->cartData['taxRulesBill'] as $rule) { $rulename = $rule['calc_name']; if (!empty($ref->cart->prices[$rule['virtuemart_calc_id'] . 'Diff'])) { $tax_display = $currencyDisplay->createPriceDiv($rule['virtuemart_calc_id'] . 'Diff', '', $ref->cart->prices, false, false, 1); //$ref->cart->prices[$rule['virtuemart_calc_id'].'Diff']; $tax_display = str_replace('class="', 'class="opc_', $tax_display); } else { $tax_display = ''; } } $op_disable_shipping = OPCloader::getShippingEnabled($ref->cart); if (!empty($payment_discount_before) && !empty($coupon_display_before)) { $discount_before = true; } else { $discount_before = false; } $disable_couponns = VmConfig::get('coupons_enable', true); if (empty($disable_couponns)) { $op_coupon = $op_coupon_ajax = ''; } if (!empty($op_coupon_ajax)) { $op_coupon = $op_coupon_ajax; } if ($isexpress) { $payment_inside_basket = false; } if (empty($payment_inside_basket)) { $payment_select = ''; } if (empty($shipping_inside_basket)) { $shipping_select = ''; } if (empty($tax_display)) { $tax_display = ''; } if (empty($op_disable_shipping)) { $op_disable_shipping = false; } $no_shipping = $op_disable_shipping; $vars = array('product_rows' => $product_rows, 'payment_inside_basket' => $payment_inside_basket, 'shipping_select' => $shipping_select, 'payment_select' => $payment_select, 'shipping_inside_basket' => $shipping_inside_basket, 'coupon_display' => $coupon_display, 'subtotal_display' => $subtotal_display, 'no_shipping' => $no_shipping, 'order_total_display' => $order_total_display, 'tax_display' => $tax_display, 'VM_LANG' => $VM_LANG, 'op_coupon_ajax' => $op_coupon_ajax, 'continue_link' => $continue_link, 'coupon_display_before' => $coupon_display_before, 'discount_before' => $discount_before, 'discount_after' => $discount_after, 'order_shipping' => $order_shipping, 'cart' => $ref->cart, 'op_coupon' => $op_coupon, 'opc_show_weight_display' => $opc_show_weight_display); //original cart support: $ref->cart->cartData['shipmentName'] = ''; $ref->cart->cartData['paymentName'] = ''; $totalInPaymentCurrency = $ref->getTotalInPaymentCurrency(); $cd = CurrencyDisplay::getInstance($ref->cart->pricesCurrency); $layoutName = 'default'; $confirm = 'confirm'; $shippingText = ''; $paymentText = ''; $checkout_link_html = ''; $useSSL = VmConfig::get('useSSL', 0); $useXHTML = true; $checkoutAdvertise = ''; if (!class_exists('OPCrenderer')) { require JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'renderer.php'; } $renderer = OPCrenderer::getInstance(); if (method_exists($renderer, 'assignRef')) { $renderer->assignRef('cart', $renderer->cart); $renderer->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency); $renderer->assignRef('layoutName', $layoutName); $renderer->assignRef('select_shipment_text', $shippingText); $renderer->assignRef('checkout_task', $confirm); $renderer->assignRef('currencyDisplay', $cd); $renderer->assignRef('select_payment_text', $paymentText); $renderer->assignRef('checkout_link_html', $checkout_link_html); $renderer->assignRef('useSSL', $useSSL); $renderer->assignRef('useXHTML', $useXHTML); $renderer->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency); $renderer->assignRef('checkoutAdvertise', $checkoutAdvertise); } if (empty($use_original_basket)) { $html = $renderer->fetch($OPCloader, 'basket.html', $vars); } else { $html = $renderer->fetchBasket($OPCloader, 'basket.html', $vars); } if ($withwrapper) { $html = '<div id="opc_basket">' . $html . '</div>'; } if (!empty($op_no_basket)) { $html = '<div style="display: none;">' . $html . '</div>'; } if (isset($currencyDisplay->_priceConfig)) { $currencyDisplay->_priceConfig = $savedConfig; } $ret = $html . $google_html; return $ret; }
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|€|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|€|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&view=opc&controller=opc&task=checkout&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; }