Terms and conditions - pressing cart link also ticks accepted tos checkbox

Started by propush, December 20, 2012, 14:10:23 PM

Previous topic - Next topic

propush

Hello,

I've been working on this for a long time now, and haven't manged to solve it.

On my site, in the cart, I chose that each time someone checks out he must accept TOS. So the checkbox appears, and the link to the lightbox with the full TOS appears as well.

The problem is, if Someone clicks the div containing the link, the accepted TOS checkbox is ticked! Div "terms-of-service" is wrapping the TOS link, a click on it checks the accepted tos checkbox. That means, that if someone tries to read the TOS - he also accepts it instantly, which is pretty bad for us.

I am using joomla 2.5.8
and vrituemart  2.0.8

I know this isn't the latest version. But I had to modify the views very heavily for my client. I do have them in the HTML folder in the template, but last time when I updated it made a huge mess.
I may have created the problem when editing the view. here is the modified view:

<?php
/**
*
* Layout for the shopping cart
*
* @package VirtueMart
* @subpackage Cart
* @author 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: cart.php 2551 2010-09-30 18:52:40Z milbo $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
JHTML::script('facebox.js''components/com_virtuemart/assets/js/'false);
JHTML::stylesheet('facebox.css''components/com_virtuemart/assets/css/'false);

JHtml::_('behavior.formvalidation');
$document JFactory::getDocument();
$document->addScriptDeclaration("
jQuery(document).ready(function($) {
$('div#full-tos').hide();
$('span.terms-of-service').click( function(){
//$.facebox({ span: '#full-tos' });
$.facebox( { div: '#full-tos' }, 'my-groovy-style');
});
});
"
);
$document->addStyleDeclaration('#facebox .content {display: block !important; height: 480px !important; overflow: auto; width: 560px !important; }');

//  vmdebug('car7t pricesUnformatted',$this->cart->pricesUnformatted);
//  vmdebug('cart pricesUnformatted',$this->cart->cartData );
?>


<div class="cart-view">
<div>
<div class="width50 floatleft">
<h1><?php echo JText::_('COM_VIRTUEMART_CART_TITLE'); ?></h1>
</div>
<?php if (VmConfig::get('oncheckout_show_steps'1) && $this->checkout_task==='confirm'){
vmdebug('checkout_task',$this->checkout_task);
echo '<div class="checkoutStep" id="checkoutStep4">'.JText::_('COM_VIRTUEMART_USER_FORM_CART_STEP4').'</div>';
?>


<div class="clear"></div>
</div>



<?php echo shopFunctionsF::getLoginForm($this->cart,false);
//echo $this->loadTemplate('login');


//
//
//// Continue and Checkout Button
/* The problem here is that we use a form for the quantity boxes and so we cant let the form start here,
 * because we would have then a form in a form.
 *
 * But we cant make an extra form here, because then pressing the above checkout button would not send the
 * user notices for exampel. The solution is to write a javascript which checks and unchecks both tos checkboxes simultan
 * The upper checkout button should than just fire the form below.
 *
<div class="checkout-button-top">

<?php // Terms Of Service Checkbox
if(!class_exists('VmHtml'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'html.php');
echo VmHtml::checkbox('tosAccepted',$this->cart->tosAccepted,1,0,'class="terms-of-service"');
$checked = '';
//echo '<input class="terms-of-service" type="checkbox" name="tosAccepted" value="1" ' . $this->cart->tosAccepted . '/>

echo '<span class="tos">'. JText::_('COM_VIRTUEMART_CART_TOS_READ_AND_ACCEPTED').'</span>';
?>


<?php // Checkout Button
echo $this->checkout_link_html;
$text JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
?>


</div>
<form method="post" id="checkoutForm" name="checkoutForm" action="<?php echo JRoute::_'index.php?option=com_virtuemart' ); ?>">

<input type='hidden' name='task' value='<?php echo $this->checkout_task?>'/>
<input type='hidden' name='option' value='com_virtuemart'/>
<input type='hidden' name='view' value='cart'/>
*/
// This displays the pricelist MUST be done with tables, because it is also used for the emails
echo $this->loadTemplate('pricelist');
if ($this->checkout_task) $taskRoute = '&task='.$this->checkout_task;
else $taskRoute ='';
?>

<form method="post" id="checkoutForm" name="checkoutForm" action="<?php echo JRoute::_'index.php?option=com_virtuemart&view=cart'.$taskRoute,$this->useXHTML,$this->useSSL ); ?>">

<?php // Leave A Comment Field ?>
<div class="customer-comment marginbottom15">
<span class="comment"><?php echo JText::_('COM_VIRTUEMART_COMMENT'); ?></span><br />
<textarea class="customer-comment" name="customer_comment" cols="50" rows="4"><?php echo $this->cart->customer_comment?></textarea>
</div>
<?php // Leave A Comment Field END ?>



<?php // Continue and Checkout Button ?>
<div class="checkout-button-top">

<?php // Terms Of Service Checkbox
if (!class_exists('VirtueMartModelUserfields')){
require(JPATH_VM_ADMINISTRATOR DS 'models' DS 'userfields.php');
}
$userFieldsModel VmModel::getModel('userfields');
if($userFieldsModel->getIfRequired('agreed')){
    ?>

    <label for ="tosAccepted">
    <?php
if(!class_exists('VmHtml'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'html.php');
echo VmHtml::checkbox('tosAccepted',$this->cart->tosAccepted,1,0,'class="terms-of-service"');

if(VmConfig::get('oncheckout_show_legal_info',1)){
?>

<div class="terms-of-service">
<span class="terms-of-service" rel="facebox"><span class="vmicon vm2-termsofservice-icon"></span><?php echo JText::_('COM_VIRTUEMART_CART_TOS_READ_AND_ACCEPTED'); ?><span class="vm2-modallink"></span></span>
<div id="full-tos">
<h2><?php echo JText::_('COM_VIRTUEMART_CART_TOS'); ?></h2>
<?php echo $this->cart->vendor->vendor_terms_of_service;?>

</div>
</div>
<?php
// VmConfig::get('oncheckout_show_legal_info',1)
//echo '<span class="tos">'. JText::_('COM_VIRTUEMART_CART_TOS_READ_AND_ACCEPTED').'</span>';
?>

    </label>
    <?php
}

echo $this->checkout_link_html;
$text JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
?>

</div>
<?php //vmdebug('my cart',$this->cart);// Continue and Checkout Button END ?>

<input type='hidden' name='task' value='<?php echo $this->checkout_task?>'/>
<input type='hidden' name='option' value='com_virtuemart'/>
<input type='hidden' name='view' value='cart'/>
</form>
</div>


Any and all help is much appreciated!

Thank you very much,
Avichay.

bytelord

Hello,

I tested with version 2.0.14 and is working fine.

Use the original one place it in a separate div

<div class="terms-of-service">

<a href="<?php JRoute::('index.php?option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=1'?>" class="terms-of-service" id="terms-of-service" rel="facebox"
   target="_blank">
<span class="vmicon vm2-termsofservice-icon"></span>
<?php echo JText::('COM_VIRTUEMART_CART_TOS_READ_AND_ACCEPTED'); ?>
</a>

<div id="full-tos">
<h2><?php echo JText::('COM_VIRTUEMART_CART_TOS'); ?></h2>
<?php echo $this->cart->vendor->vendor_terms_of_service?>
</div>

</div>
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

propush

Thank you for your help.

This does fix the problem - but creates a new one.

The link now opens a new frame - in which the home page, not tos, is displayed.

I actually managed to achieve this in my previous attempts.

Glad if you could keep assisting, and thanks in advance!

bytelord

Hi,

I don't know ... i not using 2.0.8 and i am not sure what is happened there ... check your overrides please
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!