コード例 #1
0
ファイル: utils.php プロジェクト: aldegtyarev/stelsvelo
    function copyTable($from, $to)
    {
        $dbj = JFactory::getDBO();
        $prefix = $dbj->getPrefix();
        if (OPCloader::tableExists($to)) {
            $q = 'drop table `' . $prefix . $to . '`';
            $dbj->setQuery($q);
            $dbj->query();
            $e = $dbj->getError();
            if (!empty($e)) {
                echo $e;
                die;
            }
        }
        $Config = new JConfig();
        $db = $Config->db;
        $sql = '
 CREATE  TABLE  `' . $db . '`.`' . $prefix . $to . '` (  `id` int( 11  )  NOT  NULL  AUTO_INCREMENT ,
 `menutype` varchar( 24  )  NOT  NULL  COMMENT  \'The type of menu this item belongs to. FK to #__menu_types.menutype\',
 `title` varchar( 255  )  NOT  NULL  COMMENT  \'The display title of the menu item.\',
 `alias` varchar( 255  )  CHARACTER  SET utf8 COLLATE utf8_bin NOT  NULL  COMMENT  \'The SEF alias of the menu item.\',
 `note` varchar( 255  )  NOT  NULL DEFAULT  \'\',
 `path` varchar( 1024  )  NOT  NULL  COMMENT  \'The computed path of the menu item based on the alias field.\',
 `link` varchar( 1024  )  NOT  NULL  COMMENT  \'The actually link the menu item refers to.\',
 `type` varchar( 16  )  NOT  NULL  COMMENT  \'The type of link: Component, URL, Alias, Separator\',
 `published` tinyint( 4  )  NOT  NULL DEFAULT  \'0\' COMMENT  \'The published state of the menu link.\',
 `parent_id` int( 10  )  unsigned NOT  NULL DEFAULT  \'1\' COMMENT  \'The parent menu item in the menu tree.\',
 `level` int( 10  )  unsigned NOT  NULL DEFAULT  \'0\' COMMENT  \'The relative level in the tree.\',
 `component_id` int( 10  )  unsigned NOT  NULL DEFAULT  \'0\' COMMENT  \'FK to #__extensions.id\',
 `ordering` int( 11  )  NOT  NULL DEFAULT  \'0\' COMMENT  \'The relative ordering of the menu item in the tree.\',
 `checked_out` int( 10  )  unsigned NOT  NULL DEFAULT  \'0\' COMMENT  \'FK to #__users.id\',
 `checked_out_time` timestamp NOT  NULL DEFAULT  \'0000-00-00 00:00:00\' COMMENT  \'The time the menu item was checked out.\',
 `browserNav` tinyint( 4  )  NOT  NULL DEFAULT  \'0\' COMMENT  \'The click behaviour of the link.\',
 `access` int( 10  )  unsigned NOT  NULL DEFAULT  \'0\' COMMENT  \'The access level required to view the menu item.\',
 `img` varchar( 255  )  NOT  NULL  COMMENT  \'The image of the menu item.\',
 `template_style_id` int( 10  )  unsigned NOT  NULL DEFAULT  \'0\',
 `params` text NOT  NULL  COMMENT  \'JSON encoded data for the menu item.\',
 `lft` int( 11  )  NOT  NULL DEFAULT  \'0\' COMMENT  \'Nested set lft.\',
 `rgt` int( 11  )  NOT  NULL DEFAULT  \'0\' COMMENT  \'Nested set rgt.\',
 `home` tinyint( 3  )  unsigned NOT  NULL DEFAULT  \'0\' COMMENT  \'Indicates if this menu item is the home or default page.\',
 `language` char( 7  )  NOT  NULL DEFAULT  \'\',
 `client_id` tinyint( 4  )  NOT  NULL DEFAULT  \'0\',
 PRIMARY  KEY (  `id`  ) ,
 UNIQUE  KEY  `idx_client_id_parent_id_alias_language` (  `client_id` ,  `parent_id` ,  `alias` ,  `language`  ) ,
 KEY  `idx_componentid` (  `component_id` ,  `menutype` ,  `published` ,  `access`  ) ,
 KEY  `idx_menutype` (  `menutype`  ) ,
 KEY  `idx_left_right` (  `lft` ,  `rgt`  ) ,
 KEY  `idx_alias` (  `alias`  ) ,
 KEY  `idx_path` (  `path` ( 333  )  ) ,
 KEY  `idx_language` (  `language`  )  ) ENGINE  =  MyISAM  DEFAULT CHARSET  = utf8;';
        $dbj->setQuery($sql);
        $dbj->query();
        $e = $dbj->getErrorMsg();
        if (!empty($e)) {
            echo $e;
            die;
        }
        $sql = 'SET SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO\'';
        $dbj->setQuery($sql);
        $dbj->query();
        $e = $dbj->getErrorMsg();
        if (!empty($e)) {
            echo $e;
            die;
        }
        $sql = 'INSERT INTO `' . $db . '`.`' . $prefix . $to . '` SELECT * FROM `' . $db . '`.`' . $prefix . $from . '`;';
        $dbj->setQuery($sql);
        $dbj->query();
        $e = $dbj->getErrorMsg();
        if (!empty($e)) {
            echo $e;
            die;
        }
    }
コード例 #2
0
ファイル: basket.php プロジェクト: aldegtyarev/stelsvelo
    public static function getBasket(&$ref, $OPCloader, $withwrapper = true, &$op_coupon = '', $shipping = '', $payment = '', $isexpress = false)
    {
        include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
        $has_k2 = OPCloader::tableExists('k2mart');
        if (!class_exists('ShopFunctions')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
        }
        if (!method_exists('ShopFunctions', 'convertWeightUnit')) {
            $opc_show_weight = false;
        }
        /*
           if (!class_exists('VirtueMartModelProduct'))
         require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php');
        */
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        $productClass = OPCmini::getModel('product');
        //new VirtueMartModelProduct();
        if (!class_exists('CurrencyDisplay')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
        }
        $currencyDisplay = CurrencyDisplay::getInstance($ref->cart->pricesCurrency);
        $google_html = '';
        $VM_LANG = new op_languageHelper();
        $product_rows = array();
        $p2 = $ref->cart->products;
        if (empty($ref->cart)) {
            $ref->cart = VirtueMartCart::getCart();
        }
        $vm2015 = false;
        $ref->cart->prices = $ref->cart->pricesUnformatted = OPCloader::getCheckoutPrices($ref->cart, false, $vm2015, 'opc');
        $useSSL = VmConfig::get('useSSL', 0);
        $action_url = $OPCloader->getActionUrl($OPCloader, true);
        $xi = 0;
        if (isset($currencyDisplay->_priceConfig)) {
            $savedConfig = $currencyDisplay->_priceConfig;
        }
        if (empty($product_price_display)) {
            $product_price_display = 'salesPrice';
        }
        //$test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax', 'costPrice');
        $test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax');
        // check price config
        $testf = false;
        foreach ($test_product_price_display as $product_price_display_test) {
            $test = $currencyDisplay->createPriceDiv($product_price_display, '', '10', false, false, 1);
            if (empty($test)) {
                if (isset($currencyDisplay->_priceConfig)) {
                    if (isset($currencyDisplay->_priceConfig[$product_price_display_test])) {
                        if (empty($currencyDisplay->_priceConfig[$product_price_display_test][0])) {
                            $currencyDisplay->_priceConfig[$product_price_display_test] = array(1, -1, 1);
                        }
                    }
                }
                $testf = true;
            } else {
                if (!isset($product_price_display_test2)) {
                    $product_price_display_test2 = $product_price_display_test;
                }
            }
        }
        if (empty($testf)) {
            $product_price_display = $product_price_display_test2;
        }
        $totalw = 0;
        $to_weight_unit = VmConfig::get('weight_unit_default', 'KG');
        foreach ($ref->cart->products as $pkey => $prow) {
            if ($opc_show_weight) {
                $totalw += ShopFunctions::convertWeightUnit((double) $prow->product_weight, $prow->product_weight_uom, $to_weight_unit) * (double) $prow->quantity;
            }
            $product = array();
            $id = $prow->virtuemart_media_id;
            if (empty($id)) {
                $imgf = '';
            } else {
                if (is_array($id)) {
                    $id = reset($id);
                }
                $imgf = $OPCloader->getImageFile($id);
            }
            $product['product_full_image'] = $imgf;
            if (!empty($opc_only_parent_links)) {
                if (!empty($prow->product_parent_id)) {
                    $parent = $prow->product_parent_id;
                    $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $parent . '&view=productdetails', true);
                }
            }
            // check if k2 exists:
            if (!isset($prow->url)) {
                if (isset($prow->link)) {
                    $prow->url = $prow->link;
                    if (strpos($prow->url, '&') === 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;
    }
コード例 #3
0
ファイル: loader.php プロジェクト: aldegtyarev/stelsvelo
 public static function &getVendorInfo(&$cart)
 {
     if (OPCloader::$vendorInfo == null) {
         if (OPCloader::tableExists('virtuemart_vmusers')) {
             if (empty($cart->vendorId)) {
                 $vendorid = 1;
             } else {
                 $vendorid = $cart->vendorId;
             }
             $dbj = JFactory::getDBO();
             $q = "SELECT * FROM `#__virtuemart_userinfos` as ui, #__virtuemart_vmusers as uu WHERE ui.virtuemart_user_id = uu.virtuemart_user_id and uu.virtuemart_vendor_id = '" . (int) $vendorid . "' limit 0,1";
             $dbj->setQuery($q);
             $vendorinfo = $dbj->loadAssoc();
             OPCloader::$vendorInfo = $vendorinfo;
             return $vendorinfo;
         } else {
             return null;
         }
     }
     return OPCloader::$vendorInfo;
 }
コード例 #4
0
ファイル: opc.php プロジェクト: aldegtyarev/stelsvelo
 function opc()
 {
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php';
     OPCloader::$debugMsg = '';
     //mobile handling:
     if (!defined('OPC_DETECTED_DEVICE')) {
         if (class_exists('OPCplugin')) {
             OPCplugin::detectMobile();
         }
     }
     if (!class_exists('OPCLang')) {
         require JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     }
     OPCLang::loadLang();
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php';
     //$this->setShopperGroups();
     $userModel = OPCmini::getModel('user');
     $cmd = JRequest::getVar('cmd', '');
     if ($cmd === 'checkbitvat') {
         $checkvat = $this->checkBitVat();
     }
     if ($cmd === 'checkvatopc') {
         $checkvat = $this->checkOPCVat();
     }
     OPCShopperGroups::setShopperGroupsController();
     if (method_exists($userModel, 'getCurrentUser')) {
         $user = $userModel->getCurrentUser();
         self::$shopper_groups = $user->shopper_groups;
         if (!empty($user->virtuemart_shipmentmethod_id)) {
             $user->virtuemart_shipmentmethod_id = 0;
             $user->virtuemart_paymentmethod_id = 0;
         }
     }
     $session = JFactory::getSession();
     $b = $session->set('eurobnk', null, 'vm');
     if (empty($euvat_shopper_group)) {
         jimport('joomla.html.parameter');
         if (class_exists('plgSystemBit_vm_change_shoppergroup')) {
             $session = JFactory::getSession();
             $sg = $session->get('vm_shoppergroups_add', array(), 'vm');
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('system', 'plgSystemBit_vm_change_shoppergroup', true, $dispatcher);
             // very important
             $document = JFactory::getDocument();
             JRequest::setVar('format_override', 'html');
             $_REQUEST['view'] = 'cart';
             $_REQUEST['option'] = 'com_virtuemart';
             $doctype = $document->getType();
             $dispatcher->trigger('onAfterRender');
             JRequest::setVar('format_override', 'raw');
             $sg = $session->get('vm_shoppergroups_add', array(), 'vm');
         }
     }
     JResponse::setBody('');
     // security:
     JRequest::setVar('virtuemart_shoppergroup_id', null, 'post');
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig(true);
     // since vm2.0.21a we need to load the language files here
     if (method_exists('VmConfig', 'loadJLang')) {
         $lang = JFactory::getLanguage();
         $extension = 'com_virtuemart';
         $lang->load($extension);
         //  when AJAX it needs to be loaded manually here >> in case you are outside virtuemart !!!
         VmConfig::loadJLang('com_virtuemart_orders', true);
         VmConfig::loadJLang('com_virtuemart_shoppers', true);
     }
     /// load shipping here
     $vars = JRequest::get('post');
     // custom tag test
     $cmd = JRequest::getVar('cmd', 'get_shipping');
     $doc = JFactory::getDocument();
     $type = get_class($doc);
     if ($type == 'JDocumentRAW') {
         //C:\Documents and Settings\Rupos\Local Settings\Temp\scp02371\srv\www\clients\client1\web90\web\vm2\components\com_onepage\overrides\
         //require_once(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'overrides'.DS.'opchtml.php');
         //JFactory::$instance = new JDocumentOpchtml();
         //JFactory::$document = new JDocumentOpchtml();
     }
     /*
     	$doc->addCustomTag = create_function('$string', 'return;');  
     	$doc->addCustomTag( '<!-- This is a comment. -->' );
     */
     $c = JRequest::getVar('virtuemart_currency_id', 0);
     JRequest::setVar('virtuemart_currency_id', (int) JRequest::getVar('virtuemart_currency_id'));
     /* to test the currency: */
     $mainframe = Jfactory::getApplication();
     $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id'));
     // end custom tag test
     $view = $this->getView('cart', 'html');
     $cmd = JRequest::getCmd('cmd', 'get_shipping');
     $return = array();
     $return['cmd'] = $cmd;
     if (!empty($checkvat)) {
         $return['checkvat'] = $checkvat;
     }
     $db = JFactory::getDBO();
     $username = JRequest::getVar('username', '');
     $user = JFactory::getUser();
     $un = $user->get('username');
     if ($un == $username) {
         // do not complain if entering the same username of already registered
         $return['username_exists'] = false;
     } else {
         if (!empty($username)) {
             $q = "select username from #__users where username = '******' limit 0,1";
             $db->setQuery($q);
             $r = $db->loadResult();
             if (!empty($r)) {
                 $return['username_exists'] = true;
             } else {
                 $return['username_exists'] = false;
             }
         }
     }
     if ($cmd === 'checkemail') {
         $email = JRequest::getVar('email', '');
         $return['email'] = $email;
         $user = JFactory::getUser();
         $ue = $user->get('email');
         if ($email == $ue) {
             // do not complain if user is logged in and enters the same email address
             $return['email_exists'] = false;
         } else {
             if (!empty($email)) {
                 $q = "select email from #__users where username = '******' or email = '" . $db->getEscaped($email) . "' limit 0,1";
                 $db->setQuery($q);
                 $r = $db->loadResult();
                 if (!empty($r)) {
                     $return['email_exists'] = true;
                 } else {
                     $return['email_exists'] = false;
                 }
             }
         }
     }
     if ($cmd === 'get_klarna_address') {
         if (file_exists(JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'klarna' . DS . 'klarna' . DS . 'api' . DS . 'klarna.php')) {
             $klarnaaddress = $this->getKlarnaAddress();
             if (!empty($klarnaaddress)) {
                 echo json_encode(array('cmd' => 'getKlarna', 'shipping' => 'opc_do_not_update', 'klarna' => $klarnaaddress, 'totals_html' => '', 'payment' => ''));
                 $mainframe = JFactory::getApplication();
                 // do not allow further processing
                 $mainframe->close();
             }
         }
     }
     if (!defined('JPATH_OPC')) {
         define('JPATH_OPC', JPATH_SITE . DS . 'components' . DS . 'com_onepage');
     }
     require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php';
     require_once JPATH_OPC . DS . 'helpers' . DS . 'ajaxhelper.php';
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $OPCloader = new OPCloader();
     $cart = VirtueMartCart::getCart(false);
     $opcsavedST = $cart->ST;
     $opcsavedBT = $cart->BT;
     $stopen = JRequest::getVar('shiptoopen', 0);
     if ($stopen === 'false') {
         $stopen = 0;
     }
     if (empty($stopen)) {
         $sa = JRequest::getVar('sa', '');
         if ($sa == 'adresaina') {
             $stopen = 1;
         }
     }
     if ($stopen) {
         $restoreST = false;
         $restoreBT = true;
     } else {
         $cart->ST = 0;
         $restoreST = true;
         $restoreBT = false;
     }
     //$virtuemart_currency_id;  = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id',JRequest::getInt('virtuemart_currency_id') );
     $cart->paymentCurrency = $virtuemart_currency_id;
     if (defined('VM_VERSION') && VM_VERSION >= 3) {
         if (method_exists($cart, 'prepareCartProducts')) {
             $cart->prepareCartProducts();
         }
     }
     if ($cmd === 'getST') {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loggedshopper.php';
         $return['sthtml'] = OPCLoggedShopper::getSTHtml($cart);
     }
     if (!isset($cart->vendorId)) {
         $cart->vendorId = 1;
     }
     if ($cmd == 'updateattributes') {
         $arr = $this->updateattributes($cart);
         if (!empty($arr)) {
             foreach ($arr as $key => $val) {
                 $return[$key] = $val;
             }
         }
     }
     if ($cmd == 'update_product') {
         if (defined('VM_VERSION') && VM_VERSION >= 3) {
             $quantity = JRequest::getVar('quantity');
             if (!is_array($quantity)) {
                 $cart_virtuemart_product_id = JRequest::getVar('cart_virtuemart_product_id');
                 $arr = array($cart_virtuemart_product_id => (int) $quantity);
                 JRequest::setVar('quantity', $arr);
                 $x = JRequest::getVar('quantity');
             }
         }
         $cart->updateProductCart();
     }
     if ($cmd == 'delete_product') {
         $cart->updateProductCart();
     }
     if ($cmd == 'removecoupon') {
         JRequest::setVar('coupon_code', '');
         $_REQUEST['coupon_code'] = $_POST['coupon_code'] = $_GET['coupon_code'] = '';
         $cart->couponCode = '';
         //$this->setCoupon($cart);
         $deletecouponmsg = true;
     }
     $cp = 0;
     if (method_exists($cart, 'prepareCartProducts')) {
         $cart->prepareCartProducts();
     }
     $cart->setCartIntoSession();
     $stopen = JRequest::getVar('shiptoopen', false);
     //if (!empty($stopen))
     if ($stopen === 'true' || $stopen === '1') {
         $stopen = true;
         $sa = JRequest::setVar('sa', 'adresaina');
     } else {
         $stopen = false;
     }
     //$this->setAddress($cart, true, $stopen);
     $this->setAddress($cart);
     $BT = $cart->BT;
     if ($stopen) {
         $this->setAddress($cart, true, $stopen);
         $cart->BT = $BT;
     } else {
         $cart->ST = 0;
     }
     //die('h');
     $this->setExtAddress($cart, false, $stopen);
     $zip = JRequest::getVar('shipto_zip');
     // IMPORTANT: this function calls shipping if Vm's automatic enabled
     if (method_exists($cart, 'prepareCartData')) {
         $cart->prepareCartData(false);
     }
     // US and Canada fix, show no tax for no state selected
     if (!isset($cart->BT['virtuemart_state_id'])) {
         $cart->BT['virtuemart_state_id'] = '';
     }
     if (!empty($cart->ST)) {
         // if the VM uses BT address instead of ST address in calculation, uncomment the following line:
         // $cart->BT = $cart->ST;   // this only applies to the display of the checkout, not actual saving of the data
         if (!isset($cart->ST['virtuemart_state_id'])) {
             $cart->ST['virtuemart_state_id'] = '';
         }
     }
     @header('Content-Type: text/html; charset=utf-8');
     @header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     @header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the past
     // run vm main controlle due to compatibilty
     JPluginHelper::importPlugin('vmextended');
     JPluginHelper::importPlugin('vmuserfield');
     $dispatcher = JDispatcher::getInstance();
     $_controller = 'cart';
     $trigger = 'onVmSiteController';
     $trigger = 'plgVmOnMainController';
     $dispatcher->trigger($trigger, array($_controller));
     // this function will reload the taxes on products per country
     // this calls api methods as well, let's disable it for now:
     $cart->virtuemart_shipmentmethod_id = 0;
     if (method_exists($cart, 'prepareCartViewData')) {
         $cart->prepareCartViewData();
     }
     if (!empty($virtuemart_currency_id)) {
         $cart->paymentCurrency = $virtuemart_currency_id;
     }
     if ($cmd == 'process_coupon') {
         $cart->couponCode = JRequest::getVar('coupon_code', '');
         $this->setCoupon($cart);
         // set coupon
     }
     $view->cart = $cart;
     $view->assignRef('cart', $cart);
     //if (($cmd != 'runpay') && ($cmd != 'refreshPayment'))
     // this influences the recalculation of the basket:
     $cmds = array('process_coupon', 'refresh-totals', 'refresh_totals', 'removecoupon', 'delete_product', 'update_product', 'checkvatopc', 'delete_product', 'update_product', 'updateattributes', 'get_shipping');
     if (empty($cmd) || in_array($cmd, $cmds) || stripos($cmd, 'shipping') !== false) {
         $shipping = $OPCloader->getShipping($view, $cart, true);
         $saved_totals = OPCloader::$totals_html;
     } else {
         $shipping = 'opc_do_not_update';
         OPCloader::$totals_html = '';
     }
     $return['shipping'] = $shipping;
     if (empty(OPCloader::$inform_html)) {
         OPCloader::$inform_html = array();
     }
     $return['inform_html'] = implode('', OPCloader::$inform_html);
     if (!empty($cart->couponCode)) {
         $db = JFactory::getDBO();
         $q = "select * from #__virtuemart_coupons where coupon_code = '" . $db->getEscaped($cart->couponCode) . "' limit 0,1";
         $db->setQuery($q);
         $res = $db->loadAssoc();
         if (!empty($res)) {
             if ($res['percent_or_total'] == 'percent') {
                 $cp = $res['coupon_value'];
             }
         }
         if (empty($cp)) {
             if (OPCloader::tableExists('awocoupon')) {
                 $db = JFactory::getDBO();
                 $q = "select * from #__awocoupon where coupon_code = '" . $db->getEscaped($cart->couponCode) . "' and coupon_value_type = 'percent' limit 0,1";
                 $db->setQuery($q);
                 $res = $db->loadAssoc();
                 if (!empty($res)) {
                     $cp = $res['coupon_value'];
                 }
             }
         }
     }
     if (!empty($cp)) {
         $cp = (double) $cp;
         if (round($cp) == $cp) {
             $cp = (int) $cp . ' %';
         } else {
             $cp = number_format($cp, 2, '.', ' ') . ' %';
         }
     }
     $return['couponpercent'] = $cp;
     // get payment html
     $num = 0;
     if ($cmd == 'runpay') {
         $view->cart->virtuemart_shipmentmethod_id = JRequest::getVar('shipping_rate_id', '');
     }
     $isexpress = OPCloader::isExpress($cart);
     $ph2_a = $OPCloader->getPayment($view, $num, false, $isexpress);
     $ph2 = $ph2_a['html'];
     $return['payment_extra'] = $ph2_a['extra'];
     /*
     if (!empty($ph_a['extra']))
     {
       foreach ($ph_a['extra'] as $key=>$val)
     		  {
     		    $return['payment_extra'].$val; 
     		  }
     }
     */
     if ($cmd == 'runpay') {
         $cart->virtuemart_shipmentmethod_id = null;
     }
     if (!empty(OPCloader::$totalIsZero)) {
         $hide_payment_if_one = true;
         $num = 1;
         $ph2 = '<input type="hidden" value="0" name="virtuemart_paymentmethod_id" id="virtuemart_paymentmethod_id_0" />';
     }
     if (!empty($hide_payment_if_one) && $num === 1 || $isexpress) {
         $ph = '<div class="payment_inner_html" rel="force_hide_payments">' . $ph2;
     } else {
         $ph = '<div class="payment_inner_html" rel="force_show_payments">' . $ph2;
     }
     $ph .= '</div>';
     $return['payment'] = $ph;
     if (isset($saved_totals)) {
         $return['totals_html'] = $saved_totals;
     } else {
         $return['totals_html'] = OPCloader::$totals_html;
     }
     $return['min_pov'] = OPCloader::checkPurchaseValue($cart);
     if (!empty($return['totals_html'])) {
         $session = JFactory::getSession();
         /*
         $r = $session->get('opcuniq'); 
         if (empty($r))
         {
         $rand = uniqid('', true); 
                $session->set('opcuniq', $rand);
                $session->set($rand, '0');
         }
         */
         $rand = uniqid('', true);
         $return['totals_html'] .= '<input type="hidden" name="opcuniq" value="' . $rand . '" />';
     }
     $t = $return['shipping'] . ' ' . $return['payment'];
     $t = str_replace('//<![CDATA[', '', $t);
     $t = str_replace('//]]> ', '', $t);
     $t = str_replace('<![CDATA[', '', $t);
     $t = str_replace(']]> ', '', $t);
     $t = str_replace('#paymentForm', '#adminForm', $t);
     //$t = str_replace('jQuery(document).ready(', ' jQuery( ', $t);
     $js = array();
     if (strpos($t, '<script') !== false) {
         $xa = basketHelper::strposall($t, '<script');
         foreach ($xa as $st) {
             // end of <script tag
             $x1 = strpos($t, '>', $st + 1);
             // end of </scrip tag
             $x2 = strpos($t, '</scrip', $st + 1);
             $js1 = substr($t, $x1 + 1, $x2 - $x1 - 1);
             $js[] = $js1;
         }
     }
     $return['shipping'] .= JHtml::_('form.token');
     $return['payment'] .= JHtml::_('form.token');
     if (isset(VmPlugin::$ccount)) {
         if (!empty($opc_debug)) {
             $js[] = "\n" . 'op_log("Positive cache match: ' . VmPlugin::$ccount . '");';
         }
     }
     if (!empty($opc_debug)) {
         if (defined('OPCMEMSTART')) {
             $mem = memory_get_usage(true);
             $memd = $mem - OPCMEMSTART;
             $memd = (double) ($memd / 1024);
             $memd = number_format($memd, 0, '.', ' ');
             if (!defined('debugmem')) {
                 $debugmem = $mem - OPCMEMSTART;
                 $debugmem = (double) ($debugmem / 1024);
             } else {
                 $debugmem = (double) (debugmem / 1024);
             }
             $debugmem = number_format($debugmem, 0, '.', ' ');
             $mem = (double) ($mem / 1024);
             $mem = number_format($mem, 0, '.', ' ');
             $js[] = "\n" . 'op_log("Memory usage: ' . $memd . 'kb of ' . $mem . 'kb, debug mem: ' . $debugmem . 'kb ");';
         }
     }
     $return['javascript'] = $js;
     $return['opcplugins'] = OPCloader::getPluginData($cart);
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'removemsgs.php';
     OPCremoveMsgs::removeMsgs($cart);
     $x = JFactory::getApplication()->getMessageQueue();
     $arr = array();
     $disablarray = array('Unrecognised mathop', JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS'));
     include JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'third_party' . DS . 'third_party_disable_msgs.php';
     $euvat_text = array('VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_VALID', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_COUNTRYCODE', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_FORMAT_REASON', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_FORMAT', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_SERVICE_UNAVAILABLE', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_COMPANYNAME_REQUIRED');
     foreach ($euvat_text as $k => $t) {
         $tt = JText::_($t);
         $euvat_text[$k] = substr($tt, 0, 20);
     }
     $euvatinfo = '';
     $remove = array();
     foreach ($x as $key => $val) {
         foreach ($euvat_text as $kx => $eutext) {
             // echo 'comparing '.$eutext.' with '.$val['message']."<br />\n";
             if (stripos($val['message'], $eutext) !== false) {
                 $euvatinfo .= $val['message'];
                 $remove[] = $key;
                 break;
             }
         }
         foreach ($disablarray as $msg) {
             if (stripos($val['message'], $msg) !== false) {
                 $remove[] = $key;
             }
             if (stripos($val['message'], JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID')) !== false) {
                 $cart->couponCode = '';
                 $cart->setCartIntoSession();
             }
         }
     }
     if (!empty($euvatinfo)) {
         $return['checkvat'] = $euvatinfo;
     }
     foreach ($x as $key => $val) {
         if (!in_array($key, $remove)) {
             $arr[] = $val['message'];
         }
     }
     $return['msgs'] = $arr;
     if (!empty($opc_debug)) {
         if (!empty(OPCloader::$debugMsg)) {
             $return['debug_msgs'] = OPCloader::$debugMsg;
         }
     }
     if (!empty($cart->couponCode)) {
         $return['couponcode'] = $cart->couponCode;
     } else {
         $return['couponcode'] = '';
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php';
     OPCShopperGroups::setShopperGroupsController($cart);
     $upd = array('update_product', 'delete_product', 'process_coupon', 'removecoupon', 'updateattribute', 'refreshall', 'updateattributes', 'checkvatopc', 'checkvat', 'vat_info');
     if (in_array($cmd, $upd) || stripos($cmd, 'shipping') !== false || !empty($ajaxify_cart)) {
         if ($shipping == 'opc_do_not_update') {
             $shipping = '';
         }
         if (!empty($ph2_a['html'])) {
             $payment_html = $op_payment = '<div id="payment_html">' . $ph2_a['html'] . '</div>';
         } else {
             $payment_html = $op_payment = '<div id="payment_html">&nbsp;</div>';
         }
         $html = $this->getCartHtml($cart, $OPCloader, $shipping, $payment_html);
         $return['basket'] = $html;
     }
     $cart->virtuemart_shipmentmethod_id = 0;
     $cart->virtuemart_paymentmethod_id = 0;
     $cart->setCartIntoSession();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     //echo json_encode('');
     echo json_encode($return);
     //echo $shipping;
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('updateAbaData', array());
     if ($restoreBT) {
         $cart->BT = $opcsavedBT;
     }
     if ($restoreST) {
         $cart->ST = $opcsavedST;
     }
     $cart->setCartIntoSession();
     $mainframe = JFactory::getApplication();
     // do not allow further processing
     $mainframe->close();
     die;
 }