Author Topic: [SOLVED] ajax registration  (Read 96842 times)

Ventsi Genchev

  • Jr. Member
  • **
  • Posts: 308
    • Audio Store
Re: [SOLVED] ajax registration
« Reply #30 on: April 22, 2010, 08:03:56 am »
Yes, it's even better, but there is a need for such verification?
Otherwise, your method is more accurate. Can benefit both. Matter of choice.  :)

And I want to emphasize that the hack is not mine. It is the work of peetree21. I just made some changes.  :)
Audio Store:
https://vsystem.bg - Bulgarian language
https://vsystem.bg/en - English

ors_86

  • Beginner
  • *
  • Posts: 6
Re: [SOLVED] ajax registration
« Reply #31 on: April 27, 2010, 16:21:44 pm »
its works fine, the problem is that when user decides to edit again his shipping address, his email and username are not appear!
only that, otherwhise is perfect!

Ventsi Genchev

  • Jr. Member
  • **
  • Posts: 308
    • Audio Store
Re: [SOLVED] ajax registration
« Reply #32 on: April 27, 2010, 23:55:27 pm »
Which version do you use? From the first post?
Audio Store:
https://vsystem.bg - Bulgarian language
https://vsystem.bg/en - English

sev

  • Beginner
  • *
  • Posts: 7
Re: [SOLVED] ajax registration
« Reply #33 on: April 28, 2010, 21:14:15 pm »
Guys,

Sorry but it still does not/not work fully for me.  Here's how it does and does not work:

After I implemment the second version of the hack:

a). I go to the store, without logging in, put stuff in the cart and go to checkout.  I say I am a first time customer and need to register.  I get the registration form and the hack works here like a charm.

b). If instead I click "Register" in the VM login module, I get the same registration form, but no ajax validation - the hack does not work here.

Does anyone else have the same situation?  :(

Thanks.

tenguka

  • Beginner
  • *
  • Posts: 7
Re: [SOLVED] ajax registration
« Reply #34 on: May 04, 2010, 22:43:27 pm »
Hi guys,

Thanks for the awesome hack. This should definitely be part of virtuemart. I am having the same issue as sev. It works in the checkout process when you register. But if I do a 'register now' to here /index.php?option=com_virtuemart&page=shop.registration I get a javascript error as so:

Code: [Select]
$ is not defined
This usually means jquery isn't being found so I load jquery from my template and now get this error:

Code: [Select]
$("email_ticker").setHTML is not a function
Any help on this would be very much appreciated.

Cheers!

sev

  • Beginner
  • *
  • Posts: 7
Re: [Really - SOLVED?] ajax registration
« Reply #35 on: May 27, 2010, 21:01:21 pm »
Well, after some digging in Joomla code by a friend he came up with a solution to this.

In the file /administrator/components/com_virtuemart/html/shop.registration.php after this:

if( empty($auth['user_id']) ) {

add this:

vmCommonHTML::loadMooTools();

Works like a charm now.

tenguka

  • Beginner
  • *
  • Posts: 7
Re: [SOLVED] ajax registration
« Reply #36 on: May 28, 2010, 03:21:38 am »
Awesome..that fixed it and it works like a charm. Three cheers to the Ajax fix for registration. Make this part of core please :-)

mike420

  • Beginner
  • *
  • Posts: 23
Re: [SOLVED] ajax registration
« Reply #37 on: June 07, 2010, 09:59:39 am »
I have converted this hack to work with Virtuemart 1.0.15.

It seems to work ok!!

I have also added a "Confirm Email" box.


in administrator/components/com_virtuemart/checkout_register_form.php

Find:
Code: [Select]
if (!empty( $missing )) {
echo "<script type=\"text/javascript\">alert('".$VM_LANG->_CONTACT_FORM_NC."'); </script>\n";
}


Replace with:
Code: [Select]
?>


<script language="javascript" type="text/javascript">

<?php global $mosConfig_live_site?>

function getUsername(){
var form = document.adminForm;
var uname = form.username.value;

if( !$('username_ticker') )
$('username_div').innerHTML = $('username_div').innerHTML + "<div id=\"username_ticker\" class=\"<?php if ($page == 'shop.registration') { 
echo 'usernameajax'/*Need to change for your template*/
 
}
else { 
echo 'usernameajax2'/*Need to change for your template*/
 } ?>

\"></div>";

$('username_field').value = uname;

if( form.username.value.length < 3 ) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC url(./images/publish_x.png) no-repeat 6px 6px; border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 25px; float:left;">More than 2 characters!</span>';
} else {
$('username_ticker').innerHTML = "<img src=\"<?php echo $mosConfig_live_site?>/images/wait.gif\">&nbsp;Checking";
var url = 'index.php?option=com_virtuemart&task=chkuserinfo&format=raw&what=uname';
url = url + '&uname=' + form.username.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC url(./images/publish_x.png) no-repeat 6px 6px; border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 25px;float:left;">Already Used!</span>';
} else {
$('username_ticker').innerHTML = '<span style="background:#FFFFCC url(./images/tick.png) no-repeat 6px 6px; border:1px solid #390; color:green;font-weight:bold;padding:5px 5px 5px 25px;float:left;">Available.</span>';
}
}
}).request();

}
}


function getEmail(){

var form = document.adminForm;
var email = form.email.value;

if( !$('email_ticker') )
$('email_div').innerHTML = $('email_div').innerHTML + "<div id=\"email_ticker\" class=\"<?php if ($page == 'shop.registration') { 
echo 'useremailajax'/*Need to change for your template*/
 
}
else { 
echo 'useremailajax2'/*Need to change for your template*/
 } ?>

\"></div>";

$('email_field').value = email;

if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value))) {
$('email_ticker').setHTML('<span style="background:#FFFFCC url(./images/publish_x.png) no-repeat 6px 6px;border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 25px;float:left;">Not Valid!</span>');
} else {
$('email_ticker').setHTML("<img src=\"<?php echo $mosConfig_live_site?>/images/wait.gif\">&nbsp;Checking");
var url = 'index.php?option=com_virtuemart&task=chkuserinfo&format=raw&what=email';
url = url + '&email=' + form.email.value;

new Ajax(url, {
method: 'get',
onComplete: function(x){
if(x == 1) {
$('email_ticker').setHTML('<span style="background:#FFFFCC url(./images/publish_x.png) no-repeat 6px 6px; border:1px solid #CC0000;color:red;font-weight:bold;padding:5px 5px 5px 25px;float:left;">Already Registered.</span>');
} else {
$('email_ticker').setHTML('<span style="background:#FFFFCC url(./images/tick.png) no-repeat 6px 6px; border:1px solid #390; color:green;font-weight:bold;padding:5px 5px 5px 25px;float:left;">Not Registered.</span>');
}
}
}).request();

}
}

</script>
<?php



if (!empty( $missing )) {
echo "<script type=\"text/javascript\">alert('".$VM_LANG->_('CONTACT_FORM_NC',false)."'); </script>\n";
}

You will need to change the classes to suit your template /*Need to change for your template*/

The classes I used for my template.css were:
Code: [Select]
.usernameajax {position:absolute; top:505px; left:630px; z-index:6000;}
.usernameajax2 {position:absolute; top:635px; left:480px; z-index:6000;}

.useremailajax {position:absolute; top:535px; left:630px; z-index:6000;}
.useremailajax2 {position:absolute; top:665px; left:480px; z-index:6000;}


In the same file find:
Code: [Select]
$shopper_fields['email'] = $VM_LANG->_REGISTER_EMAIL;
Add directly below:
Code: [Select]
$shopper_fields['email2'] = $VM_LANG->_REGISTER_EMAIL2;

Find:
Code: [Select]
case 'agreed':
echo '<input type="checkbox" id="agreed_field" name="agreed" value="1" class="inputbox" />';
break;

Add directly below:
Code: [Select]
case 'email':
echo '<input type="text" id="'.$fieldname.'_field" name="'.$fieldname.'" size="30" onchange="getEmail();" value="'. ($db->sf($fieldname, true, false)?$db->sf($fieldname, true, false):'') .'" class="inputbox" />'."\n";
break;

case 'email2':
echo '<input type="text" id="'.$fieldname.'_field" name="'.$fieldname.'" size="30" class="inputbox" />'."\n";
break;

case 'username':
echo '<input type="text" id="'.$fieldname.'_field" name="'.$fieldname.'" size="30" onchange="getUsername();" value="'. ($db->sf($fieldname, true, false)?$db->sf($fieldname, true, false):'') .'" class="inputbox" />'."\n";
break;


in file administrator/components/com_virtuemart/htmlTools.class.php

Find:
Code: [Select]
if( in_array( 'email', $required_fields)) {

echo '
if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value))) {
alert( \''. html_entity_decode( $VM_LANG->_REGWARN_MAIL ).'\');
return false;
}';

}


Add after:
Code: [Select]
if( in_array( 'email2', $required_fields)) {

echo '
if (form.email2.value == "") {
alert( "'.html_entity_decode( $VM_LANG->_REGWARN_MAIL2).'" );
return false;
} else if ((form.email.value != "") && (form.email.value != form.email2.value)){
alert( "'. html_entity_decode( $VM_LANG->_REGWARN_MAIL3).'" );
return false;
}';

}


in file administrator/components/com_virtuemart/languages/english.php

Find:
Code: [Select]
var $_REGISTER_EMAIL = 'Email';
Add after:
Code: [Select]
var $_REGISTER_EMAIL2 = 'Confirm E-mail';
find:
Code: [Select]
var $_REGWARN_MAIL = 'Please enter a valid e-mail address!';
Add after:
Code: [Select]
var $_REGWARN_MAIL2 = 'Please confirm your e-mail!';
var $_REGWARN_MAIL3 = 'E-mail confirmation does not match, please try again!';


in file components/com_virtuemart/virtuemart.php

Find:
Code: [Select]
include( $mosConfig_absolute_path.'/administrator/components/'.$option.'/compat.joomla1.5.php');
Add after:
Code: [Select]
$task = mosGetParam($_REQUEST, 'task' );

if($task=="chkuserinfo"){
global $database;
$email = mosGetParam($_REQUEST, 'email' );
$uname = mosGetParam($_REQUEST, 'uname' );

$what = mosGetParam($_REQUEST, 'what' );

$usercount = 0;
$emailcount = 0;


if($what == "uname"){

$database->setQuery("SELECT COUNT(*) FROM #__users WHERE username='$uname'");
$usercount = $database->loadResult();
if($usercount)
echo "1";
else
echo "0";

} else if ($what == "email") {
$database->setQuery("SELECT COUNT(*) FROM #__users WHERE email='$email'");
$emailcount = $database->loadResult();

if($emailcount)
echo "1";
else
echo "0";

}

die();
}


I think that's all!!!!

rok

  • Beginner
  • *
  • Posts: 3
Re: [SOLVED] ajax registration
« Reply #38 on: June 16, 2010, 19:45:39 pm »
I'm having problems, because my website has ja-mesolite virtuemart theme. The problem is that the ajax registration works only when user tries to check-out items (without being logged in) and it doesn't work when user tries to register through virtuemart login module on the left.

Also am having same issues as people before me with registration button to dissapear on ajax registration webpage (those hacks sadly don't work for me)...

Thank you for your help...

realcyrus

  • Beginner
  • *
  • Posts: 1
Re: [SOLVED] ajax registration
« Reply #39 on: June 17, 2010, 16:59:11 pm »
I noticed a problem with this hack;
Assume that a user is already registered and tries to edit his user data;
If he enters another username or email, and then again enters his current username or email, the form will say 'username / email already in use';
So I modified the code in components/com_virtuemart/virtuemart.php to check if it is the active username or email.

Code: [Select]
$tasked = JRequest::getVar( 'tasked' );

if($tasked=="chkuserinfo"){
$database = & JFactory::getDBO();
$actuser = & JFactory::getUser();
$actusername = $actuser->get('username');
$actemail = $actuser->get('email');
$email = JRequest::getVar( 'email' );
$uname = JRequest::getVar( 'uname' );

$what = JRequest::getVar( 'what' );

$usercount = 0;
$emailcount = 0;

if($what == "uname"){
if (strcasecmp($uname, $actusername) == 0){
echo 0;
} else {
$database->setQuery("SELECT COUNT(*) FROM #__users WHERE username='$uname'");
$usercount = $database->loadResult();
if($usercount)
echo "1";
else
echo "0";
}

} else if ($what == "email") {
if (strcasecmp($email, $actemail) == 0){
echo 0;
} else {
$database->setQuery("SELECT COUNT(*) FROM #__users WHERE email='$email'");
$emailcount = $database->loadResult();

if($emailcount)
echo "1";
else
echo "0";
}
}

die();
}



_fD_

  • Jr. Member
  • **
  • Posts: 118
    • Printdesign :: Joomla! CMS Webdesign :: Apple Computer Support
Re: [SOLVED] ajax registration
« Reply #40 on: August 27, 2010, 11:22:16 am »
Hello Guys

Great hack. So far i see, it does completly the job.

Many thanks.

Urs

realayumi

  • Beginner
  • *
  • Posts: 4
Re: [SOLVED] ajax registration
« Reply #41 on: September 14, 2010, 11:20:19 am »
But if we forget to input 1 required (*) field, after we click send, all the data we already typed become blank? And user will type it again?

alex2010

  • Beginner
  • *
  • Posts: 7
Re: [SOLVED] ajax registration
« Reply #42 on: September 15, 2010, 08:48:03 am »
hello
i asked mike420 or other friends to correct directory of files in post 37
fo example i cant find the code you put from "htmlTools.class.php"

i use v-m 1.1.5  and joomla 1.5.20

bobysolo

  • Beginner
  • *
  • Posts: 47
  • Kiss my shiny metal ass!
    • Videosorveglianza
Re: [SOLVED] ajax registration
« Reply #43 on: September 27, 2010, 23:42:28 pm »
its works fine, the problem is that when user decides to edit again his shipping address, his email and username are not appear!
only that, otherwhise is perfect!

I have the same problem - otherwise it works like a charm. For now I just disabled those fields in the account maintenance page.

Joomla 1.5.20 and VM 1.1.4.

mike420

  • Beginner
  • *
  • Posts: 23
Re: [SOLVED] ajax registration
« Reply #44 on: September 28, 2010, 02:03:30 am »
hello
i asked mike420 or other friends to correct directory of files in post 37
fo example i cant find the code you put from "htmlTools.class.php"

i use v-m 1.1.5  and joomla 1.5.20


As stated in the first line of my post.. "I have converted this hack to work with Virtuemart 1.0.15."

So I'm not sure what is wrong with your version!!