VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: dimi2013 on January 05, 2015, 13:14:11 PM

Title: VM 3.x registration form order change [Solved]
Post by: dimi2013 on January 05, 2015, 13:14:11 PM
Joomla 3.3.6
VM 3.0.2
PHP  5.5.20
PHP Built On   Linux info 3.0 #1337 SMP
Web Server   Apache


Hi All,
I'm not really sure if this kind of post is appropriate, I'm hoping it is, but if it isn't, I'll be more than happy to delete it. With VM 2.x I was able to modify the registration form so that the captcha and submit buttons were on the bottom so that users would know to fill out the form first and then proceed to the captcha, etc. See attachment photo.

With VM 3.x, while I can rearrange everything to make it look the same w/out generating any errors, the captcha never validates and I keep getting an error saying Captcha solution is incorrect, despite it being correct--It seems it's not validating. When I put the form back to its original state, it works fine. I'm not a programmer so I'm not really sure what's going on. If anyone would care to help, I'd deeply appreciate it. Thanks.



Code of modified form




<?php
/**
 *
 * Enter address data for the cart, when anonymous users checkout
 *
 * @package    VirtueMart
 * @subpackage User
 * @author Oscar van Eijk, Max Milbers
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * 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.
 * @version $Id: edit_address.php 8565 2014-11-12 18:26:14Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');

// Implement Joomla's form validation
JHtml::('behavior.formvalidation');
JHtml::stylesheet ('vmpanels.css'JURI::root () . 'components/com_virtuemart/assets/css/');

?>

<h1><?php echo $this->page_title ?></h1>
<?php
if (!class_exists('VirtueMartCart')) require(VMPATH_SITE DS 'helpers' DS 'cart.php');
$this->cart VirtueMartCart::getCart();
$url 0;
if (
$this->cart->_fromCart or $this->cart->getInCheckOut()) {
$rview 'cart';
}
else {
$rview 'user';
}

$task '';
if (
$this->cart->getInCheckOut()){
//$task = '&task=checkout';
}
$url JRoute::('index.php?option=com_virtuemart&view='.$rview.$task$this->useXHTML$this->useSSL);

echo 
shopFunctionsF::getLoginForm (TRUEFALSE$url);

$this->vmValidator();
?>





   
   




<?php // captcha addition
if(VmConfig::get ('reg_captcha')){
JHTML::_('behavior.framework');
JPluginHelper::importPlugin('captcha');
$captcha_visible vRequest::getVar('captcha');
$dispatcher JDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1');
$hide_captcha = (VmConfig::get ('oncheckout_only_registered') or $captcha_visible) ? '' 'style="display: none;"';
?>



       
       
   
       
<?php }
// end of captcha addition

if (!class_exists ('VirtueMartCart')) {
require(VMPATH_SITE DS 'helpers' DS 'cart.php');
}

if (count ($this->userFields['functions']) > 0) {
echo '<script language="javascript">' "\n";
echo join ("\n"$this->userFields['functions']);
echo '</script>' "\n";
}

echo $this->loadTemplate ('userfields');

if ($this->userDetails->JUser->get ('id')) {
echo $this->loadTemplate ('addshipto');
?>

   
  <!--this is the title add-edit address--> 
  <h2><?php
if ($this->address_type == 'BT') {
echo vmText::('Enter Captcha and click Register and checkout');
}
else {
echo vmText::('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
}
?>

</h2>
    <!--end of add-edit address-->
   
         <!--this is the captcha-->
        <fieldset id="recaptcha_wrapper" <?php echo $hide_captcha ?>>
<?php if(!VmConfig::get ('oncheckout_only_registered')) { ?>
<span class="userfields_info"><?php echo vmText::('COM_VIRTUEMART_USER_FORM_CAPTCHA'); ?></span>


<?php ?>
<div id="dynamic_recaptcha_1"></div>
</fieldset>
        <!--end of captcha-->
   
     <!--this is the register-checkout button only-->
   
    <form method="post" id="userForm" name="userForm" class="form-validate" action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=user',$this->useXHTML,$this->useSSL?>" >
<fieldset>


<!--<form method="post" id="userForm" name="userForm" action="<?php echo JRoute::('index.php'); ?>" class="form-validate">-->
<div class="control-buttons">
<?php


if ($this->cart->getInCheckOut() || $this->address_type == 'ST') {
$buttonclass 'default';
}
else {
$buttonclass 'button vm-button-correct';
}


if (VmConfig::get ('oncheckout_show_register'1) && $this->userDetails->JUser->id == && !VmConfig::get ('oncheckout_only_registered'0) && $this->address_type == 'BT' and $rview == 'cart') {
echo '<div id="reg_text">'.vmText::sprintf ('COM_VIRTUEMART_ONCHECKOUT_DEFAULT_TEXT_REGISTER'vmText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'), vmText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST')).'</div>'; }
else {
//echo vmText::_('COM_VIRTUEMART_REGISTER_ACCOUNT');
}
if (VmConfig::get ('oncheckout_show_register'1) && $this->userDetails->JUser->id == && $this->address_type == 'BT' and $rview == 'cart') {
?>

<button name="register" class="<?php echo $buttonclass ?>" type="submit" onclick="javascript:return myValidator(userForm,true);"
title="<?php echo vmText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'); ?>"><?php echo vmText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'); ?></button>
<?php if (!VmConfig::get ('oncheckout_only_registered'0)) { ?>
<button name="save" class="<?php echo $buttonclass ?>" title="<?php echo vmText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST'); ?>" type="submit"
onclick="javascript:return myValidator(userForm, false);"><?php echo vmText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST'); ?></button>
<?php ?>
<button class="default" type="reset"
onclick="window.location.href='<?php echo JRoute::('index.php?option=com_virtuemart&view=' $rview.'&task=cancel'); ?>'"><?php echo vmText::('COM_VIRTUEMART_CANCEL'); ?></button>
<?php
}
else {
?>

<button class="<?php echo $buttonclass ?>" type="submit"
onclick="javascript:return myValidator(userForm,true);"><?php echo vmText::('COM_VIRTUEMART_SAVE'); ?></button>
<button class="default" type="reset"
onclick="window.location.href='<?php echo JRoute::('index.php?option=com_virtuemart&view=' $rview.'&task=cancel'); ?>'"><?php echo vmText::('COM_VIRTUEMART_CANCEL'); ?></button>
<?php ?>
</div>
    <!--end of register-checkout button only- -->
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="view" value="user"/>
<input type="hidden" name="controller" value="user"/>
<input type="hidden" name="task" value="saveUser"/>
<input type="hidden" name="layout" value="<?php echo $this->getLayout (); ?>"/>
<input type="hidden" name="address_type" value="<?php echo $this->address_type?>"/>
<?php if (!empty($this->virtuemart_userinfo_id)) {
echo '<input type="hidden" name="shipto_virtuemart_userinfo_id" value="' . (int)$this->virtuemart_userinfo_id '" />';
}
echo JHtml::('form.token');
?>


</fieldset>
</form>




[attachment cleanup by admin]
Title: Re: New VM registration form change
Post by: GJC Web Design on January 05, 2015, 13:49:09 PM
your captcha isn't inside the form tags so it isn't submitted
Title: Re: New VM registration form change
Post by: dimi2013 on January 05, 2015, 17:08:28 PM
Thanks, GJC, for pointing me in the right direction. If anyone else wants the form to appear above the captcha, works with  EasyCalcCheck PLUS - ECC+ too, just copy and paste the code below in your overrides. Anyway, as I mentioned previously, I'm not a programmer but I got this to work.

Take care.





<?php
/**
 *
 * Enter address data for the cart, when anonymous users checkout
 *
 * @package    VirtueMart
 * @subpackage User
 * @author Oscar van Eijk, Max Milbers
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * 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.
 * @version $Id: edit_address.php 8565 2014-11-12 18:26:14Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');

// Implement Joomla's form validation
JHtml::('behavior.formvalidation');
JHtml::stylesheet ('vmpanels.css'JURI::root () . 'components/com_virtuemart/assets/css/');

?>

<h1><?php echo $this->page_title ?></h1>
<?php
if (!class_exists('VirtueMartCart')) require(VMPATH_SITE DS 'helpers' DS 'cart.php');
$this->cart VirtueMartCart::getCart();
$url 0;
if (
$this->cart->_fromCart or $this->cart->getInCheckOut()) {
$rview 'cart';
}
else {
$rview 'user';
}

$task '';
if (
$this->cart->getInCheckOut()){
//$task = '&task=checkout';
}
$url JRoute::('index.php?option=com_virtuemart&view='.$rview.$task$this->useXHTML$this->useSSL);

echo 
shopFunctionsF::getLoginForm (TRUEFALSE$url);

$this->vmValidator();
?>




<!-- buttons-->
<form method="post" id="userForm" name="userForm" class="form-validate" action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=user',$this->useXHTML,$this->useSSL?>" >
<fieldset>   





     
       <!--moves register cancel buttons to the bottom-->
   
<?php // captcha addition
if(VmConfig::get ('reg_captcha')){
JHTML::_('behavior.framework');
JPluginHelper::importPlugin('captcha');
$captcha_visible vRequest::getVar('captcha');
$dispatcher JDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1');
$hide_captcha = (VmConfig::get ('oncheckout_only_registered') or $captcha_visible) ? '' 'style="display: none;"';
?>

       
       
       
       
       
       
<?php }
// end of captcha addition 

if (!class_exists ('VirtueMartCart')) {
require(VMPATH_SITE DS 'helpers' DS 'cart.php');
}

if (count ($this->userFields['functions']) > 0) {
echo '<script language="javascript">' "\n";
echo join ("\n"$this->userFields['functions']);
echo '</script>' "\n";
}

echo $this->loadTemplate ('userfields');

if ($this->userDetails->JUser->get ('id')) {
echo $this->loadTemplate ('addshipto');
?>

   
     <!--end of register cancel buttons to the bottom-->
     
     
     
     
<h2><?php
if ($this->address_type == 'BT') {
echo vmText::('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
}
else {
echo vmText::('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
}
?>

</h2>

<!--<form method="post" id="userForm" name="userForm" action="<?php echo JRoute::('index.php'); ?>" class="form-validate">-->
   
   
   
<!-- start buttons register cancel-->


<!--start captcha-->
<fieldset id="recaptcha_wrapper" <?php echo $hide_captcha ?>>
<?php if(!VmConfig::get ('oncheckout_only_registered')) { ?>
<span class="userfields_info"><?php echo vmText::('COM_VIRTUEMART_USER_FORM_CAPTCHA'); ?></span>
<?php ?>
<div id="dynamic_recaptcha_1"></div>
</fieldset>
        <!--end captcha-->

<div class="control-buttons">
<?php


if ($this->cart->getInCheckOut() || $this->address_type == 'ST') {
$buttonclass 'default';
}
else {
$buttonclass 'button vm-button-correct';
}


if (VmConfig::get ('oncheckout_show_register'1) && $this->userDetails->JUser->id == && !VmConfig::get ('oncheckout_only_registered'0) && $this->address_type == 'BT' and $rview == 'cart') {
echo '<div id="reg_text">'.vmText::sprintf ('COM_VIRTUEMART_ONCHECKOUT_DEFAULT_TEXT_REGISTER'vmText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'), vmText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST')).'</div>'; }
else {
//echo vmText::_('COM_VIRTUEMART_REGISTER_ACCOUNT');
}
if (VmConfig::get ('oncheckout_show_register'1) && $this->userDetails->JUser->id == && $this->address_type == 'BT' and $rview == 'cart') {
?>

<button name="register" class="<?php echo $buttonclass ?>" type="submit" onclick="javascript:return myValidator(userForm,true);"
title="<?php echo vmText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'); ?>"><?php echo vmText::('COM_VIRTUEMART_REGISTER_AND_CHECKOUT'); ?></button>
<?php if (!VmConfig::get ('oncheckout_only_registered'0)) { ?>
<button name="save" class="<?php echo $buttonclass ?>" title="<?php echo vmText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST'); ?>" type="submit"
onclick="javascript:return myValidator(userForm, false);"><?php echo vmText::('COM_VIRTUEMART_CHECKOUT_AS_GUEST'); ?></button>
<?php ?>
<button class="default" type="reset"
onclick="window.location.href='<?php echo JRoute::('index.php?option=com_virtuemart&view=' $rview.'&task=cancel'); ?>'"><?php echo vmText::('COM_VIRTUEMART_CANCEL'); ?></button>
<?php
}
else {
?>

<button class="<?php echo $buttonclass ?>" type="submit"
onclick="javascript:return myValidator(userForm,true);"><?php echo vmText::('COM_VIRTUEMART_SAVE'); ?></button>
<button class="default" type="reset"
onclick="window.location.href='<?php echo JRoute::('index.php?option=com_virtuemart&view=' $rview.'&task=cancel'); ?>'"><?php echo vmText::('COM_VIRTUEMART_CANCEL'); ?></button>
                   
                   
                   

                   
                   
<?php ?>
</div>
    <!--end of buttons-->


<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="view" value="user"/>
<input type="hidden" name="controller" value="user"/>
<input type="hidden" name="task" value="saveUser"/>
<input type="hidden" name="layout" value="<?php echo $this->getLayout (); ?>"/>
<input type="hidden" name="address_type" value="<?php echo $this->address_type?>"/>
   
   

   
   
<?php if (!empty($this->virtuemart_userinfo_id)) {
echo '<input type="hidden" name="shipto_virtuemart_userinfo_id" value="' . (int)$this->virtuemart_userinfo_id '" />';
}
echo JHtml::('form.token');
?>


</fieldset>
</form>



Title: Re: VM 3.x registration form order change [Solved]
Post by: fastpat27 on June 24, 2015, 22:38:33 PM
Hi Dimi
I'm not so much working on the captcha but I would like to move or have second Register and Cancel buttons on the bottom of the page too. I did this before in VM2 but can't seem to find the correct file to edit. Which file do I need to work on to do this?

Still learning how to do overrides too so it's something I would like to have as an override when VM updates again.

Thanks
FP

VM3.0.9 Joomla 3.4.1
Title: Re: VM 3.x registration form order change [Solved]
Post by: dimi2013 on June 25, 2015, 11:47:07 AM
fastpat27,
Check out code I submitted and look for the comments. I've commented where all the parts are so you'll have to copy/paste. Just experiment and you'll get it.
Title: Re: VM 3.x registration form order change [Solved]
Post by: fastpat27 on June 25, 2015, 12:50:54 PM
Hi dimi
Sorry, reading this on a mobile at the moment so it's hard to read the code. I'm just not sure which file I need to edit with your code, where do I find the file name and location? If it's in the code I'll read again later on the bigger screen.

Thanks for the help
FP
Title: Re: VM 3.x registration form order change [Solved]
Post by: dimi2013 on June 25, 2015, 14:35:10 PM
/Your_Root_Folder/components/com_virtuemart/views/user/tmpl

file is edit_address.php
Title: Re: VM 3.x registration form order change [Solved]
Post by: fastpat27 on June 25, 2015, 14:46:04 PM
Brilliant, I'll get stuck in later

Thanks
Title: Re: VM 3.x registration form order change [Solved]
Post by: fastpat27 on June 25, 2015, 22:09:01 PM
Hi Dimi
I tried editing that file but made no difference, then deleted all the code and replaced with yours, still made no difference. I must be editing the wrong file?? To confirm this is the same page if you clicked on VM Account Maintenance??

FP
Title: Re: VM 3.x registration form order change [Solved]
Post by: fastpat27 on June 25, 2015, 22:11:47 PM
Ah, sorted, it was the same folder

/Your_Root_Folder/components/com_virtuemart/views/user/tmpl

but "edit_shopper.php" file

Now to learn how to create an override  :-[
Title: Re: VM 3.x registration form order change [Solved]
Post by: dimi2013 on June 26, 2015, 06:05:38 AM
That's really interesting, thanks for posting. Before I posted the location of the file, I looked at my overrides and it was indeed the file I mentioned. Maybe, they've changed something somewhere. However, I'm running the latest version of VM. Oh well.
As for overrides, it's quite easy. Do a Google search and you'll find something. The link below is to VM's documentation and should get you started.

http://docs.virtuemart.net/tutorials/templating-layouts/101-how-to-overwrite-plugins.html (http://docs.virtuemart.net/tutorials/templating-layouts/101-how-to-overwrite-plugins.html)
Title: Re: VM 3.x registration form order change [Solved]
Post by: fastpat27 on June 26, 2015, 13:23:51 PM
Thanks Dimi, I think there are a couple of different pages, there is one with the Register button and one with Checkout and Register, maybe that is the difference.

Bit of reading to do now and a bit of experimenting :), thanks for the pointers, great stuff

Regards
FP
Title: Re: VM 3.x registration form order change [Solved]
Post by: ch1vph on July 22, 2017, 17:41:02 PM
<?php
/**
 *
 * Modify user form view, User info
 *
 * @package VirtueMart
 * @subpackage User
 * @author Oscar van Eijk
 * @link ${PHING.VM.MAINTAINERURL}
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * 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.
 * @version $Id: edit_shopper.php 9413 2017-01-04 17:20:58Z Milbo $
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

if(!
$this->userDetails->user_is_vendor){ ?>

<div class="buttonBar-right">
<button class="button" type="submit" onclick="javascript:return myValidator(userForm, true);" ><?php echo $this->button_lbl ?></button>
&nbsp;
<button class="button" type="reset" onclick="window.location.href='<?php echo JRoute::_('index.php?option=com_virtuemart&view=user'FALSE); ?>'" ><?php echo vmText::_('COM_VIRTUEMART_CANCEL'); ?></button>
</div>

<?php }
if( 
$this->userDetails->virtuemart_user_id!=0) {
    echo 
$this->loadTemplate('vmshopper');
}

echo 
$this->loadTemplate('address_userfields');

if (
$this->userDetails->JUser->get('id') ) {
  echo 
$this->loadTemplate('address_addshipto');
}

if(!empty(
$this->virtuemart_userinfo_id)){
echo '<input type="hidden" name="virtuemart_userinfo_id" value="'.(int)$this->virtuemart_userinfo_id.'" />';
}
?>

<input type="hidden" name="task" value="saveUser" />
<input type="hidden" name="address_type" value="<?php echo $this->address_type?>"/>

<div class="buttonBar-right">
<button class="button" type="submit" onclick="javascript:return myValidator(userForm, true);" ><?php echo $this->button_lbl ?></button>
&nbsp;
<button class="button" type="reset" onclick="window.location.href='<?php echo JRoute::_('index.php?option=com_virtuemart&view=user'FALSE); ?>'" ><?php echo vmText::_('COM_VIRTUEMART_CANCEL'); ?></button>
</div>