Example #1
0
 function installphpexcell()
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     $data = OPCloader::fetchUrl('http://www.rupostel.com/gpl/phpexcell.zip');
     if (!empty($data)) {
         $zip = JPATH_ROOT . DS . 'libraries' . DS . 'PHPExcel' . DS . 'phpexcel.zip';
         $dest = JPATH_ROOT . DS . 'libraries' . DS . 'PHPExcel';
         jimport('joomla.filesystem.file');
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.archive');
         jimport('joomla.archive.archive');
         if (JFolder::create($dest) !== false) {
             if (JFile::write($zip, $data) !== false) {
                 if (JArchive::extract($zip, $dest . DS) !== false) {
                     $msg = JText::_('COM_ONEPAGE_OK');
                 }
             }
         }
     }
     if (empty($msg)) {
         $msg = 'Error';
     }
     $data = JRequest::get('post');
     if (isset($data['limitstart'])) {
         $limitstart = $data['limitstart'];
     } else {
         $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
     }
     $mainframe = JFactory::getApplication();
     if (isset($data['limit'])) {
         $limit = $data['limit'];
     }
     if (empty($limit)) {
         $limit = $mainframe->getUserStateFromRequest("{$option}.limit", 'limit', 50, 'int');
     }
     $link = 'index.php?option=com_onepage&view=orders&limitstart=' . $limitstart . '&limit=' . $limit;
     $this->setRedirect($link, $msg);
 }
Example #2
0
 function xmlexportData()
 {
     $entity = JRequest::getVar('entity', '');
     $ref_id = JRequest::getVar('asset', 'virtuemart_category_id');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $entity = JFile::makeSafe($entity);
     $cache_dir = JPATH_CACHE . DS . 'com_onepage' . DS;
     $cache_file = $cache_dir . 'xmlcache_' . $entity . '.php';
     if (!file_exists($cache_dir)) {
         JFolder::create($cache_dir);
     }
     if (file_exists($cache_file)) {
         include $cache_file;
         if (isset($return)) {
             return $return;
         }
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'controllers' . DS . 'xmlexport.php';
     $xc = new VirtueMartControllerXmlexport();
     $class = $xc->createXml($entity);
     if (empty($class)) {
         return;
     }
     if (method_exists($class, 'getPairingUrl')) {
         $url = $class->getPairingUrl();
     } else {
         if (isset($class->xml->category_pairing_url)) {
             $url = (string) $class->xml->category_pairing_url;
         } else {
             return;
         }
     }
     if (method_exists($class, 'getPairingName')) {
         $name = $class->getPairingName();
     } else {
         if (isset($class->xml->category_pairing_name)) {
             $name = (string) $class->xml->category_pairing_name;
         } else {
             $name = $entity;
         }
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     $res = OPCloader::fetchUrl($url);
     if (empty($res)) {
         return;
     }
     $converted = array();
     if (method_exists($class, 'processPairingData')) {
         $data = $class->processPairingData($res, $converted);
     } else {
         return;
     }
     if (empty($converted)) {
         foreach ($data->children as $topcat) {
             $converted[$topcat->id] = $topcat->txt;
             if (!empty($topcat->children)) {
                 $this->recurseCat($topcat->children, $converted[$topcat->id], $converted);
             }
         }
     }
     $data = '<?php defined( \'_JEXEC\' ) or die( \'Restricted access\' );' . "\n";
     $data .= ' $return = ' . var_export($converted, true);
     $data .= '; ' . "\n";
     JFile::write($cache_file, $data);
     return $converted;
 }
Example #3
0
    public static function getPayment(&$ref, &$OPCloader, &$num, $ajax = false, $isexpress = false)
    {
        if ($isexpress) {
            $reta = array();
            $reta['html'] = '<input type="hidden" name="virtuemart_paymentmethod_id" value="' . $ref->cart->virtuemart_paymentmethod_id . '" />';
            $reta['extra'] = '';
            return $reta;
        }
        include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
        $payment_not_found_text = '';
        $payments_payment_rates = array();
        if (!class_exists('OPCrenderer')) {
            require JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'renderer.php';
        }
        $renderer = OPCrenderer::getInstance();
        if (!$renderer->checkPaymentMethodsConfigured()) {
            if (method_exists($renderer, 'assignRef')) {
                $renderer->assignRef('paymentplugins_payments', $payments_payment_rates);
                $renderer->assignRef('found_payment_method', $found_payment_method);
            }
        }
        $p = JRequest::getVar('payment_method_id', $payment_default);
        if (empty($p)) {
            $selectedPayment = empty($ref->cart->virtuemart_paymentmethod_id) ? 0 : $ref->cart->virtuemart_paymentmethod_id;
        } else {
            $selectedPayment = $p;
        }
        // set missing fields for klarna
        OPCloader::prepareBT($ref->cart);
        $dpps = array();
        $shipping = JRequest::getVar('shipping_rate_id', '');
        //if ($ajax)
        if (!empty($shipping)) {
            if (!empty($disable_payment_per_shipping)) {
                $session = JFactory::getSession();
                $dpps = $session->get('dpps', null);
                if (empty($dpps)) {
                    $OPCloader->getShipping($ref, $ref->cart, true);
                }
                $dpps = $session->get('dpps', null);
                if (!empty($dpps)) {
                }
            }
        }
        //
        if (!empty($shipping)) {
            if (!empty($shipping)) {
                $ref->cart->virtuemart_shipmentmethod_id = $shipping;
            }
            $vm2015 = false;
            $ref->cart->prices = $ref->cart->pricesUnformatted = OPCloader::getCheckoutPrices($ref->cart, false, $vm2015, 'opc');
        }
        $paymentplugins_payments = array();
        if ($p === 'none') {
            $p = 0;
        }
        if ($payment_default === 'none') {
            $paymentplugins = array();
            $psel = '<input onclick="javascript: Onepage.runPay(\'\',\'\',op_textinclship, op_currency, 0)" type="radio" name="virtuemart_paymentmethod_id" id="payment_id_0"   value="0" not_a_valid_payment="not_a_valid_payment" ';
            if (empty($p) || $p === 'none') {
                $psel .= ' selected="selected" ';
                $payment_default = 0;
            }
            $psel .= ' />
<label for="payment_id_0"><span class="vmpayment"><span class="vmpayment_name">-' . OPCLang::_('COM_VIRTUEMART_CART_EDIT_PAYMENT') . '- </span></span></label>';
            $paymentplugins[] = $psel;
        }
        if (!class_exists('vmPSPlugin')) {
            require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
        }
        JPluginHelper::importPlugin('vmpayment');
        $dispatcher = JDispatcher::getInstance();
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'ajaxhelper.php';
        $bhelper = new basketHelper();
        //$bhelper->createDefaultAddress($ref, $ref->cart);
        //old: 2.0.208 and prior: $returnValues = $dispatcher->trigger('plgVmDisplayListFEPayment', array($ref->cart, $selectedPayment, &$paymentplugins_payments));
        //plgVmDisplayListFEPaymentOPCNocache
        $returnValues = $dispatcher->trigger('plgVmDisplayListFEPaymentOPCNocache', array(&$ref->cart, $selectedPayment, &$paymentplugins_payments));
        if (empty($returnValues)) {
            $returnValues = $dispatcher->trigger('plgVmDisplayListFEPayment', array($ref->cart, $selectedPayment, &$paymentplugins_payments));
        }
        // if no payment defined
        $found_payment_method = false;
        $n = 0;
        $debug = '';
        foreach ($paymentplugins_payments as $p1) {
            if (is_array($p1)) {
                $n += count($p1);
            }
        }
        if ($n > 0) {
            $found_payment_method = true;
        }
        $num = $n;
        if (!$found_payment_method) {
            $link = '';
            // todo
            $payment_not_found_text = OPCLang::sprintf('COM_VIRTUEMART_CART_NO_PAYMENT_METHOD_PUBLIC', '<a href="' . $link . '">' . $link . '</a>');
        }
        require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'ajaxhelper.php';
        $bhelper = new basketHelper();
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'transform.php';
        $ret = array();
        if ($found_payment_method) {
            if (!empty($payment_inside)) {
                $ret2 = OPCTransform::paymentToSelect($paymentplugins_payments, $shipping, $dpps);
                if (!empty($ret2)) {
                    $ret = array($ret2['select']);
                    $extra = $ret2['extra'];
                    /*
                    		  foreach ($ret['extra'] as $key=>$val)
                    {
                      $extra[$key] = $val; 
                    }
                    */
                }
            }
            if (empty($payment_inside) || empty($ret)) {
                $sorted = array();
                $unknown = array();
                foreach ($paymentplugins_payments as $paymentplugin_payments) {
                    if (is_array($paymentplugin_payments)) {
                        foreach ($paymentplugin_payments as $paymentplugin_payment) {
                            $id = OPCTransform::getFT($paymentplugin_payment, 'input', 'virtuemart_paymentmethod_id', 'name', 'virtuemart_paymentmethod_id', '>', 'value');
                            if (is_array($id)) {
                                $id = reset($id);
                            }
                            $paymentplugin_payment = str_replace('class="vmpayment_description"', 'class="vmpayment_description vmpayment_description_' . $id . '"', $paymentplugin_payment);
                            //vmpayment_cardinfo
                            $paymentplugin_payment = str_replace('class="vmpayment_cardinfo"', 'class="vmpayment_cardinfo vmpayment_cardinfo_' . $id . '"', $paymentplugin_payment);
                            //ccDetails
                            $paymentplugin_payment = str_replace('class="ccDetails"', 'class="ccDetails ccDetails_' . $id . '"', $paymentplugin_payment);
                            OPCloader::opcDebug('checking shipping ' . $shipping);
                            OPCloader::opcDebug('dpps:');
                            OPCloader::opcDebug($dpps);
                            OPCloader::opcDebug('dpps_disable:');
                            OPCloader::opcDebug($dpps_disable);
                            if (!empty($shipping)) {
                                if (!empty($dpps)) {
                                    if (!empty($disable_payment_per_shipping)) {
                                        foreach ($dpps_disable as $k => $v) {
                                            if (!empty($dpps[$k])) {
                                                foreach ($dpps[$k] as $y => $try) {
                                                    if ((int) $dpps[$k][$y] == (int) $shipping) {
                                                        if ($dpps_disable[$k] == $id) {
                                                            OPCloader::opcDebug('disabling payment id ' . $id . ' for shipping id ' . $shipping);
                                                            $paymentplugin_payment = '';
                                                            continue 3;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            // PPL Pro fix
                            $paymentplugin_payment = str_replace('<br/><a href="' . JRoute::_('index.php?option=com_virtuemart&view=cart&task=editpayment&Itemid=' . JRequest::getInt('Itemid'), false) . '">' . JText::_('VMPAYMENT_PAYPAL_CC_ENTER_INFO') . '</a>', '', $paymentplugin_payment);
                            $paymentplugin_payment = str_replace('name="virtuemart_paymentmethod_id"', 'name="virtuemart_paymentmethod_id" onclick="javascript: Onepage.runPay(\'\',\'\',op_textinclship, op_currency, 0)" ', $paymentplugin_payment);
                            $ret[] = $paymentplugin_payment;
                            if ($n === 1 && !empty($hide_payment_if_one)) {
                                $paymentplugin_payment = str_replace('type="radio"', 'type="hidden"', $paymentplugin_payment);
                            }
                            if (is_numeric($id)) {
                                $ind = (int) $id;
                                if (empty($sorted[$ind])) {
                                    $sorted[$ind] = $paymentplugin_payment;
                                } else {
                                    $unknown[] = $paymentplugin_payment;
                                }
                            } else {
                                if (is_numeric($id[0])) {
                                    $ind = (int) $id[0];
                                    if (empty($sorted[$ind])) {
                                        $sorted[$ind] = $paymentplugin_payment;
                                    } else {
                                        $unknown[] = $paymentplugin_payment;
                                    }
                                } else {
                                    $unknown[] = $paymentplugin_payment;
                                }
                            }
                        }
                    }
                }
                if (!empty($sorted)) {
                    $dbj = JFactory::getDBO();
                    $dbj->setQuery("select * from #__virtuemart_paymentmethods where published = '1' order by ordering asc limit 999");
                    $list = $dbj->loadAssocList();
                    $msg = $dbj->getErrorMsg();
                    if (!empty($msg)) {
                        echo $msg;
                    }
                    $sortedfinal = array();
                    if (!empty($list)) {
                        foreach ($list as $pme) {
                            if (!empty($sorted[$pme['virtuemart_paymentmethod_id']])) {
                                $sortedfinal[] = $sorted[$pme['virtuemart_paymentmethod_id']];
                            }
                        }
                        if (empty($unknown)) {
                            $unknown = array();
                        }
                        if (!empty($sortedfinal)) {
                            $ret = array_merge($sortedfinal, $unknown);
                        }
                    }
                }
            }
        } else {
            $ret[] = $payment_not_found_text . '<input type="hidden" name="virtuemart_paymentmethod_id" id="opc_missing_payment" value="0" />';
        }
        if (empty($payment_inside)) {
            if (!empty($ret)) {
                if (!empty($paymentplugins)) {
                    $ret = array_merge($paymentplugins, $ret);
                }
            }
        }
        $vars = array('payments' => $ret, 'cart' => $ref->cart);
        $html = $OPCloader->fetch($OPCloader, 'list_payment_methods.tpl', $vars);
        $pid = JRequest::getVar('payment_method_id', '');
        if (!empty($pid) && is_numeric($pid)) {
            if (strpos($html, 'value="' . $pid . '"') !== false) {
                $html = str_replace('checked="checked"', '', $html);
                $html = str_replace(' checked', ' ', $html);
                $html = str_replace('value="' . $pid . '"', 'value="' . $pid . '" checked="checked" ', $html);
            }
        } else {
            if (strpos($html, 'value="' . $payment_default . '"') !== false) {
                $html = str_replace('checked="checked"', '', $html);
                $html = str_replace(' checked', ' ', $html);
                $html = str_replace('value="' . $payment_default . '"', 'value="' . $payment_default . '" checked="checked" ', $html);
            }
        }
        $html = str_replace('"radio"', '"radio" autocomplete="off" ', $html);
        if (!$payment_inside) {
            if (strpos($html, 'checked') === false) {
                $x1 = strpos($html, 'name="virtuemart_paymentmethod_id"');
                if ($x1 !== false) {
                    $html = substr($html, 0, $x1) . ' checked="checked" ' . substr($html, $x1);
                } else {
                    // we've got no method here !
                }
            }
        }
        // klarna compatibility
        $count = 0;
        $html = str_replace('name="klarna_paymentmethod"', 'name="klarna_paymentmethod_opc"', $html, $count);
        $html .= '<input type="hidden" name="opc_payment_method_id" id="opc_payment_method_id" value="" />';
        if ($count > 0) {
            if (!defined('klarna_opc_id')) {
                $html .= '<input type="hidden" name="klarna_opc_method" id="klarna_opc_method" value="" />';
                define('klarna_opc_id', 1);
            }
        }
        $reta = array();
        $reta['html'] = $html;
        if (!empty($extra)) {
            $reta['extra'] = $extra;
        } else {
            $reta['extra'] = '';
        }
        return $reta;
    }
Example #4
0
    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;
        }
    }
Example #5
0
 /**
  * Creates HTTP request and returns response body
  * 
  * @param string $url URL
  * @return string Response body
  */
 private function sendRequest($url)
 {
     if (!function_exists('fsockopen')) {
         if (class_exists('OPCloader')) {
             return OPCloader::fetchUrl($url);
         }
         return false;
     }
     $parsed = parse_url($url);
     $fp = fsockopen($parsed['host'], 80, $errno, $errstr, 5);
     if (!$fp) {
         //throw new OPCHeurekaOverenoException($errstr . ' (' . $errno . ')');
         return false;
     } else {
         $return = '';
         $out = "GET " . $parsed['path'] . "?" . $parsed['query'] . " HTTP/1.1\r\n" . "Host: " . $parsed['host'] . "\r\n" . "Connection: Close\r\n\r\n";
         //stAn - protect agains slow server:
         $start = microtime(true);
         fputs($fp, $out);
         while (!feof($fp)) {
             $return .= fgets($fp, 128);
             $now = microtime(true);
             if ($now - $start > 10) {
                 break;
             }
         }
         fclose($fp);
         $returnParsed = explode("\r\n\r\n", $return);
         return empty($returnParsed[1]) ? '' : trim($returnParsed[1]);
     }
 }
Example #6
0
 public static function paymentToSelect($htmla, $shipping, $dpps)
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $pid = JRequest::getVar('payment_method_id', $payment_default);
     if ($payment_default === 'none') {
         $payment_default = 0;
         $adds = true;
     }
     $options = '';
     if (!empty($adds)) {
         $options .= '<option not_a_valid_payment="not_a_valid_payment" value="0" id="payment_id_0">' . OPCLang::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . '</option>';
     }
     $extra = array();
     foreach ($htmla as $paymentplugin_payments) {
         if (is_array($paymentplugin_payments)) {
             foreach ($paymentplugin_payments as $paymentplugin_payment) {
                 $id = self::getFT($paymentplugin_payment, 'input', 'virtuemart_paymentmethod_id', 'name', 'virtuemart_paymentmethod_id', '>', 'value');
                 OPCloader::opcDebug('checking shipping ' . $shipping);
                 OPCloader::opcDebug('dpps:');
                 OPCloader::opcDebug($dpps);
                 OPCloader::opcDebug('dpps_disable:');
                 OPCloader::opcDebug($dpps_disable);
                 if (!empty($shipping)) {
                     if (!empty($dpps)) {
                         if (!empty($disable_payment_per_shipping)) {
                             $idp = $id[0];
                             foreach ($dpps_disable as $k => $v) {
                                 if (!empty($dpps[$k])) {
                                     foreach ($dpps[$k] as $y => $try) {
                                         if ((int) $dpps[$k][$y] == (int) $shipping) {
                                             OPCloader::opcDebug('found shipping ' . $dpps[$k][$y] . ' testing payment id' . $idp);
                                             if ($dpps_disable[$k] == $idp) {
                                                 OPCloader::opcDebug('disabling payment id ' . $idp . ' for shipping id ' . $shipping);
                                                 $paymentplugin_payment = '';
                                                 continue 3;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $html = self::getInnerTag('label', $paymentplugin_payment);
                 // remove description:
                 $xd = stripos($html, '<span class="vmpayment_description">');
                 if ($xd !== false) {
                     $s1 = stripos($html, '</span>', $xd);
                     $len = strlen('</span>');
                     $html = substr($html, 0, $xd) . substr($html, $s1 + $len);
                 }
                 $x = str_replace($html, '', $paymentplugin_payment);
                 $t1 = strip_tags($x);
                 $t2 = trim($t1);
                 $hasextra = false;
                 if (!empty($t2)) {
                     $x2 = self::getUnclosedTag('input', $x, 'virtuemart_paymentmethod_id');
                     // remove the payment input
                     $x = str_replace($x2, '', $x);
                     $extra[$id[0]] = '<div class="payment_extra" style="display: none;" id="extra_payment_' . $id[0] . '">' . $x . '</div>';
                     $hasextra = true;
                 } else {
                     $extra[$id[0]] = '';
                 }
                 $html = strip_tags($html);
                 $options .= '<option value="' . $id[0] . '"';
                 if ($id[0] == $pid) {
                     $options .= ' selected="selected" ';
                 }
                 if ($hasextra) {
                     $options .= ' rel="' . $id[0] . '" ';
                 }
                 $options .= '>' . $html . '</option>';
             }
         }
     }
     $select = '<select autocomplete="off" id="opcPaymentSelect" class="opcPaymentSelect" onchange="javascript: Onepage.runPaySelect(this);" name="virtuemart_paymentmethod_id">' . $options . '</select>';
     //$extra['-1'] = $select;
     $a2 = array();
     $a2['extra'] = '';
     $a2['select'] = $select;
     /*	
     foreach ($extra as $key=>$l)
     	$a2['extra'] .= $l; 
     */
     if (empty($extra)) {
         $extra = array();
     }
     $a2['extra'] = $extra;
     return $a2;
 }
Example #7
0
    public static function getBasket(&$ref, $OPCloader, $withwrapper = true, &$op_coupon = '', $shipping = '', $payment = '', $isexpress = false)
    {
        include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
        $has_k2 = OPCloader::tableExists('k2mart');
        if (!class_exists('ShopFunctions')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
        }
        if (!method_exists('ShopFunctions', 'convertWeightUnit')) {
            $opc_show_weight = false;
        }
        /*
           if (!class_exists('VirtueMartModelProduct'))
         require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php');
        */
        require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
        $productClass = OPCmini::getModel('product');
        //new VirtueMartModelProduct();
        if (!class_exists('CurrencyDisplay')) {
            require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
        }
        $currencyDisplay = CurrencyDisplay::getInstance($ref->cart->pricesCurrency);
        $google_html = '';
        $VM_LANG = new op_languageHelper();
        $product_rows = array();
        $p2 = $ref->cart->products;
        if (empty($ref->cart)) {
            $ref->cart = VirtueMartCart::getCart();
        }
        $vm2015 = false;
        $ref->cart->prices = $ref->cart->pricesUnformatted = OPCloader::getCheckoutPrices($ref->cart, false, $vm2015, 'opc');
        $useSSL = VmConfig::get('useSSL', 0);
        $action_url = $OPCloader->getActionUrl($OPCloader, true);
        $xi = 0;
        if (isset($currencyDisplay->_priceConfig)) {
            $savedConfig = $currencyDisplay->_priceConfig;
        }
        if (empty($product_price_display)) {
            $product_price_display = 'salesPrice';
        }
        //$test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax', 'costPrice');
        $test_product_price_display = array($product_price_display, 'salesPrice', 'basePrice', 'priceWithoutTax', 'basePriceWithTax', 'priceBeforeTax');
        // check price config
        $testf = false;
        foreach ($test_product_price_display as $product_price_display_test) {
            $test = $currencyDisplay->createPriceDiv($product_price_display, '', '10', false, false, 1);
            if (empty($test)) {
                if (isset($currencyDisplay->_priceConfig)) {
                    if (isset($currencyDisplay->_priceConfig[$product_price_display_test])) {
                        if (empty($currencyDisplay->_priceConfig[$product_price_display_test][0])) {
                            $currencyDisplay->_priceConfig[$product_price_display_test] = array(1, -1, 1);
                        }
                    }
                }
                $testf = true;
            } else {
                if (!isset($product_price_display_test2)) {
                    $product_price_display_test2 = $product_price_display_test;
                }
            }
        }
        if (empty($testf)) {
            $product_price_display = $product_price_display_test2;
        }
        $totalw = 0;
        $to_weight_unit = VmConfig::get('weight_unit_default', 'KG');
        foreach ($ref->cart->products as $pkey => $prow) {
            if ($opc_show_weight) {
                $totalw += ShopFunctions::convertWeightUnit((double) $prow->product_weight, $prow->product_weight_uom, $to_weight_unit) * (double) $prow->quantity;
            }
            $product = array();
            $id = $prow->virtuemart_media_id;
            if (empty($id)) {
                $imgf = '';
            } else {
                if (is_array($id)) {
                    $id = reset($id);
                }
                $imgf = $OPCloader->getImageFile($id);
            }
            $product['product_full_image'] = $imgf;
            if (!empty($opc_only_parent_links)) {
                if (!empty($prow->product_parent_id)) {
                    $parent = $prow->product_parent_id;
                    $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $parent . '&view=productdetails', true);
                }
            }
            // check if k2 exists:
            if (!isset($prow->url)) {
                if (isset($prow->link)) {
                    $prow->url = $prow->link;
                    if (strpos($prow->url, '&amp;') === false) {
                        $prow->url = str_replace('&', '&amp;', $prow->url);
                    }
                } else {
                    $prow->url = JRoute::_('index.php?option=com_virtuemart&virtuemart_product_id=' . $prow->virtuemart_product_id . '&view=productdetails', true);
                }
            }
            if ($has_k2) {
                $db = JFactory::getDBO();
                $q = 'select baseID from #__k2mart where referenceID = ' . (int) $prow->virtuemart_product_id . ' limit 0,1';
                $db->setQuery($q);
                $k2_id = $db->loadResult();
                if (!empty($k2_id)) {
                    $prow->url = JRoute::_('index.php?option=com_k2&id=' . $k2_id . '&view=item', true);
                }
            }
            $product['product_name'] = JHTML::link($prow->url, $prow->product_name, ' class="opc_product_name" ');
            if ((!defined('VM_VERSION') || VM_VERSION < 3) && (isset($prow->customfields) && !is_array($prow->customfields))) {
                if (!empty($opc_editable_attributes)) {
                    $product['product_attributes'] = '<div style="clear:both;">' . OPCrenderer::getCustomFields($prow->virtuemart_product_id, $prow->cart_item_id, $prow->quantity) . '</div>';
                } else {
                    $product['product_attributes'] = $prow->customfields;
                }
            } else {
                $product['product_attributes'] = '';
            }
            /*
            var_dump($prow->customfields); 
            $cart = VirtuemartCart::getCart();
            
            $p = array(); 
            foreach ($cart->products as $k=>$v)
            {
              $p[$k] = $v; 
            } 
            unset($cart->products); 
            
            unset($cart->ST); 
            unset($cart->BT); 
            unset($cart->BTaddress); 
            unset($cart->STaddress); 
            $cart->products = $p; 
            $cart->setCartIntoSession(); 
            var_dump($cart->products); die(); 
            var_dump($cart); 
            JFactory::getApplication()->close(); 
            */
            if (defined('VM_VERSION') && VM_VERSION >= 3) {
            }
            if (isset($prow->customfields) && is_array($prow->customfields)) {
                $customfieldsModel = OPCmini::getModel('Customfields');
                $product['product_attributes'] = $customfieldsModel->CustomsFieldCartDisplay($prow);
            }
            $product['product_sku'] = $prow->product_sku;
            // end price test
            if (isset($prow->quantity)) {
                $product['product_quantity'] = $prow->quantity;
            }
            if (isset($prow->min_order_level)) {
                $product['min_order_level'] = $prow->min_order_level;
            }
            if (isset($prow->max_order_level)) {
                $product['max_order_level'] = $prow->max_order_level;
            }
            //$product_model = $OPCloader->getModel('product');
            $xi++;
            if (empty($no_extra_product_info)) {
                $prowcopy = $productClass->getProduct($prow->virtuemart_product_id, true);
            } else {
                $prowcopy = $prow;
            }
            $product['info'] = $prowcopy;
            $product['product'] = $prow;
            if (isset($ref->cart->prices[$pkey])) {
                $currentPrice = $ref->cart->prices[$pkey];
            } else {
                if (isset($prow->prices)) {
                    $currentPrice = $prow->prices;
                }
            }
            if ($product_price_display == 'salesPrice') {
                if (isset($prow->prices)) {
                    $product['product_price'] = $currentPrice['salesPrice'];
                } else {
                    if (isset($prow->salesPrice)) {
                        $product['product_price'] = $prow->salesPrice;
                    } else {
                        if (isset($prow->basePriceWithTax)) {
                            $product['product_price'] = $prow->basePriceWithTax;
                        } else {
                            if (isset($prow->basePrice)) {
                                $product['product_price'] = $prow->basePrice;
                            }
                        }
                    }
                }
            } else {
                if (isset($prow->prices)) {
                    $product['product_price'] = $currentPrice[$product_price_display];
                } else {
                    if (isset($prow->{$product_price_display})) {
                        $product['product_price'] = $prow->{$product_price_display};
                    } else {
                        if (isset($prow->salesPrice)) {
                            $product['product_price'] = $prow->salesPrice;
                        }
                    }
                }
            }
            if (!isset($product['product_price'])) {
                $price = $ref->cart->pricesUnformatted[$pkey];
                $product['product_price'] = $price[$product_price_display];
            }
            if (empty($product['product_price'])) {
                $product_price_display = 'salesPrice';
                $price = $ref->cart->pricesUnformatted[$pkey];
                $product['product_price'] = $price['salesPrice'];
            }
            $price_raw = $product['product_price'];
            // the quantity is not working up to 2.0.4
            $product['product_id'] = $prow->virtuemart_product_id;
            $google_html .= '<input type="hidden" name="prod_id" value="' . $prow->virtuemart_product_id . '" />
			   <input type="hidden" name="prodsku_' . $prow->virtuemart_product_id . '" id="prodsku_' . $prow->virtuemart_product_id . '" value="' . OPCloader::slash($prow->product_sku, false) . '" />
			   <input type="hidden" name="prodname_' . $prow->virtuemart_product_id . '" id="prodname_' . $prow->virtuemart_product_id . '" value="' . OPCloader::slash($prow->product_name, false) . '" />
			   <input type="hidden" name="prodq_' . $prow->virtuemart_product_id . '" id="prodq_' . $prow->virtuemart_product_id . '" value="' . $prow->quantity . '" />
			   <input type="hidden" name="produprice_' . $prow->virtuemart_product_id . '" id="produprice_' . $prow->virtuemart_product_id . '" value="' . $price_raw . '" />
			    <input type="hidden" name="prodcat_' . $prow->virtuemart_product_id . '" id="prodcat_' . $prow->virtuemart_product_id . '" value="' . $prow->category_name . '" />
			   
			   
			  ';
            if (isset($ref->cart->pricesUnformatted[$pkey])) {
                $price = $ref->cart->pricesUnformatted[$pkey];
            } else {
                $price = $prow->prices;
            }
            $product['prices'] = $price;
            $product['prices_formatted'] = array();
            if ($vm2015) {
                foreach ($price as $key => $pricev) {
                    //if (!isset($price[$key]))
                    if (!empty($pricev)) {
                        $product['prices_formatted'][$key] = $currencyDisplay->createPriceDiv($key, '', $price, false, true, 1);
                    }
                }
            }
            $product['product_price'] = $currencyDisplay->createPriceDiv($product_price_display, '', $price, false, true, 1);
            /*
            if (false)
            if (empty($product['product_price']))
            {
              // ok, we have a wrong type selected here
            				if ($product_price_display == 'salesPrice') 
            				$product['product_price'] = $currencyDisplay->createPriceDiv('basePrice','', $price,false,false, 1);
            				if (empty($product['product_price']))
            				$product['product_price'] = $currencyDisplay->createPriceDiv('priceWithoutTax','', $price,false,false, 1);
            				if (empty($product['product_price']))
            				$product['product_price'] = $currencyDisplay->createPriceDiv('basePriceWithTax','', $price,false,false, 1);
            				if (empty($product['product_price']))
            				$product['product_price'] = $currencyDisplay->createPriceDiv('priceBeforeTax','', $price,false,false, 1);
            				if (empty($product['product_price']))
            				$product['product_price'] = $currencyDisplay->createPriceDiv('costPrice','', $price,false,false, 1);
            				
            
            				 
            }
            */
            $product['product_price'] = str_replace('class="', 'class="opc_price_general opc_', $product['product_price']);
            if (!isset($prow->cart_item_id)) {
                $prow->cart_item_id = $pkey;
            }
            $v = array('product' => $prow, 'action_url' => $action_url, 'use_ssl' => $useSSL, 'useSSL' => $useSSL);
            if (!empty($ajaxify_cart)) {
                $update_form = $OPCloader->fetch($OPCloader, 'update_form_ajax.tpl', $v);
                $delete_form = $OPCloader->fetch($OPCloader, 'delete_form_ajax.tpl', $v);
            } else {
                $update_form = $OPCloader->fetch($OPCloader, 'update_form.tpl', $v);
                $delete_form = $OPCloader->fetch($OPCloader, 'delete_form.tpl', $v);
                $op_coupon_ajax = '';
            }
            if (empty($update_form)) {
                if (!empty($ajaxify_cart)) {
                    $product['update_form'] = '<input type="text" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" class="inputbox" size="3" name="quantity" id="quantity_for_' . md5($prow->cart_item_id) . '" value="' . $prow->quantity . '" /><a class="updatebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="#" rel="' . $prow->cart_item_id . '|' . md5($prow->cart_item_id) . '"> </a>';
                    $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="#" rel="' . $prow->cart_item_id . '"> </a>';
                } else {
                    $product['update_form'] = '<form action="' . $action_url . '" method="post" style="display: inline;">
				<input type="hidden" name="option" value="com_virtuemart" />
				<input type="text" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" class="inputbox" size="3" name="quantity" value="' . $prow->quantity . '" />
				<input type="hidden" name="view" value="cart" />
				<input type="hidden" name="task" value="update" />
				<input type="hidden" name="cart_virtuemart_product_id" value="' . $prow->cart_item_id . '" />
				<input type="submit" class="updatebtn" name="update" title="' . OPCLang::_('COM_VIRTUEMART_CART_UPDATE') . '" value=" "/>
			  </form>';
                    if (defined('VM_VERSION') && VM_VERSION >= 3) {
                        $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="' . JRoute::_('index.php?option=com_virtuemart&view=cart&task=delete.' . $prow->cart_item_id . '&cart_virtuemart_product_id=' . $prow->cart_item_id, true, $useSSL) . '"> </a>';
                    } else {
                        $product['delete_form'] = '<a class="deletebtn" title="' . OPCLang::_('COM_VIRTUEMART_CART_DELETE') . '" href="' . JRoute::_('index.php?option=com_virtuemart&view=cart&task=delete&cart_virtuemart_product_id=' . $prow->cart_item_id, true, $useSSL) . '"> </a>';
                    }
                }
            } else {
                $product['update_form'] = $update_form;
                $product['delete_form'] = $delete_form;
            }
            if (!empty($ajaxify_cart)) {
                $product['update_form'] = str_replace('href=', 'onclick="return Onepage.updateProduct(this);" href=', $product['update_form']);
                $product['delete_form'] = str_replace('href=', 'onclick="return Onepage.deleteProduct(this);" href=', $product['delete_form']);
            }
            //vm3 update:
            if (defined('VM_VERSION') && VM_VERSION >= 3) {
                $product['update_form'] = str_replace('name="quantity"', 'name="quantity[' . $prow->cart_item_id . ']"', $product['update_form']);
                $product['update_form'] = str_replace('value="update"', 'value="updatecart"', $product['update_form']);
            }
            $product['subtotal'] = $prow->quantity * $price_raw;
            //else
            //$product['subtotal'] = $prow->subtotal_with_tax;
            // this is fixed from 2.0.4 and would not be needed
            if (isset($ref->cart->pricesUnformatted[$pkey])) {
                $copy = $ref->cart->pricesUnformatted[$pkey];
            } else {
                $copy = $prow->prices;
            }
            //$copy['salesPrice'] = $copy['subtotal_with_tax'];
            $copy[$product_price_display] = $product['subtotal'];
            $product['subtotal'] = $currencyDisplay->createPriceDiv($product_price_display, '', $copy, false, true, 1);
            $product['subtotal'] = str_replace('class="', 'class="opc_', $product['subtotal']);
            // opc vars
            $product_rows[] = $product;
            //break;
        }
        //$shipping_inside_basket = false;
        $shipping_select = $shipping;
        $payment_select = $payment;
        if (!empty($ref->cart->prices['salesPriceCoupon'])) {
            if (empty($coupon_price_display)) {
                $coupon_price_display = 'salesPriceCoupon';
            }
            $coupon_display = $currencyDisplay->createPriceDiv($coupon_price_display, '', $ref->cart->prices, false, true, 1);
            //$ref->cart->prices['salesPriceCoupon'];
            $coupon_display = str_replace('class="', 'class="opc_', $coupon_display);
        } else {
            $coupon_display = '';
        }
        if (!empty($coupon_display)) {
            $discount_after = true;
        } else {
            $discount_after = false;
        }
        if (empty($other_discount_display)) {
            $other_discount_display = 'billDiscountAmount';
        }
        switch ($other_discount_display) {
            case 'billDiscountAmount':
                $coupon_display_before = $currencyDisplay->createPriceDiv('billDiscountAmount', '', $ref->cart->prices, false, false, 1);
                if (empty($ref->cart->prices['billDiscountAmount'])) {
                    $coupon_display_before = '';
                }
                break;
            case 'discountAmount':
                $coupon_display_before = $currencyDisplay->createPriceDiv('discountAmount', '', $ref->cart->prices, false, false, 1);
                if (empty($ref->cart->prices['discountAmount'])) {
                    $coupon_display_before = '';
                }
            case 'minus':
                $billD = abs($ref->cart->prices['billDiscountAmount']);
                foreach ($ref->cart->prices as $key => $val) {
                    if (!empty($ref->cart->products[$key])) {
                        if (is_array($val)) {
                            $billD -= abs($val['subtotal_discount']);
                        }
                    }
                }
                $billD = abs($billD) * -1;
                $prices_new['billTotal'] = $billD;
                if (!empty($billD)) {
                    $coupon_display_before = $currencyDisplay->createPriceDiv('billTotal', '', $prices_new, false, false, 1);
                } else {
                    $coupon_display_before = '';
                }
                break;
            case 'sum':
                $billD = 0;
                foreach ($ref->cart->prices as $key => $val) {
                    if (!empty($ref->cart->products[$key])) {
                        if (is_array($val)) {
                            $billD += $val['subtotal_discount'];
                        }
                    }
                }
                $billD = abs($billD) * -1;
                $prices_new['billTotal'] = $billD;
                if (!empty($billD)) {
                    $coupon_display_before = $currencyDisplay->createPriceDiv('billTotal', '', $prices_new, false, false, 1);
                } else {
                    $coupon_display_before = '';
                }
                break;
        }
        $coupon_display_before = str_replace('class="', 'class="opc_', $coupon_display_before);
        //else $coupon_display_before = '';
        $opc_show_weight_display = '';
        if (!empty($opc_show_weight) && !empty($totalw)) {
            $dec = $currencyDisplay->getDecimalSymbol();
            $th = $currencyDisplay->getThousandsSeperator();
            $w = VmConfig::get('weight_unit_default', 'KG');
            $w = strtoupper($w);
            if ($w == 'OZ') {
                $w = 'OUNCE';
            }
            $unit = JText::_('COM_VIRTUEMART_UNIT_SYMBOL_' . $w);
            if ($unit == 'COM_VIRTUEMART_UNIT_SYMBOL_' . $w) {
                $unit = $w = VmConfig('weight_unit_default', 'kg');
            }
            $opc_show_weight_display = number_format($totalw, 2, $dec, $th) . ' ' . $unit;
        }
        if (!empty($ajaxify_cart)) {
            $coupon_text = $ref->cart->couponCode ? OPCLang::_('COM_VIRTUEMART_COUPON_CODE_CHANGE') : OPCLang::_('COM_VIRTUEMART_COUPON_CODE_ENTER');
            $vars = array('coupon_text' => $coupon_text, 'coupon_display' => $coupon_display);
            $op_coupon_ajax = $OPCloader->fetch($OPCloader, 'couponField_ajax', $vars);
            if (stripos($op_coupon_ajax, 'Onepage.setCouponAjax') === false) {
                $op_coupon_ajax = str_replace('type="button', 'onclick="return Onepage.setCouponAjax(this);" type="button', $op_coupon_ajax);
            }
        }
        if (empty($subtotal_price_display)) {
            $subtotal_price_display = 'salesPrice';
        }
        if ($subtotal_price_display != 'diffTotals') {
            $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $ref->cart->prices, false, false, 1);
            if ($subtotal_price_display == 'basePriceWithTax') {
                if (stripos($subtotal_display, ' ></span') !== false) {
                    $subtotal_price_display = 'salesPrice';
                    $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $ref->cart->prices, false, false, 1);
                }
            }
        } else {
            $subtotal = $ref->cart->prices['billTotal'] - $ref->cart->prices['billTaxAmount'];
            $arr = array('diffTotals' => $subtotal);
            $subtotal_display = $currencyDisplay->createPriceDiv($subtotal_price_display, '', $arr, false, false, 1);
        }
        //$ref->cart->prices['salesPrice'];
        $subtotal_display = str_replace('class="', 'class="opc_', $subtotal_display);
        $prices = $ref->cart->prices;
        if (!isset($prices[$subtotal_price_display . 'Shipment'])) {
            if ($subtotal_price_display != 'salesPrice') {
                $order_shipping = $prices['shipmentValue'];
            } else {
                $order_shipping = $prices['salesPriceShipment'];
            }
        } else {
            $order_shipping = $prices[$subtotal_price_display . 'Shipment'];
        }
        if (!empty($order_shipping)) {
            $virtuemart_currency_id = OPCloader::getCurrency($ref->cart);
            $order_shipping = $currencyDisplay->convertCurrencyTo($virtuemart_currency_id, $order_shipping, false);
            $test = $currencyDisplay->createPriceDiv($product_price_display, '', $order_shipping, false, true, 1);
            if (!empty($test)) {
                $order_shipping = $test;
            }
            $order_shipping = str_replace('class="', 'class="opc_', $order_shipping);
        } else {
            $order_shipping = '';
        }
        $continue_link = $OPCloader->getContinueLink($ref);
        $order_total_display = $currencyDisplay->createPriceDiv('billTotal', '', $ref->cart->prices, false, false, 1);
        //$ref->cart->prices['billTotal'];
        $order_total_display = str_replace('class="', 'class="opc_', $order_total_display);
        // this will need a little tuning
        foreach ($ref->cart->cartData['taxRulesBill'] as $rule) {
            $rulename = $rule['calc_name'];
            if (!empty($ref->cart->prices[$rule['virtuemart_calc_id'] . 'Diff'])) {
                $tax_display = $currencyDisplay->createPriceDiv($rule['virtuemart_calc_id'] . 'Diff', '', $ref->cart->prices, false, false, 1);
                //$ref->cart->prices[$rule['virtuemart_calc_id'].'Diff'];
                $tax_display = str_replace('class="', 'class="opc_', $tax_display);
            } else {
                $tax_display = '';
            }
        }
        $op_disable_shipping = OPCloader::getShippingEnabled($ref->cart);
        if (!empty($payment_discount_before) && !empty($coupon_display_before)) {
            $discount_before = true;
        } else {
            $discount_before = false;
        }
        $disable_couponns = VmConfig::get('coupons_enable', true);
        if (empty($disable_couponns)) {
            $op_coupon = $op_coupon_ajax = '';
        }
        if (!empty($op_coupon_ajax)) {
            $op_coupon = $op_coupon_ajax;
        }
        if ($isexpress) {
            $payment_inside_basket = false;
        }
        if (empty($payment_inside_basket)) {
            $payment_select = '';
        }
        if (empty($shipping_inside_basket)) {
            $shipping_select = '';
        }
        if (empty($tax_display)) {
            $tax_display = '';
        }
        if (empty($op_disable_shipping)) {
            $op_disable_shipping = false;
        }
        $no_shipping = $op_disable_shipping;
        $vars = array('product_rows' => $product_rows, 'payment_inside_basket' => $payment_inside_basket, 'shipping_select' => $shipping_select, 'payment_select' => $payment_select, 'shipping_inside_basket' => $shipping_inside_basket, 'coupon_display' => $coupon_display, 'subtotal_display' => $subtotal_display, 'no_shipping' => $no_shipping, 'order_total_display' => $order_total_display, 'tax_display' => $tax_display, 'VM_LANG' => $VM_LANG, 'op_coupon_ajax' => $op_coupon_ajax, 'continue_link' => $continue_link, 'coupon_display_before' => $coupon_display_before, 'discount_before' => $discount_before, 'discount_after' => $discount_after, 'order_shipping' => $order_shipping, 'cart' => $ref->cart, 'op_coupon' => $op_coupon, 'opc_show_weight_display' => $opc_show_weight_display);
        //original cart support:
        $ref->cart->cartData['shipmentName'] = '';
        $ref->cart->cartData['paymentName'] = '';
        $totalInPaymentCurrency = $ref->getTotalInPaymentCurrency();
        $cd = CurrencyDisplay::getInstance($ref->cart->pricesCurrency);
        $layoutName = 'default';
        $confirm = 'confirm';
        $shippingText = '';
        $paymentText = '';
        $checkout_link_html = '';
        $useSSL = VmConfig::get('useSSL', 0);
        $useXHTML = true;
        $checkoutAdvertise = '';
        if (!class_exists('OPCrenderer')) {
            require JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'renderer.php';
        }
        $renderer = OPCrenderer::getInstance();
        if (method_exists($renderer, 'assignRef')) {
            $renderer->assignRef('cart', $renderer->cart);
            $renderer->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
            $renderer->assignRef('layoutName', $layoutName);
            $renderer->assignRef('select_shipment_text', $shippingText);
            $renderer->assignRef('checkout_task', $confirm);
            $renderer->assignRef('currencyDisplay', $cd);
            $renderer->assignRef('select_payment_text', $paymentText);
            $renderer->assignRef('checkout_link_html', $checkout_link_html);
            $renderer->assignRef('useSSL', $useSSL);
            $renderer->assignRef('useXHTML', $useXHTML);
            $renderer->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
            $renderer->assignRef('checkoutAdvertise', $checkoutAdvertise);
        }
        if (empty($use_original_basket)) {
            $html = $renderer->fetch($OPCloader, 'basket.html', $vars);
        } else {
            $html = $renderer->fetchBasket($OPCloader, 'basket.html', $vars);
        }
        if ($withwrapper) {
            $html = '<div id="opc_basket">' . $html . '</div>';
        }
        if (!empty($op_no_basket)) {
            $html = '<div style="display: none;">' . $html . '</div>';
        }
        if (isset($currencyDisplay->_priceConfig)) {
            $currencyDisplay->_priceConfig = $savedConfig;
        }
        $ret = $html . $google_html;
        return $ret;
    }
Example #8
0
 public function fetchBasket(&$ref, $template, $vars, $new = '')
 {
     include JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $op_disable_shipping = OPCloader::getShippingEnabled();
     $no_shipping = $op_disable_shipping;
     $instance = OPCrenderer::getInstance();
     return $instance->fetchVirtuemart('pricelist', 'cart', 'default');
 }
 public static function addtocartaslink(&$ref)
 {
     $c = get_class($ref->cart);
     if ($c != 'VirtuemartCart') {
         $ref->cart = VirtuemartCart::getCart();
     }
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $rememberhtml = '';
     $rp = JRequest::getVar('randomproduct', 0);
     if (!empty($rp)) {
         if (OPCloader::checkOPCSecret()) {
             $opc_link_type = 1;
             $q = 'select virtuemart_product_id from #__virtuemart_products where published=1 limit 1';
             $db = JFactory::getDBO();
             $db->setQuery($q);
             $temp_id = $db->loadResult();
             JRequest::setVar('add_id', $temp_id);
         }
     }
     if (empty($opc_link_type)) {
         return;
     }
     $p_id = JRequest::getVar('add_id', '');
     if (empty($p_id)) {
         return;
     }
     if (!isset($ref->cart->order_number)) {
         $ref->cart->order_number = '';
     }
     if (!empty($p_id)) {
         $qq = array();
         if (is_array($p_id)) {
             foreach ($p_id as $i => $item) {
                 if (!is_numeric($p_id[$i])) {
                     break;
                 }
                 $q = JRequest::getVar('qadd_' . $p_id[$i], 1);
                 if (!is_numeric($q)) {
                     break;
                 }
                 $rememberhtml .= '<input type="hidden" name="qadd_' . $p_id[$i] . '" value="' . $q . '" />';
                 $rememberhtml .= '<input type="hidden" name="add_id[' . $i . ']" value="' . $p_id[$i] . '" />';
                 $q = (double) $q;
                 $qq[$p_id[$i]] = $q;
             }
         } else {
             // you can use /index.php?option=com_virtuemart&page=shop.cart&add_id=10&quadd=1;
             // to add two products (ids: 10 and 11) of two quantity each (quadd_11=2 for product id 11 set quantity 2)
             // OR /index.php?option=com_virtuemart&page=shop.cart&add_id[]=10&quadd_10=2&add_id[]=11&qadd_11=2
             $q = JRequest::getVar('qadd_' . $p_id, 1);
             $rememberhtml .= '<input type="hidden" name="qadd_' . $p_id . '" value="' . $q . '" />';
             $rememberhtml .= '<input type="hidden" name="add_id" value="' . $p_id . '" />';
             $q = (double) $q;
             $q2 = JRequest::getVar('qadd', 1);
             //$rememberhtml .= '<input type="hidden" name="qadd" value="'.$q2.'" />';
             if (!is_numeric($p_id)) {
                 return;
             }
             $qq[$p_id] = $q;
             $a = array();
             $a[$p_id] = $p_id;
             $p_id = $a;
         }
     } else {
         return;
     }
     $post = JRequest::get('default');
     /*
     	if (!class_exists('VirtueMartModelProduct'))
     require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php');
     */
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $productClass = OPCmini::getModel('product');
     //new VirtueMartModelProduct();
     //$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array'); //is sanitized then
     $newp = array();
     $rr2 = array();
     foreach ($p_id as $pid) {
         $newp[$pid] = $pid;
         $product = $productClass->getProductSingle($pid, true, true, true);
         $rr = OPCAddToCartAsLink::getProductCustomsFieldCart($product);
         $rr2[] = $rr;
     }
     if ($opc_link_type == 2 || $opc_link_type == 1) {
         if (!empty($ref->cart->products)) {
             $p = $ref->cart->products;
             foreach ($p as $key => $pr) {
                 $id = $pr->virtuemart_product_id;
                 // delete cart content
                 if ($opc_link_type == 1) {
                     if (isset($ref->cart->products[$key])) {
                         $ref->cart->removeProductCart($key);
                     } else {
                         if (isset($ref->cart->product[$id])) {
                             $ref->cart->removeProductCart($id);
                         }
                     }
                     continue;
                 }
                 // do not increment quantity:
                 if ($opc_link_type == 2) {
                     if (in_array($id, $newp)) {
                         return;
                     }
                 }
             }
         }
     }
     $virtuemart_product_ids = JRequest::setVar('virtuemart_product_id', $newp);
     //is sanitized then
     $virtuemart_product_ids = JRequest::setVar('quantity', $qq);
     //is sanitized then
     if (!empty($rr2)) {
         foreach ($rr2 as $rr1) {
             foreach ($rr1 as $post) {
                 $x = JRequest::getVar($post['name']);
                 if (empty($x)) {
                     $test = array();
                     if (strpos($post['name'], ']') !== false) {
                         $post['name'] = parse_str($post['name'] . '=' . $post['value'], $test);
                         $firstkey = 0;
                         if (!empty($test)) {
                             foreach ($test as $key => $val) {
                                 $firstkey = $key;
                                 break;
                             }
                         }
                         $name = $firstkey;
                         $value = $test[$name];
                         JRequest::setVar($name, $value);
                     } else {
                         JRequest::setVar($post['name'], $post['value']);
                     }
                 }
             }
         }
     }
     if (!empty($opc_auto_coupon)) {
         $ref->cart->couponCode = $opc_auto_coupon;
     }
     $ref->cart->add();
     JRequest::setVar('virtuemart_product_id', '');
     JRequest::setVar('add_id', '');
     JRequest::setVar('opc_adc', 1);
     //$quantityPost = (int) $post['quantity'][$p_key];
     return $rememberhtml;
 }
Example #10
0
    public static function getFormVars(&$ref)
    {
        if (!isset(OPCloader::$inform_html)) {
            OPCloader::$inform_html = array();
        }
        $ih = implode('', OPCloader::$inform_html);
        $html = '<input type="hidden" value="com_onepage" name="option" id="opc_option" />
		<input type="hidden" value="checkout" name="task" id="opc_task" />
		<input type="hidden" value="opc" name="view" id="opc_view" />
		<input type="hidden" value="1" name="nosef" id="nosef" />
		<input type="hidden" name="saved_shipping_id" id="saved_shipping_id" value=""/>
		<input type="hidden" name="order_language" value="' . JFactory::getLanguage()->getTag() . '" />
		<input type="hidden" value="opc" name="controller" id="opc_controller" />
		<input type="hidden" name="form_submitted" value="0" id="form_submitted" />
		<div style="display:none;" id="inform_html">&nbsp;' . $ih . '</div>';
        return $html;
    }
Example #11
0
 public static function getUserFields(&$userFields, &$OPCloader, &$cart, $remove = array(), $only = array(), $skipreorder = array())
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $user = JFactory::getUser();
     $uid = $user->get('id');
     //$userFields = $userFieldsOrig;
     if (!empty($userFields)) {
         foreach ($userFields['fields'] as $key => $uf) {
             $userFields['fields'][$key]['formcode'] = str_replace('vm-chzn-select', '', $userFields['fields'][$key]['formcode']);
             $userFields['fields'][$key]['formcode'] = str_replace('maxlength', 'disabledmaxlength', $userFields['fields'][$key]['formcode']);
             if ($key == 'password') {
                 $userFields['fields'][$key]['required'] = true;
             }
             if ($key == 'password2') {
                 $userFields['fields'][$key]['required'] = true;
             }
             $arr = array('name', 'username');
             if (in_array($key, $arr)) {
                 $userFields['fields'][$key]['required'] = 1;
             }
             if (!empty($custom_rendering_fields)) {
                 if (in_array($userFields['fields'][$key]['name'], $custom_rendering_fields)) {
                     unset($userFields['fields'][$key]);
                     continue;
                 }
             }
             if ($key != 'email') {
                 $userFields['fields'][$key]['formcode'] = str_replace('/>', ' autocomplete="off" />', $userFields['fields'][$key]['formcode']);
             }
             if ($key == 'email') {
                 if (!empty($cart->BT['email'])) {
                     $userFields['fields'][$key]['formcode'] = str_replace('value=""', ' value="' . $cart->BT['email'] . '"', $userFields['fields'][$key]['formcode']);
                     $userFields['fields'][$key]['formcode'] = str_replace('type="text"', 'type="email"', $userFields['fields'][$key]['formcode']);
                 }
             }
             $userFields['fields'][$key]['formcode'] = str_replace('size="0"', '', $userFields['fields'][$key]['formcode']);
             // get proper state listing:
             if ($key == 'virtuemart_state_id') {
                 if (!empty($cart->BT['virtuemart_country_id'])) {
                     $c = $cart->BT['virtuemart_country_id'];
                 } else {
                     $c = $default_shipping_country;
                 }
                 if (empty($c)) {
                     $vendor = $OPCloader->getVendorInfo($cart);
                     $c = $vendor['virtuemart_country_id'];
                 }
                 require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'commonhtml.php';
                 $html = OPCCommonHtml::getStateHtmlOptions($cart, $c, 'BT');
                 if (!empty($cart->BT['virtuemart_state_id'])) {
                     $html = str_replace('value="' . $cart->BT['virtuemart_state_id'] . '"', 'value="' . $cart->BT['virtuemart_state_id'] . '" selected="selected"', $html);
                 }
                 //
                 if (!empty($userFields['fields']['virtuemart_state_id']['required'])) {
                     $userFields['fields']['virtuemart_state_id']['formcode'] = '<select class="inputbox multiple opcrequired" id="virtuemart_state_id" opcrequired="opcrequired" size="1"  name="virtuemart_state_id" >' . $html . '</select>';
                 } else {
                     $userFields['fields']['virtuemart_state_id']['formcode'] = '<select class="inputbox multiple" id="virtuemart_state_id"  size="1"  name="virtuemart_state_id" >' . $html . '</select>';
                 }
                 //$userFields['fields'][$key]['formcode'] = '<select class="inputbox multiple" id="virtuemart_state_id"  size="1"  name="virtuemart_state_id" >'.$html.'</select>';
             }
             // add klarna button:
             if (!empty($klarna_se_get_address)) {
                 if ($key == 'socialNumber') {
                     $newhtml = '<input type="button" id="klarna_get_address_button" onclick="return Onepage.send_special_cmd(this, \'get_klarna_address\' );" value="' . OPCLang::_('COM_ONEPAGE_KLARNA_GET_ADDRESS') . '" />';
                     //$userFields['fields'][$key]['formcode'] = str_replace('name="socialNumber"', ' style="width: 70%;" name="socialNumber"', $userFields['fields'][$key]['formcode']).$newhtml;
                     $userFields['fields'][$key]['formcode'] .= $newhtml;
                 }
             }
             // mark email read only when logged in
             if ($key == 'email') {
                 // user is logged, but does not have a VM account
                 if (!OPCloader::logged($cart) && !empty($uid)) {
                     // the user is logged in only in joomla, but does not have an account with virtuemart
                     $userFields['fields'][$key]['formcode'] = str_replace('/>', ' readonly="readonly" />', $userFields['fields'][$key]['formcode']);
                 } else {
                     $userFields['fields'][$key]['formcode'] = str_replace('type="text"', 'type="email"', $userFields['fields'][$key]['formcode']);
                 }
             }
             // remove autocomplete for multi dependant fields
             if ($key == 'virtuemart_country_id') {
                 $userFields['fields'][$key]['formcode'] = str_replace('name=', ' autocomplete="off" name=', $userFields['fields'][$key]['formcode']);
             }
             // set required properly:
             if (isset($userFields['fields'][$key]['name'])) {
                 if (!empty($uf['required']) && strpos($uf['formcode'], 'required') === false) {
                     if ($userFields['fields'][$key]['name'] != 'virtuemart_state_id') {
                         $x1 = strpos($uf['formcode'], 'class="');
                         if ($x1 !== false) {
                             $userFields['fields'][$key]['formcode'] = str_replace('class="', 'class="required ', $uf['formcode']);
                         } else {
                             $userFields['fields'][$key]['formcode'] = str_replace('name="', 'class="required" name="', $uf['formcode']);
                         }
                     }
                 }
             }
             if ($uf['type'] == 'date') {
                 $userFields['fields'][$key]['formcode'] = str_replace(OPCLang::_('COM_VIRTUEMART_NEVER'), $userFields['fields'][$key]['title'], $userFields['fields'][$key]['formcode']);
             }
             if (!empty($op_no_display_name)) {
                 if ($userFields['fields'][$key]['name'] == 'name') {
                     unset($userFields['fields'][$key]);
                     continue;
                 }
             }
             if ($key == 'username') {
                 if (!empty($op_usernameisemail) && $userFields['fields'][$key]['name'] == 'username') {
                     unset($userFields['fields'][$key]);
                     continue;
                 }
             }
             if ($key == 'password') {
                 $userFields['fields']['opc_password'] = $userFields['fields'][$key];
                 $userFields['fields']['opc_password']['formcode'] = str_replace('password', 'opc_password', $userFields['fields']['opc_password']['formcode']);
                 $userFields['fields']['opc_password']['formcode'] = str_replace('type="opc_password"', 'type="password" autocomplete="off" ', $userFields['fields']['opc_password']['formcode']);
                 $userFields['fields']['opc_password']['name'] = 'opc_password';
                 //unset($userFields['fields'][$key]);
                 if (!empty($password_clear_text)) {
                     $userFields['fields']['opc_password']['formcode'] = str_replace('type="password"', 'type="text" ', $userFields['fields']['opc_password']['formcode']);
                 }
                 unset($userFields['fields']['password']);
                 //$l = $userFields['fields']['opc_password'];
             }
             if ($key == 'password2') {
                 if (!empty($password_clear_text)) {
                     $userFields['fields']['password2']['formcode'] = str_replace('type="password"', 'type="text" ', $userFields['fields']['password2']['formcode']);
                 }
                 $userFields['fields']['opc_password2'] = $userFields['fields']['password2'];
                 unset($userFields['fields']['password2']);
             }
             if ($key == 'email') {
                 $userFields['fields'][$key]['formcode'] = str_replace('class="required', 'class="required email ', $userFields['fields']['email']['formcode']);
                 $userFields['fields'][$key]['formcode'] = str_replace('type="text"', 'type="email"', $userFields['fields'][$key]['formcode']);
                 if (!empty($double_email)) {
                     $email2 = $userFields['fields']['email'];
                     $email2['name'] = 'email2';
                     $title = OPCLang::_('COM_ONEPAGE_EMAIL2');
                     if ($title != 'COM_ONEPAGE_EMAIL2') {
                         $email2['title'] = $title;
                     }
                     $email2['formcode'] = str_replace('"email', '"email2', $email2['formcode']);
                     $email2['formcode'] = str_replace('id=', ' onblur="javascript: doublemail_checkMail();" id=', $email2['formcode']);
                     $email2['formcode'] = str_replace('type="email2"', 'type="email"', $email2['formcode']);
                     $h = '<span style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email2_info" class="email2_class">';
                     $emailerr = OPCLang::_('COM_ONEPAGE_EMAIL_DONT_MATCH');
                     if ($emailerr != 'COM_ONEPAGE_EMAIL_DONT_MATCH') {
                         $h .= $emailerr;
                     } else {
                         $h .= "Emails don't match!";
                     }
                     $h .= '</span>';
                     $email2['formcode'] .= $h;
                 }
                 if (!empty($opc_check_email)) {
                     if (!OPCloader::logged($cart) && empty($uid)) {
                         if (!empty($userFields['fields']['email'])) {
                             $un = $userFields['fields']['email']['formcode'];
                             $un = str_replace('id=', ' onblur="javascript: Onepage.email_check(this);" id=', $un);
                             $un .= '<span class="email_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email_already_exists">';
                             $un .= OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL'));
                             $un .= '</span>';
                             $userFields['fields']['email']['formcode'] = $un;
                         }
                     }
                 }
             }
             if ($key == 'EUVatID' || $key == 'eu_vat_id') {
                 $h = '<br /><span style="display: none; position: relative; float: left; clear: both; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="vat_info" class="vat_info">';
                 $h .= '</span>';
                 $userFields['fields'][$key]['formcode'] .= $h;
             }
             if ($key == 'opc_vat') {
                 if (!empty($opc_euvat)) {
                     if (!empty($userFields['fields']['opc_vat'])) {
                         $un = $userFields['fields']['opc_vat']['formcode'];
                         if (!empty($opc_euvat_button)) {
                             $un .= '<br /><input type="button" value="' . OPCLang::_('COM_ONEPAGE_VALIDATE_VAT_BUTTON') . '" onclick="javascript:  Onepage.validateOpcEuVat(this);" class="opc_euvat_button" />';
                         }
                         $un .= '<br /><span class="vat_info" style="display: none; position: relative;  color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="vat_info">';
                         $un .= OPCLang::_('COM_ONEPAGE_VAT_CHECKER_INVALID');
                         $un .= '</span>';
                         $userFields['fields']['opc_vat']['formcode'] = $un;
                     }
                 }
             }
             if ($key == 'username') {
                 if (!empty($opc_check_username)) {
                     if (!OPCloader::logged($cart) && empty($uid)) {
                         if (!empty($userFields['fields']['username'])) {
                             $u = OPCLang::_('COM_VIRTUEMART_REGISTER_UNAME');
                             $un = $userFields['fields']['username']['formcode'];
                             $un = str_replace('id=', ' onblur="javascript: Onepage.username_check(this);" id=', $un);
                             $un .= '<span class="username_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="username_already_exists">';
                             $un .= OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', $u);
                             $un .= '</span>';
                             $userFields['fields']['username']['formcode'] = $un;
                         }
                     }
                 }
             }
         }
     }
     if (!empty($email2)) {
         $userFields['fields']['email2'] = $email2;
     }
     if (!defined('OPC_IN_REGISTRATION_MODE')) {
         jimport('joomla.html.parameter');
         $plugin = JPluginHelper::getPlugin('system', 'vm_mailchimp');
         if (!empty($plugin)) {
             if (class_exists('JParameter')) {
                 $params = new JParameter($plugin->params);
             } else {
                 $params = new JRegistry($plugin->params);
             }
             $opc = $params->get('disable_in_opc', false);
             if (!empty($opc)) {
                 unset($userFields['fields']['mailchimp']);
             }
         }
     }
     if (!empty($userFields)) {
         self::reorderFields($userFields, $skipreorder);
     }
 }
Example #12
0
 function getShippingArray()
 {
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmshipment');
     // lets create a new instance of the cart
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart(false, false);
     //For the selection of the shipment method we need the total amount to pay.
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $shipmentModel = OPCloader::getMini('Shipmentmethod');
     $shipments = $shipmentModel->getShipments();
     return $shipments;
     foreach ($shipments as &$s) {
         $cartData['shipmentName'] = OPCLang::_('COM_VIRTUEMART_CART_NO_SHIPMENT_SELECTED');
         $cartPrices['shipmentValue'] = 0;
         //could be automatically set to a default set in the globalconfig
         $cartPrices['shipmentTax'] = 0;
         $cartPrices['shipmentTotal'] = 0;
         $cartPrices['salesPriceShipment'] = 0;
         $savedc = $cart;
         $cart->virtuemart_shipmentmethod_id = $s->virtuemart_shipmentmethod_id;
         $cart->automaticSelectedShipment = true;
         $cart->setCartIntoSession();
         $returnValues = $dispatcher->trigger('calculateSalesPrice', array(&$cart, &$s, &$cart->priceUnformatted));
         $found_shipment_method = false;
         $shipment_not_found_text = OPCLang::_('COM_VIRTUEMART_CART_NO_SHIPPING_METHOD_PUBLIC');
         $shipments_shipment_rates = array();
         $s->op_prices = $cartPrices;
         $s->op_name = $cartData;
         $cart = $savedc;
     }
     return $shipments;
     if (empty($shipments)) {
         // we have no shipping method avaiable
         define('NO_SHIPPING', '0');
     }
     $selectedShipment = empty($cart->virtuemart_shipmentmethod_id) ? 0 : $cart->virtuemart_shipmentmethod_id;
     $shipments_shipment_rates = array();
     //JPluginHelper::importPlugin('vmshipment');
     $dispatcher = JDispatcher::getInstance();
     unset($_SESSION['load_fedex_prices_from_session']);
     $returnValues = $dispatcher->trigger('plgVmDisplayListFEShipment', array($cart, $selectedShipment, &$shipments_shipment_rates));
     // if no shipment rate defined
     $found_shipment_method = false;
     foreach ($returnValues as $returnValue) {
         if ($returnValue) {
             $found_shipment_method = true;
             break;
         }
     }
     $shipment_not_found_text = OPCLang::_('COM_VIRTUEMART_CART_NO_SHIPPING_METHOD_PUBLIC');
     return;
     $ret = '';
     // if only one Shipment , should be checked by default
     foreach ($shipments_shipment_rates as $shipment_shipment_rates) {
         if (is_array($shipment_shipment_rates)) {
             foreach ($shipment_shipment_rates as $shipment_shipment_rate) {
                 $ret .= $shipment_shipment_rate . '<br />';
             }
         }
     }
     return $ret;
 }
Example #13
0
 public static function loadJavascriptFiles(&$ref, &$OPCloader)
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     /*
     if (!empty($opc_php_js))
     {
       $dc = JFactory::getDocument(); 
       $url = OPCloader::getUrl(true);
          
       $url_onepage = JRoute::_('index.php?option=com_onepage&view=loadjs&task=loadjs&file=sync.js&nosef=1&format=raw'); 
       $dc->addScript($url_onepage, "text/javascript", false, false); 
       $url_onepage = JRoute::_('index.php?option=com_onepage&view=loadjs&task=loadjs&file=onepage.js&nosef=1&format=raw'); 
       $dc->addScript($url_onepage, "text/javascript", true, true); 
       
       
       return; 
     }
     */
     if (empty($opc_async)) {
         $ref->script('onepage.js', 'components/com_onepage/assets/js/', false);
         $ref->script('sync.js', 'components/com_onepage/assets/js/', false);
     } else {
         $ref->script('sync.js', 'components/com_onepage/assets/js/', false);
         $dc = JFactory::getDocument();
         $url = OPCloader::getUrl(true);
         $dc->addScript($url . 'components/com_onepage/assets/js/onepage.js', "text/javascript", true, true);
     }
 }
Example #14
0
 public static function getTosLink(&$ref, &$OPCloader)
 {
     $cart = $ref->cart;
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
     $opclang = JFactory::getLanguage()->getTag();
     $tos_config = OPCconfig::getValue('opc_config', 'tos_config', 0, 0, true);
     if (empty($tos_config) || !is_numeric($tos_config)) {
         $itemid = JRequest::getVar('Itemid', '');
         if (!empty($itemid)) {
             $itemid = '&Itemid=' . $itemid;
         } else {
             $itemid = '';
         }
         $tos_link = OPCloader::getUrl() . 'index.php?nosef=1&format=html&option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=' . $cart->vendor->virtuemart_vendor_id . '&tmpl=component' . $itemid;
         require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'version.php';
         $x = VmVersion::$RELEASE;
         if (strpos($x, '${PHING.VM.RELEASE}') === false) {
             if (!version_compare($x, '2.0.2', '>=')) {
                 return "";
             }
         }
     } else {
         //if (!empty($newitemid))
         //$tos_link = JRoute::_('index.php?option=com_content&view=article&id='.$tos_config.'&tmpl=component&Itemid='.$newitemid);
         //else
         $tos_itemid = OPCconfig::getValue('opc_config', 'tos_itemid', 0, 0, true);
         if (!empty($tos_itemid)) {
             $tos_link = JRoute::_('index.php?option=com_content&view=article&id=' . $tos_config . '&tmpl=component&Itemid=' . $tos_itemid);
         } else {
             $tos_link = JRoute::_('index.php?option=com_content&view=article&id=' . $tos_config . '&tmpl=component');
         }
     }
     $b1 = JURI::root(true);
     if (!empty($b1)) {
         if (strpos($tos_link, $b1) === 0) {
             $tos_link = substr($tos_link, strlen($b1));
         }
     }
     if (strpos($tos_link, 'http') !== 0) {
         $base = JURI::root();
         if (substr($base, -1) == '/') {
             $base = substr($base, 0, -1);
         }
         if (substr($tos_link, 0, 1) !== '/') {
             $tos_link = '/' . $tos_link;
         }
         $tos_link = $base . $tos_link;
     }
     if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) {
         $tos_link = str_replace('http:', 'https:', $tos_link);
     }
     return $tos_link;
 }
Example #15
0
$loader = new OPCloader();
$amount = JRequest::getVar('amount', 0);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Conversion</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body onload="javascript:eval('parent.op_semafor=true;')">
<?php 
$path = JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'trackers' . DS . 'body.html';
if (file_exists($path)) {
    ob_start();
    echo @file_get_contents($path);
    $html = ob_get_clean();
    if (!empty($amount) && !empty($adwords_amount[0])) {
        $html = str_replace($adwords_amount[0], $amount, $html);
    }
    echo $html;
}
?>
<script type="text/javascript" src="<?php 
$url = OPCloader::getUrl();
echo $url;
?>
components/com_onepage/trackers/footer.js">
</script>
</body>
</html>
Example #16
0
 public static function updateHtml($html, &$order, $afterrender = false)
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
     $ty_page = OPCconfig::getValue('ty_page', 'ty_page', 0, array());
     if (empty($ty_page)) {
         return;
     }
     if (empty($order)) {
         return;
     }
     if (is_array($order)) {
         if (isset($order['details'])) {
             $order = $order['details']['BT'];
         }
     }
     //we must reload order here in case any plugin had changed it in meantime:
     $id = $order->virtuemart_order_id;
     if (!empty($id)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
         $orderModel = OPCmini::getModel('orders');
         $order_full = $orderModel->getOrder($id);
         if (empty($order_full)) {
             return;
         }
         $order = $order_full['details']['BT'];
     }
     $status = $order->order_status;
     if (!is_object($order)) {
         return;
     }
     $payment_id = $order->virtuemart_paymentmethod_id;
     if (empty($order->order_language)) {
         $jlang = JFactory::getLanguage();
         $cl = $jlang->getTag();
         $cl = strtolower(str_replace('-', '_', $cl));
     } else {
         $cl = $order->order_language;
     }
     // check conditions:
     $orightml = $html;
     $todo = array();
     foreach ($ty_page as $k => $ty) {
         if (!is_object($ty)) {
             continue;
         }
         if ($ty->payment_id != $payment_id) {
             continue;
         }
         if (!empty($ty->language)) {
             if ($ty->language != $cl) {
                 continue;
             }
         }
         if ($ty->order_status != $status) {
             continue;
         }
         $todo[] = $ty;
     }
     if (empty($todo)) {
         return;
     }
     /*
     	  COM_ONEPAGE_TY_MODE_0="Prepend to payment generated html"
     COM_ONEPAGE_TY_MODE_1="Append to payment generated html"
     COM_ONEPAGE_TY_MODE_2="Replace payment generated html"
     */
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'opctracking.php';
     $repvals = array();
     $order_object = new stdClass();
     OPCtrackingHelper::getOrderVars($id, $repvals, $order_object, false);
     foreach ($todo as $ty2) {
         $htmla = OPCloader::getArticle($ty2->article_id, $repvals);
         if (empty($ty2->mode)) {
             $html = $htmla . '<br />' . $html;
         } else {
             if ($ty2->mode == 1) {
                 $html = $html . '<br />' . $htmla;
             } else {
                 if ($ty->mode == 2) {
                     $html = $htmla;
                 }
             }
         }
     }
     if (defined('TYMODDONE')) {
         return $html;
     } else {
         define('TYMODDONE', true);
     }
     if ($orightml != $html) {
         if (!$afterrender) {
             JRequest::setVar('html', $html);
         } else {
             $buffer = JResponse::getBody();
             $buffer = str_replace($orightml, $html, $buffer);
             JResponse::setBody($buffer);
         }
     }
     return $html;
 }
Example #17
0
 public static function getSTHtml(&$cart)
 {
     $html = '';
     $stId = JRequest::getVar('ship_to_info_id', 0);
     $stId = (int) $stId;
     if (!empty($stId)) {
         $user_id = JFactory::getUser()->get('id');
         if (!empty($user_id)) {
             $db = JFactory::getDBO();
             $q = 'select * from #__virtuemart_userinfos where virtuemart_userinfo_id = ' . $db->escape($stId) . ' limit 0,1';
             $db->setQuery($q);
             $adr1 = $db->loadObject();
             if (!empty($adr1)) {
                 if ($adr1->virtuemart_user_id == $user_id) {
                     /*
                     			   $new_adr1 = new stdClass(); 
                     			   foreach ($adr1 as $key=>$val)
                     			    {
                       $new_adr1->$key = $val; 
                     }
                     */
                     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
                     $umodel = OPCmini::getModel('user');
                     //new VirtuemartModelUser();
                     $virtuemart_userinfo_id = 0;
                     $currentUser = JFactory::getUser();
                     $uid = $currentUser->get('id');
                     $userDetails = $umodel->getUser();
                     $virtuemart_userinfo_id = $umodel->getBTuserinfo_id();
                     $userFields = $umodel->getUserInfoInUserFields('default', 'BT', $virtuemart_userinfo_id);
                     $userFields = $umodel->getUserInfoInUserFields('default', 'ST', $stId);
                     /*
                      */
                     if (method_exists($cart, 'prepareAddressDataInCart')) {
                         $cart->prepareAddressDataInCart('ST', 1);
                     }
                     if (method_exists($cart, 'prepareAddressFieldsInCart')) {
                         $cart->prepareAddressFieldsInCart();
                     }
                     if (isset($cart->STaddress['fields'])) {
                         $BTaddress = $cart->STaddress['fields'];
                     } else {
                         $BTaddress = $cart->BTaddress['fields'];
                     }
                     $new_address_link = '#" onclick="return Onepage.op_showEditST();';
                     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
                     $OPCloader = new OPCloader();
                     $BTaddressNamed = $OPCloader->setCountryAndState($BTaddress);
                     $html = self::renderNamed($BTaddressNamed, $adr1, $cart, $OPCloader, $virtuemart_userinfo_id, true);
                 }
             }
         }
     }
     return $html;
 }
 // legacy vars to be deleted:
 $op_disable_shipping = OPCloader::getShippingEnabled($this->cart);
 if (empty($op_disable_shipping)) {
     $op_disable_shipping = false;
 }
 $no_shipping = $op_disable_shipping;
 $cart = $this->cart;
 if (!empty($min_reached_text)) {
     JFactory::getApplication()->enqueueMessage($min_reached_text);
 }
 if (!empty($min_reached_text) && file_exists(JPATH_OPC . DS . 'themes' . DS . $selected_template . DS . 'onepage.min.tpl.php')) {
     echo '<div class="opc_minorder_wrapper" id="opc_minorder_wrapper" >';
     include JPATH_OPC . DS . 'themes' . DS . $selected_template . DS . 'onepage.min.tpl.php';
     echo '</div>';
 } else {
     if (OPCloader::logged($cart)) {
         if (!empty($min_reached_text)) {
             $html_in_between .= '<div style="clear: both;">' . $min_reached_text . '</div>';
         }
         // let's set the TOS config here
         echo '<div class="opc_logged_wrapper" id="opc_logged_wrapper" >';
         include JPATH_OPC . DS . 'themes' . DS . $selected_template . DS . 'onepage.logged.tpl.php';
         echo '</div>';
     } else {
         if (!empty($min_reached_text)) {
             $html_in_between .= '<div style="clear: both;">' . $min_reached_text . '</div>';
         }
         echo '<div class="opc_unlogged_wrapper" id="opc_unlogged_wrapper" >';
         include JPATH_OPC . DS . 'themes' . DS . $selected_template . DS . 'onepage.unlogged.tpl.php';
         echo '</div>';
     }
Example #19
0
 public static function setShopperGroups($id, $remove = array())
 {
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $user = JFactory::getUser();
     if (empty($allow_sg_update_logged)) {
         if ($user->id != 0 && empty($user->guest)) {
             return $id;
         }
     }
     if (!class_exists('VirtueMartModelShopperGroup')) {
         if (file_exists(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'shoppergroup.php')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'shoppergroup.php';
         } else {
             return 1;
         }
     }
     if (!method_exists('VirtueMartModelShopperGroup', 'appendShopperGroups')) {
         return 1;
     }
     OPCloader::opcDebug('OPC: setShopperGroup: ' . $id);
     $arr = array(1, 2);
     if (!empty($id) && $id > 0 && !in_array($id, $arr)) {
         //remove default and anonymous
         $remove[] = 1;
         $remove[] = 2;
     }
     if (!empty($id)) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
         $shoppergroupmodel = OPCmini::getModel('ShopperGroup');
         //new VirtueMartModelShopperGroup();
         if (method_exists($shoppergroupmodel, 'removeSessionSgrps')) {
             if (method_exists($shoppergroupmodel, 'appendShopperGroups')) {
                 $session = JFactory::getSession();
                 $shoppergroup_ids = $session->get('vm_shoppergroups_add', array(), 'vm');
                 //$shoppergroupmodel->removeSessionSgrps($shoppergroup_ids);
                 $new_shoppergroups = $shoppergroup_ids;
                 foreach ($remove as $rid) {
                     foreach ($new_shoppergroups as $key => $val) {
                         if ($rid == $val) {
                             unset($new_shoppergroups[$key]);
                         }
                     }
                 }
                 $session->set('vm_shoppergroups_remove', $remove, 'vm');
                 if ($id > 0) {
                     if (!in_array($id, $shoppergroup_ids)) {
                         $new_shoppergroups[] = $id;
                         JRequest::setVar('virtuemart_shoppergroup_id', $id, 'post');
                     }
                 }
                 $session = JFactory::getSession();
                 $shoppergroup_ids = $session->set('vm_shoppergroups_add', $new_shoppergroups, 'vm');
                 $user = JFactory::getUser();
                 $shoppergroupmodel->appendShopperGroups($new_shoppergroups, $user);
                 OPCloader::opcDebug('OPC: setShopperGroup changed: ' . $id);
                 if ($id > 0) {
                     return $id;
                 }
             }
         }
     }
     static $default_id;
     if (!empty($default_id)) {
         return $default_id;
     }
     // else
     // this is a VM default group:
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     if (empty($cart->vendorId)) {
         $vid = 1;
     } else {
         $vid = (int) $cart->vendorId;
     }
     $user = JFactory::getDBO();
     $sid = $user->get('id');
     if (empty($id)) {
         if (empty($sid) || $user->guest) {
             //anonymous:
             $db = JFactory::getDBO();
             $q = "select virtuemart_shoppergroup_id from #__virtuemart_shoppergroups where default = '2' virtuemart_vendor_id = " . $vid . " limit 1";
             $db->setQuery($q);
             $id = $db->loadResult();
             $default_id = $id;
         } else {
             $db = JFactory::getDBO();
             $q = "select virtuemart_shoppergroup_id from #__virtuemart_shoppergroups where default = '1' virtuemart_vendor_id = " . $vid . " limit 1";
             $db->setQuery($q);
             $id = $db->loadResult();
             $default_id = $id;
         }
     }
     return $id;
 }
Example #20
0
 function confirmedOrder()
 {
     $cart =& self::$current_cart;
     $payment_id = $cart->virtuemart_paymentmethod_id;
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     //Just to prevent direct call
     if ($cart->_dataValidated && $cart->_confirmDone) {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
         $orderModel = OPCmini::getModel('Orders');
         $this->getModifiedData($cart);
         if (!empty($delivery_date)) {
             $cart->delivery_date = $delivery_date;
         }
         $orderID = $orderModel->createOrderFromCart($cart);
         $this->getModifiedData($cart, true);
         $msgq1 = JFactory::getApplication()->get('messageQueue', array());
         $msgq2 = JFactory::getApplication()->get('_messageQueue', array());
         $op_disable_shipping = OPCloader::getShippingEnabled($cart);
         if ($op_disable_shipping) {
             //$q = 'update #__virtuemart_orders set
         }
         if (empty($orderID)) {
             $mainframe = JFactory::getApplication();
             $this->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&task=checkout', false, VmConfig::get('useSSL', false)));
         }
         $cart->virtuemart_order_id = $orderID;
         $order = $orderModel->getOrder($orderID);
         self::$new_order =& $order;
         $this->getModifiedOrder($order, $cart);
         // $GLOBALS['is_dup']
         if (!empty($orderID)) {
             if (!empty($GLOBALS['is_dup']) && is_numeric($GLOBALS['is_dup'])) {
                 $dbj = JFactory::getDBO();
                 $q = "update #__virtuemart_orders SET virtuemart_user_id = '" . $this->getEscaped($dbj, $GLOBALS['is_dup']) . "' where virtuemart_order_id = '" . $this->getEscaped($dbj, $orderID) . "' limit 1";
                 $dbj->setQuery($q);
                 $dbj->query();
                 $dbj = JFactory::getDBO();
                 $q = "update #__virtuemart_order_userinfos SET virtuemart_user_id = '" . $this->getEscaped($dbj, $GLOBALS['is_dup']) . "' where virtuemart_order_id = '" . $this->getEscaped($dbj, $orderID) . "' limit 2";
                 $dbj->setQuery($q);
                 $dbj->query();
                 $e = $dbj->getErrorMsg();
             } else {
                 if (!empty($GLOBALS['opc_new_user']) && is_numeric($GLOBALS['opc_new_user'])) {
                     $dbj = JFactory::getDBO();
                     $q = "update #__virtuemart_orders SET virtuemart_user_id = '" . $this->getEscaped($dbj, $GLOBALS['opc_new_user']) . "' where virtuemart_order_id = '" . $this->getEscaped($dbj, $orderID) . "' limit 1";
                     $dbj->setQuery($q);
                     $dbj->query();
                     $dbj = JFactory::getDBO();
                     $q = "update #__virtuemart_order_userinfos SET virtuemart_user_id = '" . $this->getEscaped($dbj, $GLOBALS['opc_new_user']) . "' where virtuemart_order_id = '" . $this->getEscaped($dbj, $orderID) . "' limit 2";
                     $dbj->setQuery($q);
                     $dbj->query();
                     $e = $dbj->getErrorMsg();
                 }
             }
         }
         //opc_new_user
         if (empty($order['details']['ST']->email) && !empty($order['details']['BT']->email)) {
             $order['details']['ST']->email = $order['details']['BT']->email;
         }
         // 			$cart = $this->getCart();
         if (isset($order['details']['BT'])) {
             $this->doCurl($order['details']['BT']);
         }
         $dispatcher = JDispatcher::getInstance();
         // 			$html="";
         if ($order['details']['BT']->order_total <= 0) {
             $no_payment = true;
         } else {
             $no_payment = false;
         }
         if (empty($op_disable_shipping)) {
             JPluginHelper::importPlugin('vmshipment');
         }
         JPluginHelper::importPlugin('vmcustom');
         if (empty($no_payment)) {
             JPluginHelper::importPlugin('vmpayment');
         }
         JPluginHelper::importPlugin('vmcustom');
         JPluginHelper::importPlugin('vmcalculation');
         $session = JFactory::getSession();
         $return_context = $session->getId();
         //end OPC email mod
         ob_start();
         $order = $orderModel->getOrder($orderID);
         if ($order['details']['BT']->order_status != $zero_total_status) {
             if ($order['details']['BT']->order_total <= 0) {
                 require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
                 $modelOrder = OPCmini::getModel('orders');
                 $order['order_status'] = $zero_total_status;
                 $order['customer_notified'] = 1;
                 $order['comments'] = '';
                 $modelOrder->updateStatusForOneOrder($orderID, $order, true);
                 //$order['paymentName']= $dbValues['payment_name'];
                 //We delete the old stuff
                 $cart->emptyCart();
             }
         }
         $output = ob_get_clean();
         //$returnValues = $dispatcher->trigger('plgVmConfirmedOrder', array($cart, $order));
         // pairs the cookie with the database
         $returnValues = $dispatcher->trigger('plgOpcOrderCreated', array($cart, $order));
         // runs shipping confirm as first and payment as last
         $returnValues = $dispatcher->trigger('plgVmConfirmedOrderOPC', array('shipment', $cart, $order));
         $returnValues = $dispatcher->trigger('plgVmConfirmedOrderOPC', array('calculation', $cart, $order));
         $returnValues = $dispatcher->trigger('plgVmConfirmedOrderOPC', array('custom', $cart, $order));
         $except = array('shipment', 'custom', 'calculation');
         $returnValues = $dispatcher->trigger('plgVmConfirmedOrderOPCExcept', array($except, $cart, $order));
         //OPC: maybe we want to send emil before a redirect:
         if (!empty($send_pending_mail)) {
             if (!class_exists('shopFunctionsF')) {
                 require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
             }
             //Important, the data of the order update mails, payments and invoice should
             //always be in the database, so using getOrder is the right method
             require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
             $orderModel = OPCmini::getModel('orders');
             //$order = $orderModel->getOrder($orderID);
             $payment_name = $shipment_name = '';
             $op_disable_shipping = OPCloader::getShippingEnabled($cart);
             $msgqx1 = JFactory::getApplication()->get('messageQueue', array());
             $msgqx2 = JFactory::getApplication()->get('_messageQueue', array());
             $msgqx3 = JFactory::getApplication()->getMessageQueue();
             if (!class_exists('vmPSPlugin')) {
                 require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
             }
             if (empty($op_disable_shipping)) {
                 JPluginHelper::importPlugin('vmshipment');
             }
             if (empty($no_payment)) {
                 JPluginHelper::importPlugin('vmpayment');
             }
             $dispatcher = JDispatcher::getInstance();
             if (empty($op_disable_shipping)) {
                 $returnValues = $dispatcher->trigger('plgVmonShowOrderPrintShipment', array($order['details']['BT']->virtuemart_order_id, $order['details']['BT']->virtuemart_shipmentmethod_id, &$shipment_name));
             }
             if (empty($no_payment)) {
                 $returnValues = $dispatcher->trigger('plgVmonShowOrderPrintPayment', array($order['details']['BT']->virtuemart_order_id, $order['details']['BT']->virtuemart_paymentmethod_id, &$payment_name));
             }
             $order['shipmentName'] = $shipment_name;
             if (empty($no_payment)) {
                 $order['paymentName'] = $payment_name;
             } else {
                 $order['paymentName'] = '';
             }
             $vars['orderDetails'] = $order;
             if (!isset($vars['newOrderData'])) {
                 $vars['newOrderData'] = array();
             }
             $vars['newOrderData']['customer_notified'] = 1;
             $vars['url'] = 'url';
             $vars['doVendor'] = false;
             if (!empty($order['details']['BT']->virtuemart_vendor_id)) {
                 $virtuemart_vendor_id = $order['details']['BT']->virtuemart_vendor_id;
             } else {
                 $virtuemart_vendor_id = 1;
             }
             require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
             $vendorModel = OPCmini::getModel('vendor');
             $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
             $vars['vendor'] = $vendor;
             $vendorEmail = $vendorModel->getVendorEmail($virtuemart_vendor_id);
             if (empty($vendorEmail)) {
                 $db = JFactory::getDBO();
                 $query = 'SELECT * FROM `#__virtuemart_vmusers`';
                 $db->setQuery($query);
                 $res = $db->loadAssocList();
                 $query = 'SELECT ju.email FROM `#__virtuemart_vmusers` as vmu, `#__users` as ju WHERE `virtuemart_vendor_id`=' . (int) $virtuemart_vendor_id . ' and ju.id = vmu.virtuemart_user_id and vmu.user_is_vendor = 1 limit 0,1';
                 $db->setQuery($query);
                 $vendorEmail = $db->loadResult();
             }
             $vars['vendorEmail'] = $vendorEmail;
             // Send the email
             if (file_exists(JPATH_VM_SITE . DS . 'views' . DS . 'invoice' . DS . 'view.html.php')) {
                 if (OPCcheckout::renderMail('invoice', $vendorEmail, $vars, null, true, false)) {
                     //ok
                 }
                 $x = JFactory::getApplication()->set('messageQueue', $msgqx1);
                 $x = JFactory::getApplication()->set('_messageQueue', $msgqx2);
                 if (OPCJ3) {
                     if (class_exists('ReflectionClass')) {
                         $a = JFactory::getApplication();
                         $reflectionClass = new ReflectionClass($a);
                         $property = $reflectionClass->getProperty('_messageQueue');
                         $property->setAccessible(true);
                         $property->setValue($a, $msgqx3);
                         $x = JFactory::getApplication()->getMessageQueue();
                     }
                 }
             }
         }
         /*
         jimport( 'joomla.plugin.helper' );
         $plugin = JPluginHelper::getPlugin('vmpayment', 'opctracking');
         if (!empty($plugin))
         {
            $opctracking = true; 
         }
         else 
         {
            $opctracking = false; 
         }
         */
         //$html = JRequest::getVar('html', JText::_('COM_VIRTUEMART_ORDER_PROCESSED'), null, 'string', JREQUEST_ALLOWRAW);
         $html = JRequest::getVar('html', JText::_('COM_VIRTUEMART_ORDER_PROCESSED'), 'default', 'STRING', JREQUEST_ALLOWRAW);
         $app = JFactory::getApplication();
         require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
         $utm_p_load = false;
         $default = array();
         $utm_p = OPCConfig::getValue('opc_config', 'utm_payments', 0, $default, false, false);
         if (!empty($payment_id)) {
             if (in_array($payment_id, $utm_p)) {
                 $utm_p_load = true;
             }
         }
         if (method_exists($app, 'input')) {
             $html2 = $app->input->get('html', JText::_('COM_VIRTUEMART_ORDER_PROCESSED'), 'RAW');
             if ($utm_p_load) {
                 $html2 = str_replace('&amp;view=', '&amp;utm_nooverride=1&view=', $html2);
                 $html2 = str_replace('&view=', '&utm_nooverride=1&view=', $html2);
                 $app->input->set('html', $html2);
             }
         } else {
             $html2 = JRequest::getVar('html', JText::_('COM_VIRTUEMART_ORDER_PROCESSED'), 'default', 'STRING', JREQUEST_ALLOWRAW);
             if ($utm_p_load) {
                 $html2 = str_replace('&view=pluginresponse', '&utm_nooverride=1&view=pluginresponse', $html2);
                 $html2 = str_replace('&amp;view=pluginresponse', '&amp;utm_nooverride=1&amp;view=pluginresponse', $html2);
                 JRequest::setVar('html', $html2);
             }
         }
         if ($html != $html2) {
             $output .= $html2;
         }
         $output .= $html;
         ob_start();
         if ($order['details']['BT']->order_total <= 0) {
             $cart->emptyCart();
         }
         $output .= ob_get_clean();
         $x = JFactory::getApplication()->set('messageQueue', $msgq1);
         $x = JFactory::getApplication()->set('_messageQueue', $msgq2);
         if (!empty($output)) {
             return $output;
         }
         // may be redirect is done by the payment plugin (eg: paypal)
         // if payment plugin echos a form, false = nothing happen, true= echo form ,
         // 1 = cart should be emptied, 0 cart should not be emptied
     }
 }
Example #21
0
            $now = time();
            if ($now - $time > 24 * 60 * 60) {
                $refresh = true;
            }
        } else {
            $refresh = true;
        }
    } else {
        $refresh = true;
    }
} else {
    $refresh = true;
}
if (!empty($refresh) || empty($json)) {
    $url = 'http://partner.pickpackpont.hu/stores/validboltlista.xml';
    $data = OPCloader::fetchUrl($url);
    $json = simplexml_load_string($data);
    if (!empty($json)) {
        $json->OPCtime = time();
        foreach ($json as $key => $val) {
            if (empty($json->{$key})) {
                $json->{$key} = '';
            }
        }
        $json_data = json_encode($json);
        JFile::write($file, $json_data);
        $xmlfile = JPATH_CACHE . DS . 'validboltlista.xml';
        $_SESSION['vm_ppp_xml'] = $xmlfile;
        JFile::write($xmlfile, $data);
    }
}
Example #22
0
 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;
 }
Example #23
0
 public static function fetchUrl($url, $XPost = '')
 {
     if (!function_exists('curl_init')) {
         return file_get_contents($url);
     }
     $ch = curl_init();
     //	 curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_URL, $url);
     // set url to post to
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // return into a variable
     curl_setopt($ch, CURLOPT_TIMEOUT, 4000);
     // times out after 4s
     curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost);
     // add POST fields
     if (!empty($XPost)) {
         curl_setopt($ch, CURLOPT_POST, 1);
     } else {
         curl_setopt($ch, CURLOPT_POST, 0);
     }
     curl_setopt($ch, CURLOPT_ENCODING, "gzip");
     $result = curl_exec($ch);
     if (curl_errno($ch)) {
         OPCloader::opcDebug('ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch));
         @curl_close($ch);
         return false;
     } else {
         $returnCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
         OPCloader::opcDebug($url . ' -> ' . $returnCode);
         switch ($returnCode) {
             case 404:
                 @curl_close($ch);
                 return false;
                 break;
             case 200:
                 break;
             default:
                 @curl_close($ch);
                 return false;
                 break;
         }
     }
     @curl_close($ch);
     return $result;
 }
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * 
 */
if (!defined('_VALID_MOS') && !defined('_JEXEC')) {
    die('Direct Access to ' . basename(__FILE__) . ' is not allowed.');
}
$document = JFactory::getDocument();
ob_start();
echo '<div id="vmMainPageOPC">';
include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
$newitemid = OPCconfig::getValue('opc_config', 'newitemid', 0, 0, true);
if (OPCloader::checkOPCSecret()) {
    $selected_template .= '_preview';
}
$currentUser = JFactory::getUser();
$uid = $currentUser->get('id');
if (!empty($uid)) {
    $no_login_in_template = true;
}
JHTMLOPC::stylesheet('onepage.css', 'components/com_onepage/themes/' . $selected_template . '/', array());
//JHTML::_('behavior.formvalidation');
JHTMLOPC::stylesheet('vmpanels.css', 'components/com_virtuemart/assets/css/', array());
if (!empty($load_min_bootstrap)) {
    JHTMLOPC::stylesheet('bootstrap.min.css', 'components/com_onepage/themes/extra/bootstrap/', array());
}
if (VM_REGISTRATION_TYPE == 'NO_REGISTRATION') {
    $no_login_in_template = true;
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * 
 */
if (!defined('_VALID_MOS') && !defined('_JEXEC')) {
    die('Direct Access to ' . basename(__FILE__) . ' is not allowed.');
}
?>
<!-- italian privacy checkbox -->
<div style="width: 100%;clear:both;text-align:left;margin-left:-20px;">
<div style="width: 5%; float: left;">
<script type="text/javascript">
op_userfields.push('italianagreed'); 
custom_rendering_fields.push('italianagreed'); 
var italagreeerr = "<?php 
echo OPCloader::slash(JText::_('COM_ONEPAGE_ITALIAN_AGREE_ERROR'));
?>
";
function validateItalian()
{
  d = document.getElementById('italianagreed_field'); 
  if (d != null)
  if (!d.checked)
  {
    alert(italagreeerr); 
    return false; 
  }
  return true; 
}
 addOpcTriggerer('callSubmitFunct', 'validateItalian'); 
</script>
Example #26
0
 function getGeneralCacheHash($name, &$cart, &$data = array())
 {
     // will create product hash (quantity, attributes, weight), order of products do not play role:
     OPCcache::createCartHash($cart);
     $carthash = OPCcache::$cartHash;
     // end of product hash
     // will create custom cache per fedex and similar:
     // zip and country are the basic cache dimensions, add more here:
     if (empty($cart->virtuemart_shipmentmethod_id)) {
         $returnValues = array();
     } else {
         if (isset(OPCcache::$cachedResult[$cart->virtuemart_shipmentmethod_id])) {
             // per request cache:
             $returnValues = OPCcache::$cachedResult[$cart->virtuemart_shipmentmethod_id];
         } else {
             JPluginHelper::importPlugin('shipment');
             $dispatcher = JDispatcher::getInstance();
             $returnValues = $dispatcher->trigger('plgVmGetSpecificCache', array($cart));
         }
     }
     $spec_cache = '';
     foreach ($returnValues as $val) {
         if (!empty($val)) {
             $spec_cache .= $val;
         }
     }
     if (!isset(OPCloader::$debugMsg)) {
         OPCloader::$debugMsg = array();
     }
     OPCloader::$debugMsg[] = $spec_cache;
     // end of custom
     // any extras:
     if (!empty($data)) {
         $datahash = md5(serialize($data));
     } else {
         $datahash = '';
     }
     // end of extras
     // basic address:
     $to_address = $cart->ST == 0 ? $cart->BT : $cart->ST;
     $zip = @$to_address['zip'];
     $country = @$to_address['virtuemart_country_id'];
     $country = @$to_address['virtuemart_state_id'];
     // end of basic address
     $alldimensions = $name . md5($carthash . $zip . $country . $datahash . $spec_cache);
     return $alldimensions;
 }
Example #27
0
    }
    $vatids['field'] = (string) $euvat;
    $s = serialize($vatids);
    $vatids = $session->set('opc_vat', $s);
    if (!defined('bit_included')) {
        define('bit_included', 1);
        //http://vm2onj25.rupostel.com/index.php?option=com_onepage&nosef=1&task=opc&view=opc&format=opchtml&tmpl=component&op_onlyd=&lang=
        $bitjs = '
//<![CDATA[
	bit_error_msg = "' . $error_msg . '";
	bit_error_msg_country_mismatch = "' . $error_msg_country_mismatch . '"; 
	bit_validation_method = "' . $validation_method . '"; 
	bit_euvatid_field_name = "' . $euvatid_field_name . '"; 
	bit_prefix_invalid = "' . $prefix_invalid . '";  
	
	bit_current_url = "' . OPCloader::getUrl() . 'index.php?option=com_onepage&task=opc&tmpl=component&cmd=checkbitvat&format=opchtml&nosef=1&view=opc' . '"; 
	
	function opc_bit_check_vatid(el)
	{
	   //Onepage.validateBitVat(el);
	   //return;
		if (el.name.toString().indexOf(\'shipto_\')<0)
		{
		if (typeof document.userForm != \'undefined\')
		{
			 document.userForm[bit_euvatid_field_name] = document.getElementById(bit_euvatid_field_name+\'_field\'); 
			 document.userForm[\'virtuemart_country_id\'] = document.getElementById(\'virtuemart_country_id\'); 
		}
		else
		{
			 document.userForm = new Array(); 
Example #28
0
 public static function loadOpcForLoggedUser()
 {
     include JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'onepage.cfg.php';
     $task = JRequest::getWord('task');
     $option = JRequest::getWord('option');
     $view = JRequest::getWord('view');
     $layout = JRequest::getVar('layout', '');
     if ('user' == $view && ('savecartuser' == $task || strpos($task, 'editadd') !== false)) {
         //if (!defined('JPATH_COMPONENT')) define('JPATH_COMPONENT', JPATH_SITE.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_virtuemart');
         if ($view != 'opc') {
             $config = array("base_path" => JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_virtuemart', "layout" => "default");
         } else {
             $config = array("base_path" => JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage', "layout" => "default");
         }
         $OPCloader = new OPCloader($config);
         if (!class_exists('VirtueMartCart')) {
             require JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_virtuemart' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'cart.php';
         }
         $cart = VirtueMartCart::getCart();
         if ($view != 'opc') {
             if (!OPCloader::logged($cart)) {
                 // we will load OPC for all edit address links for unlogged
                 JRequest::setVar('view', 'cart');
             }
         }
     }
 }
Example #29
0
 public static function getRegistrationHhtml(&$obj, &$OPCloader)
 {
     // if (!empty($no_login_in_template)) return "";
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!empty($obj->cart)) {
         $cart =& $obj->cart;
     } else {
         $cart = VirtueMartCart::getCart();
     }
     $type = 'BT';
     // for unlogged
     $virtuemart_userinfo_id = 0;
     $new = 1;
     $fieldtype = $type . 'address';
     /*
     if (method_exists($cart, 'prepareAddressDataInCart'))
     $cart->prepareAddressDataInCart($type, $new);
     */
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
     OPCUserFields::populateCart($cart, $type, true);
     /*
     if (method_exists($cart, 'prepareAddressFieldsInCart'))
     $cart->prepareAddressFieldsInCart();
     */
     OPCloader::setRegType();
     if (!class_exists('VirtuemartModelUserfields')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'userfields.php';
     }
     $corefields = VirtueMartModelUserfields::getCoreFields();
     $userFields = $cart->{$fieldtype};
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     $layout = 'default';
     foreach ($userFields['fields'] as $key => $uf) {
         if (!in_array($key, $corefields) || $key == 'agreed') {
             unset($userFields['fields'][$key]);
             continue;
         }
         if (!empty($opc_email_in_bt) || $OPCloader->isNoLogin() || $OPCloader->isNoLogin()) {
             if ($userFields['fields'][$key]['name'] == 'email') {
                 unset($userFields['fields'][$key]);
                 continue;
             }
         }
         if ($key == 'email') {
             $user = JFactory::getUser();
             $uid = $user->get('id');
             // user is logged, but does not have a VM account
             if (!OPCloader::logged($cart) && !empty($uid)) {
                 // the user is logged in only in joomla, but does not have an account with virtuemart
                 $userFields['fields'][$key]['formcode'] = str_replace('/>', ' readonly="readonly" />', $userFields['fields'][$key]['formcode']);
             }
         }
     }
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php';
     OPCUserFields::getUserFields($userFields, $OPCloader, $cart);
     // lets move email to the top
     $copy = array();
     // we will reorder the fields, so the email is first when used as username
     $u = OPCLang::_('COM_VIRTUEMART_REGISTER_UNAME');
     //$e = OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL');
     // disable when used for logged in
     if (!empty($userFields['fields'])) {
         /*
              if (empty($opc_email_in_bt) && (!empty($double_email)))
         {
           // email is in BT, let's check for double mail
         		
         		$email2 = $userFields['fields']['email'];
         		$email2['name'] = 'email2'; 
         		$title = OPCLang::_('COM_ONEPAGE_EMAIL2'); 
         		if ($title != 'COM_ONEPAGE_EMAIL2')
         		$email2['title'] = $title;
         		$email2['formcode'] = str_replace('"email', '"email2', $email2['formcode']); 
         		$email2['formcode'] = str_replace('id=', ' onblur="javascript: doublemail_checkMail();" id=', $email2['formcode']);
         		
         		$h = '<span style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email2_info" class="email2_class">';
         		$emailerr = OPCLang::_('COM_ONEPAGE_EMAIL_DONT_MATCH');
         		if ($emailerr != 'COM_ONEPAGE_EMAIL_DONT_MATCH')
         		$h .= $emailerr;
         		else $h .= "Emails don't match!";
         		$h .= '</span>';
         		$email2['formcode'] .= $h;
         }
         */
         /*
         	 if (!empty($opc_check_username))
         	 if ((!OPCloader::logged($cart)) && (empty($uid)))
         	 if (!empty($userFields['fields']['username']))
         {
          
            $un = $userFields['fields']['username']['formcode']; 
         		 $un = str_replace('id=', ' onblur="javascript: Onepage.username_check(this);" id=', $un);
         		 $un .=  '<span class="username_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="username_already_exists">';
         		 $un .= OPCLang::sprintf('COM_VIRTUEMART_STRING_ERROR_NOT_UNIQUE_NAME', $u); 
         		 $un .= '</span>'; 
         		 $userFields['fields']['username']['formcode'] = $un; 
         }
         */
         /*
         if (!empty($opc_check_email))
         if ((!OPCloader::logged($cart)) && (empty($uid)))
         if (!empty($userFields['fields']['email']))
         {
         
            $un = $userFields['fields']['email']['formcode']; 
         		 $un = str_replace('id=', ' onblur="javascript: Onepage.email_check(this);" id=', $un);
         		 $un .=  '<span class="email_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email_already_exists">';
         		 $un .= OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL')); 
         		 $un .= '</span>'; 
         		 $userFields['fields']['email']['formcode'] = $un; 
         }
         */
     }
     /*
     	$OPCloader->reorderFields($userFields); 
     */
     if (count($userFields['fields']) === 0) {
         // no fields found
         return '';
     }
     //if (empty($opc_email_in_bt) && (!empty($double_email)))
     //$OPCloader->insertAfter($userFields['fields'], 'email', $email2, 'email2');
     $vars = array('rowFields' => $userFields, 'cart' => $obj, 'is_registration' => true);
     $html = $OPCloader->fetch($OPCloader, 'list_user_fields.tpl', $vars);
     $html = str_replace("'password'", "'opc_password'", $html);
     $html = str_replace("password2", "opc_password2", $html);
     if (strpos($html, 'email_field') !== false) {
         $html .= '<input type="hidden" name="email_in_registration" value="1" id="email_in_registration" />';
     } else {
         $html .= '<input type="hidden" name="email_in_registration" value="0" id="email_in_registration" />';
     }
     return $html;
 }
 function checkEnabledShipto()
 {
     $op_disable_shipto = OPCloader::getShiptoEnabled($this->cart);
 }