News:

Looking for documentation? Take a look on our wiki

Main Menu

Display TOS checkbox on last step (and bug with double message)

Started by BlueOwl, August 26, 2013, 10:01:07 AM

Previous topic - Next topic

BlueOwl

Hi!

Virtuemart v 2.0.22b, Joomla 2.5.14

How can I display the checkbox only on the last step of the checkout process? I have already made an override, that is not displayed on first step. But after the user has entered his adress data, he sees the cart again with a message that he must accept TOS, and this message is shown double times (the double message came after update to 22b). On this step he should be forwarded to select payment, not the TOS.

I want the checkbox and the request for the checkbox shown only on last step. What do I have to modify on default.php of cart view?

We are using no customer registration on our virtuemart shop.

Our default.php of cart in override looks now like this:

<?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')) {
//show TOS only on last step
if (!empty($this->cart->BT)){
if (!class_exists ('VmHtml')) {
require(JPATH_VM_ADMINISTRATOR DS 'helpers' DS 'html.php');
}
echo VmHtml::checkbox ('tosAccepted'$this->cart->tosAccepted10'class="terms-of-service"');

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

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

<label for="tosAccepted">
<a href="<?php JRoute::('index.php?option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=1'FALSE?>" 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>
</label>

<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>';
}
}
echo $this->checkout_link_html;
?>

</div>


The code which is responsible for checking if tos checkbox is checked is in cart.php and I think there is a bug with the double message.

In com_virtuemart/helpers/cart.php on line 810 ff

if (empty($this->tosAccepted)) {

$userFieldsModel = VmModel::getModel('Userfields');

//$required = $userFieldsModel->getIfRequired('agreed');
$agreed = $userFieldsModel->getUserfield('agreed','name');
vmdebug('my new getUserfieldbyName',$agreed->default,$agreed->required);
if(!empty($agreed->required) and empty($agreed->default) and !empty($this->BT)){
$redirectMsg = null;// JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');

vmInfo('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS','COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');
return $this->redirecter('index.php?option=com_virtuemart&view=cart' , $redirectMsg);
} else if($agreed->default){
$this->tosAccepted = $agreed->default;
}
}


The double message is clearly a bug, why is this two times in this line?

vmInfo('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS','COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS');

I tried to modify the if statement so that it would be looking for the tos accepted after shipping and payment is selected, but I was not very lucky with it. Any help would be great

BlueOwl

Hi there!

I am still wondering, is it possible to make the accepting of the TOS as a last step for the checkout process?

Thank you very much!

Zimuqürazia

@BlueOwl: I have the same problem. I also tried different things with the code, but the error messages are both gone or they are both there. Let me know if you found a fix.

BlueOwl

The problem with two error messages is gone now in version 26d.

But there is still the problem, that virtuemart is forcing user to accept tos too early. Now on my page, if you enter your adress, you come back to the cart and the message "please accept TOS" displays. It should be displayed only, if user has pressed "buy now" and not checked the tos...  :(

This seems to be default behavior in Virtuemart?

I set up a fresh install with joomla 2.5.17 and Virtuemart 26d. It is the same. On checkout user enters adress, he is taken back to the cart with the message "Please accept the terms of service to confirm". Even if he has not selected a payment method.

It would be very nice if there is a way to make it work, so that the message is displayed only if user wants to buy (final action) and has not checked the box