public static function setShopperGroupsController($cart = null) { // we need to alter shopper group for business when set to: $is_business = JRequest::getVar('opc_is_business', 0); $remove = array(); //require_once(JPATH_OPC.DS.'helpers'.DS.'loader.php'); OPCShopperGroups::getSetShopperGroup(); 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; } } if (!method_exists('VirtueMartModelShopperGroup', 'appendShopperGroups')) { return 1; } include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; if (!empty($business_shopper_group) || !empty($visitor_shopper_group)) { if (class_exists('VirtueMartModelShopperGroup')) { $shoppergroupmodel = new VirtueMartModelShopperGroup(); if (method_exists($shoppergroupmodel, 'removeSessionSgrps')) { if (method_exists($shoppergroupmodel, 'appendShopperGroups')) { if (!empty($is_business)) { // we will differenciate between default and anonymous shopper group // default is used for non-logged users // anononymous is used for logged in users as guests OPCShopperGroups::setShopperGroups($business_shopper_group); $remove[] = $visitor_shopper_group; // function appendShopperGroups(&$shopperGroups,$user,$onlyPublished = FALSE,$vendorId=1){ // remove previous: /* $session = JFactory::getSession(); $shoppergroup_ids = $session->get('vm_shoppergroups_add',array(),'vm'); $shoppergroupmodel->removeSessionSgrps($shoppergroup_ids); $new_shoppergroups = array(); $new_shoppergroups[] = $business_shopper_group; $shoppergroup_ids = $session->set('vm_shoppergroups_add',$new_shoppergroups,'vm'); $shoppergroupmodel->appendShopperGroups($new_shoppergroups, null); JRequest::setVar('virtuemart_shoppergroup_id', $new_shoppergroups, 'post'); */ //appendShopperGroups } else { OPCShopperGroups::setShopperGroups($visitor_shopper_group); $remove[] = $business_shopper_group; /* $shoppergroupmodel = new VirtueMartModelShopperGroup(); // function appendShopperGroups(&$shopperGroups,$user,$onlyPublished = FALSE,$vendorId=1){ // remove previous: $session = JFactory::getSession(); $shoppergroup_ids = $session->get('vm_shoppergroups_add',array(),'vm'); $shoppergroupmodel->removeSessionSgrps($shoppergroup_ids); $new_shoppergroups = array(); $new_shoppergroups[] = $visitor_shopper_group; $shoppergroup_ids = $session->set('vm_shoppergroups_add',$new_shoppergroups,'vm'); $shoppergroupmodel->appendShopperGroups($new_shoppergroups, null); JRequest::setVar('virtuemart_shoppergroup_id', $new_shoppergroups, 'post'); */ } } } } } // EU VAT shopper group: if (!empty($euvat_shopper_group)) { $removeu = true; $session = JFactory::getSession(); $vatids = $session->get('opc_vat', array()); if (!is_array($vatids)) { $vatids = @unserialize($vatids); } //BIT vat checker: if (!empty($vatids['field'])) { $euvat = JRequest::getVar($vatids['field'], ''); $euvat = preg_replace("/[^a-zA-Z0-9]/", "", $euvat); $euvat = strtoupper($euvat); if (!empty($cart)) { $address = $cart->ST == 0 ? $cart->BT : $cart->ST; $country = $address['virtuemart_country_id']; } else { $country = JRequest::getVar('virtuemart_country_id'); } $vathash = $country . '_' . $euvat; $home = 'NL'; if (!class_exists('ShopFunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } $country_2_code = shopFunctions::getCountryByID($country, 'country_2_code'); $home = explode(',', $home_vat_countries); $list = array(); if (is_array($home)) { foreach ($home as $k => $v) { $list[] = strtoupper(trim($v)); } } else { $list[] = $v; } if (!in_array($country_2_code, $list)) { if (!empty($euvat)) { $euvat = strtoupper($euvat); if (!empty($vatids[$vathash])) { //change OPC VAT shopper group: OPCShopperGroups::setShopperGroups($euvat_shopper_group); $removeu = false; } } } } if ($removeu) { $remove[] = $euvat_shopper_group; } } OPCShopperGroups::setShopperGroups(-1, $remove); if (class_exists('calculationHelper')) { calculationHelper::$_instance = null; } $session = JFactory::getSession(); $shoppergroup_ids = $session->get('vm_shoppergroups_add', array(), 'vm'); }
public static function getInstance() { if (!is_object(self::$_instance)) { self::$_instance = new calculationHelper(); } else { //We store in UTC and use here of course also UTC $jnow = JFactory::getDate(); self::$_instance->_now = $jnow->toMySQL(); } return self::$_instance; }
public static function getInstance() { if (!is_object(self::$_instance)) { self::$_instance = new calculationHelper(); } else { $jnow = JFactory::getDate(); self::$_instance->_now = $jnow->toMySQL(); } return self::$_instance; }