News:

Support the VirtueMart project and become a member

Main Menu

Hide add to cart for non registered users

Started by m.davide82, May 22, 2012, 14:34:55 PM

Previous topic - Next topic

m.davide82

Hello,

anyone as an idea on how to see the "add to cart" only for registered users?


Thanks in advance,

David

Leonard Michael

I'd like to know this too!

Respectfully,
LMW1

stuart.prevos

#2
I guess you could write a code like this in ->views->productdetails->tmpl->default_addtocart.php
=========================================================
<?php
if(!JFactory::getUser()->guest) //********************this will test if the user is logged and if they are do the following*****************//
{
?>
<div class="addtocart-bar">

<?php // Display the quantity box


    $stockhandle = VmConfig::get('stockhandle', 'none');
    if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock - $this->product->product_ordered) < 1) {
?>
      <a href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id='.$this->product->virtuemart_product_id); ?>"><?php echo JText::_('COM_VIRTUEMART_CART_NOTIFY') ?></a>

<?php } else { ?>
                  <!-- <label for="quantity<?php echo $this->product->virtuemart_product_id; ?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
       <span class="quantity-box">
      <input type="text" class="quantity-input js-recalculate" name="quantity[]" value="<?php if (isset($this->product->min_order_level) && (int) $this->product->min_order_level > 0) {
    echo $this->product->min_order_level;
} else {
    echo '1';
} ?>" />
       </span>
       <span class="quantity-controls js-recalculate">
      <input type="button" class="quantity-controls quantity-plus" />
      <input type="button" class="quantity-controls quantity-minus" />
       </span>
       <?php // Display the quantity box END ?>

       <?php
       // Display the add to cart button
       ?>
      <span class="addtocart-button">
      <input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo JText::_('COM_VIRTUEMART_CART_ADD_TO') ?>" title="<?php echo JText::_('COM_VIRTUEMART_CART_ADD_TO') ?>" />
      </span>
<?php } ?>

       <div class="clear"></div>
   </div>
<?php
} //*********************end of login test*********************//
?>

===============================================================

But do it by using an HTML override in your template folder.

bumburum

NO CHANGES. replace the entire default_addtocart.php
Quote from: stuart.prevos on May 29, 2012, 08:23:10 AM
I guess you could write a code like this in ->views->productdetails->tmpl->default_addtocart.php
=========================================================
<?php
if(!JFactory::getUser()->guest) //********************this will test if the user is logged and if they are do the following*****************//
{
?>
<div class="addtocart-bar">

<?php // Display the quantity box


    $stockhandle = VmConfig::get('stockhandle', 'none');
    if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($this->product->product_in_stock - $this->product->product_ordered) < 1) {
?>
      <a href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id='.$this->product->virtuemart_product_id); ?>"><?php echo JText::_('COM_VIRTUEMART_CART_NOTIFY') ?></a>

<?php } else { ?>
                  <!-- <label for="quantity<?php echo $this->product->virtuemart_product_id; ?>" class="quantity_box"><?php echo JText::_('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> -->
       <span class="quantity-box">
      <input type="text" class="quantity-input js-recalculate" name="quantity[]" value="<?php if (isset($this->product->min_order_level) && (int) $this->product->min_order_level > 0) {
    echo $this->product->min_order_level;
} else {
    echo '1';
} ?>" />
       </span>
       <span class="quantity-controls js-recalculate">
      <input type="button" class="quantity-controls quantity-plus" />
      <input type="button" class="quantity-controls quantity-minus" />
       </span>
       <?php // Display the quantity box END ?>

       <?php
       // Display the add to cart button
       ?>
      <span class="addtocart-button">
      <input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo JText::_('COM_VIRTUEMART_CART_ADD_TO') ?>" title="<?php echo JText::_('COM_VIRTUEMART_CART_ADD_TO') ?>" />
      </span>
<?php } ?>

       <div class="clear"></div>
   </div>
<?php
} //*********************end of login test*********************//
?>

===============================================================

But do it by using an HTML override in your template folder.