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 getBTfields(&$obj, $unlg = false, $no_wrapper = false) { include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; $default_shipping_country = OPCloader::getDefaultCountry($cart); // $default_shipping_country $islogged = OPCloader::logged($obj->cart); if ($islogged && empty($unlg)) { return $this->getUserInfoBT($obj); } else { 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'; $this->address_type = 'BT'; // for unlogged $virtuemart_userinfo_id = 0; $this->virtuemart_userinfo_id = 0; $new = 1; if (!empty($unlg)) { $new = false; } $fieldtype = $type . 'address'; if (empty($cart->BT)) { $cart->BT = array(); } $user = JFactory::getUser(); $uid = $user->get('id'); // PPL Express address: $moveBT = false; $count = 0; if (!empty($cart->savedST)) { if (!$islogged) { foreach ($cart->savedST as $key => $val) { if ($key == 'virtuemart_country_id') { continue; } if ($key == 'virtuemart_state_id') { continue; } if (substr($key, 0, 7) === 'shipto_') { continue; } if (empty($cart->BT[$key]) && !empty($val)) { $count++; } else { if (!empty($cart->BT[$key]) && $val != $cart->BT[$key]) { $count--; } } } if ($count > 0) { if ($cart->savedST['virtuemart_country_id'] != $cart->BT['virtuemart_country_id']) { $cart->BT['virtuemart_state_id'] = 0; } foreach ($cart->savedST as $key => $val) { if (!empty($val)) { $cart->BT[$key] = $val; } } } } } if (empty($cart->BT['virtuemart_country_id'])) { if (!empty($default_shipping_country) && is_numeric($default_shipping_country)) { $cart->BT['virtuemart_country_id'] = $default_shipping_country; } else { // let's set a default country $vendor = $this->getVendorInfo($cart); $cart->BT['virtuemart_country_id'] = $vendor['virtuemart_country_id']; } } /* if (!empty($cart->BT) && (count($cart->BT)>2)) $new = false; if (empty($cart->BT)) $new = true; */ $type = 'BT'; require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php'; OPCUserFields::populateCart($cart, $type, true); OPCloader::setRegType(); $op_disable_shipto = OPCloader::getShiptoEnabled($cart); if (!class_exists('VirtuemartModelUserfields')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'userfields.php'; } $corefields = VirtueMartModelUserfields::getCoreFields(); $userFields = $cart->{$fieldtype}; if (isset($cart->BTaddress) && isset($cart->BTaddress['fields']) && isset($cart->BTaddress['fields']['virtuemart_country_id']) && !empty($cart->BTaddress['fields']['virtuemart_country_id']['value'])) { if (is_numeric($cart->BTaddress['fields']['virtuemart_country_id']['value'])) { $cart->BT['virtuemart_country_id'] = $cart->BTaddress['fields']['virtuemart_country_id']['value']; } } // unset corefields $onlyf = array(); if (empty($bt_fields_from)) { $q = 'select name from #__virtuemart_userfields where published=1 and registration = 1'; $db = JFactory::getDBO(); $db->setQuery($q); $onlyf2 = $db->loadAssocList(); foreach ($onlyf2 as $k => $v) { $onlyf[] = $v['name']; } } if (!empty($userFields['fields'])) { foreach ($userFields['fields'] as $key => $uf) { // disable fields that are not marked for registration if (!empty($onlyf)) { if (!in_array($uf['name'], $onlyf)) { unset($userFields['fields'][$key]); continue; } } $userFields['fields'][$key]['formcode'] = str_replace('vm-chzn-select', '', $userFields['fields'][$key]['formcode']); OPCloader::$fields_names[$key] = $userFields['fields'][$key]['title']; if ($userFields['fields'][$key]['type'] == 'delimiter') { unset($userFields['fields'][$key]); continue; } foreach ($corefields as $f) { if ($f == $uf['name']) { // will move the email to bt section if (empty($no_login_in_template) || $unlg) { if ($f == 'email') { if (empty($opc_email_in_bt)) { if (!$this->isNoLogin()) { unset($userFields['fields'][$key]); } } } else { unset($userFields['fields'][$key]); } continue; } } } if (empty($custom_rendering_fields)) { $custom_rendering_fields = array(); } if (!empty($custom_rendering_fields)) { if (in_array($uf['name'], $custom_rendering_fields)) { unset($userFields['fields'][$key]); continue; } } if ($key == 'name') { if (!empty($op_no_display_name)) { if (!empty($userFields['fields']['name'])) { unset($userFields['fields']['name']); } } } } } // end of for each require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php'; $skipreorder = array('email'); OPCUserFields::getUserFields($userFields, $this, $cart, array(), array(), $skipreorder); // logic reversed, if email is not in BT, remove it if (!((!empty($opc_email_in_bt) || $this->isNoLogin()) && !empty($double_email))) { unset($userFields['fields']['email2']); // email is in BT, let's check for double mail } $skipreorder = array(); if (!empty($opc_email_in_bt) || $this->isNoLogin()) { $skipreorder[] = 'email'; if (!empty($opc_check_email)) { if (!OPCloader::logged($cart) && empty($uid)) { if (!empty($userFields['fields']['email'])) { $un = $userFields['fields']['email']['formcode']; if (stripos($un, 'id="email_already_exists"') === false) { //if (!$double_email) $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; } } } } } require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'userfields.php'; OPCUserFields::reorderFields($userFields, $skipreorder); require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php'; $this->_model = OPCmini::getModel('user'); //new VirtuemartModelUser(); $layout = 'default'; $hidden = array(); $hidden_html = ''; if (!empty($userFields['fields'])) { foreach ($userFields['fields'] as $key => $val) { if (!empty($val['hidden'])) { $hidden[] = $val; $hidden_html .= $val['formcode']; unset($userFields['fields'][$key]); } } } $vars = array('rowFields' => $userFields, 'cart' => $obj, 'is_logged' => $unlg); $html = $this->fetch($this, 'list_user_fields.tpl', $vars); $hidden_html = str_replace('"required"', '""', $hidden_html); $html .= $hidden_html; $html = $this->addListeners($html); if (empty($custom_rendering_fields)) { $custom_rendering_fields = array(); } if (in_array('virtuemart_country_id', $custom_rendering_fields)) { $html .= '<input type="hidden" id="virtuemart_country_id" name="virtuemart_country_id" value="' . $default_shipping_country . '" />'; } if (in_array('virtuemart_state_id', $custom_rendering_fields)) { $html .= '<input type="hidden" id="virtuemart_state_id" name="virtuemart_state_id" value="0" />'; } return $html; } }