News:

Support the VirtueMart project and become a member

Main Menu

Disable Billing and Shipping for non registered users

Started by redback, October 16, 2013, 05:51:37 AM

Previous topic - Next topic

redback

Hello,

Running Joomla 2.5.14 and VM 2.0.24

I am using VM for Account Customers only. Which means the shop admin creates the VM customer account and assigns the shopper group.

Therefore I would like to disable the Billing and Shipping Information on the checkout page so that non registered customers cannot attempt to order or register.

I would also like to have the Billing and Shipping Information displayed for the registered customer once logged in.

Is this possible and how do I do this?

Thanks

jenkinhill

Use a template override with hidden or removed billing/delivery divs so the shopper cannot add those details themselves. eg http://forum.virtuemart.net/index.php?topic=119571.msg406937#msg406937
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

redback

Thanks for your reply that worked perfectly.

However I have now discovered that if you do not login and add a product to the cart and select show cart, then go straight to Check Out Now you are taken to a page with the following;
Your account details
Add/Edit billing address information

I am trying to achieve the following;
Customer will have an account setup with username and password by the store admin.
Customer cannot purchase without logging in.
Customer cannot register or enter billing details.

http://www.watershednt.com.au/new13/index.php/shop

Your assistance is greatly appreciated.

mowlman

Hello Reback,

For Customer cannot purchase without logging in.      Try to check: Only registered users can checkout   within VM Configuration - Checkout Tab.

I believe this may help.

redback


AH

Redback

If you want to prevent users from seeing cart details including adding anything to the addresses/registering  then you will have to do an override to the cart page.

Programmatically I prefer a solution that checks for the required state and does not get the data if the state is not met, rather than messing with hidden divs. There is no point in getting the data and the hidden div soluition requires more effort.

In either case you need to know what check to perform!

Components\com_virtuemart\views\cart\tmpl\default.php

Check to see if there is a userid (logged on) if not display a message - else display the cart stuff.

The code below should work, if not, adjust the if() statement,



<?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');
if(
VmConfig::get('usefancy',0)){
vmJsApi::js'fancybox/jquery.fancybox-1.3.4.pack');
vmJsApi::css('jquery.fancybox-1.3.4');
$box "
//<![CDATA[
jQuery(document).ready(function($) {
$('div#full-tos').hide();
var con = $('div#full-tos').html();
$('a#terms-of-service').click(function(event) {
event.preventDefault();
$.fancybox ({ div: '#full-tos', content: con });
});
});

//]]>
"
;
} else {
vmJsApi::js ('facebox');
vmJsApi::css ('facebox');
$box "
//<![CDATA[
jQuery(document).ready(function($) {
$('div#full-tos').hide();
$('a#terms-of-service').click(function(event) {
event.preventDefault();
$.facebox( { div: '#full-tos' }, 'my-groovy-style');
});
});

//]]>
"
;
}

JHtml::('behavior.formvalidation');
$document JFactory::getDocument ();
$document->addScriptDeclaration ($box);
$document->addScriptDeclaration ("

//<![CDATA[
jQuery(document).ready(function($) {
if ( $('#STsameAsBTjs').is(':checked') ) {
$('#output-shipto-display').hide();
} else {
$('#output-shipto-display').show();
}
$('#STsameAsBTjs').click(function(event) {
if($(this).is(':checked')){
$('#STsameAsBT').val('1') ;
$('#output-shipto-display').hide();
} else {
$('#STsameAsBT').val('0') ;
$('#output-shipto-display').show();
}
});
});

//]]>

"
);
$document->addStyleDeclaration ('#facebox .content {display: block !important; height: 480px !important; overflow: auto; width: 560px !important; }');

?>


<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="width50 floatleft right">
<?php // Continue Shopping Button
if (!empty($this->continue_link_html)) {
echo $this->continue_link_html;
?>

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

<?php

// display this message if not logged in - else display the cart
if ( $user->id == ) {

    echo 
"You will need to have an accoutn with us if you wish to purchase  (you can make your own language variable here if required)";

} else {
        
    
?>
   
   
<?php echo shopFunctionsF::getLoginForm ($this->cartFALSE);

// 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 '';
}


// added in 2.0.8
?>

<div id="checkout-advertise-box">
<?php
if (!empty($this->checkoutAdvertise)) {
foreach ($this->checkoutAdvertise as $checkoutAdvertise) {
?>

<div class="checkout-advertise">
<?php echo $checkoutAdvertise?>
</div>
<?php
}
}
?>

</div>

<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_CART'); ?></span><br/>
<textarea class="customer-comment" name="customer_comment" cols="60" rows="1"><?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')) {
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>
<?php // Continue and Checkout Button END ?>
<input type='hidden' name='order_language' value='<?php echo $this->order_language?>'/>
<input type='hidden' id='STsameAsBT' name='STsameAsBT' value='<?php echo $this->cart->STsameAsBT?>'/>
<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>

<?php
}
?>

Regards
A

Joomla 4.4.5
php 8.1

redback

Hutson, thank you for your reply.

It does not show the cart details and leaves the message for non logged in users. However you also get the same message for logged in users who are unable to see the cart.

Cheers

AH

Redback

Doh! I posted the response late the other day and messed up the variable!

Below should function.

I have also adjusted slightly. 
If the customer is not logged in, it will show the login details for them - (slightly better than telling them to get an account especially when they are already customers)
If they have logged in or, do loging - the login details are removed as they are no longer required. This makes checkout look a bit cleaner.


Components\com_virtuemart\views\cart\tmpl\default.php

Check to see if there is a userid (logged on) if not display a message and login details - else display the cart stuff.


<?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');
if(
VmConfig::get('usefancy',0)){
vmJsApi::js'fancybox/jquery.fancybox-1.3.4.pack');
vmJsApi::css('jquery.fancybox-1.3.4');
$box "
//<![CDATA[
jQuery(document).ready(function($) {
$('div#full-tos').hide();
var con = $('div#full-tos').html();
$('a#terms-of-service').click(function(event) {
event.preventDefault();
$.fancybox ({ div: '#full-tos', content: con });
});
});

//]]>
"
;
} else {
vmJsApi::js ('facebox');
vmJsApi::css ('facebox');
$box "
//<![CDATA[
jQuery(document).ready(function($) {
$('div#full-tos').hide();
$('a#terms-of-service').click(function(event) {
event.preventDefault();
$.facebox( { div: '#full-tos' }, 'my-groovy-style');
});
});

//]]>
"
;
}

JHtml::('behavior.formvalidation');
$document JFactory::getDocument ();
$document->addScriptDeclaration ($box);
$document->addScriptDeclaration ("

//<![CDATA[
jQuery(document).ready(function($) {
if ( $('#STsameAsBTjs').is(':checked') ) {
$('#output-shipto-display').hide();
} else {
$('#output-shipto-display').show();
}
$('#STsameAsBTjs').click(function(event) {
if($(this).is(':checked')){
$('#STsameAsBT').val('1') ;
$('#output-shipto-display').hide();
} else {
$('#STsameAsBT').val('0') ;
$('#output-shipto-display').show();
}
});
});

//]]>

"
);
$document->addStyleDeclaration ('#facebox .content {display: block !important; height: 480px !important; overflow: auto; width: 560px !important; }');

?>


<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="width50 floatleft right">
<?php // Continue Shopping Button
if (!empty($this->continue_link_html)) {
echo $this->continue_link_html;
?>

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

<?php

// display this message if not logged in - else display the cart
if ( $this->cart->user->_id == ) {

    echo 
"You will need to have an account with us if you wish to purchase  (you can make your own language variable here if required)";

    
//show login details only when they have not logged in if logged in they will not show

    
echo shopFunctionsF::getLoginForm ($this->cartFALSE);

    
// show login details end
} else {
        
    
?>
   
   
<?php

// 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 '';
}


// added in 2.0.8
?>

<div id="checkout-advertise-box">
<?php
if (!empty($this->checkoutAdvertise)) {
foreach ($this->checkoutAdvertise as $checkoutAdvertise) {
?>

<div class="checkout-advertise">
<?php echo $checkoutAdvertise?>
</div>
<?php
}
}
?>

</div>

<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_CART'); ?></span><br/>
<textarea class="customer-comment" name="customer_comment" cols="60" rows="1"><?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')) {
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>
<?php // Continue and Checkout Button END ?>
<input type='hidden' name='order_language' value='<?php echo $this->order_language?>'/>
<input type='hidden' id='STsameAsBT' name='STsameAsBT' value='<?php echo $this->cart->STsameAsBT?>'/>
<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>

<?php
}
?>




Hope this works for you

Regards
A

Joomla 4.4.5
php 8.1

redback

Perfect!!! thanks very much.

I dont suppose you know how to resolve this issue for me?

http://forum.virtuemart.net/index.php?topic=119592.0

Thanks again!!