user2925363
user2925363

Reputation: 1

Hide the "addtocart'" button in Virtuemart for not logged in users

I am trying to customise a Virtuemart Template in order to hide the ADD TO CART button only for users who are not logged in or unregistered. I am using Virtuemart 2.0.x and Joomla 2.5.x

I have added this code in the "default_addtocart.php" file after line 122: (/templates/MYTEMPLATE/html/com_virtuemart/productdetails/)

after this code:

            <span class="addtocart-button">
            <?php echo shopFunctionsF::getAddToCartButton ($this->product->orderable); ?>

I have added this code:

        <?php if ($_SESSION['auth']['user_id'] = 1) { ?>
            <style type="text/css" media="screen">
            .addtocart-area, .addtocart-bar, .quantity-box, .addtocart-button { display:none;}
            </style>

This makes the "addtocart" button to be hidden, but for all usergroups, regardless if a user is logged in or not.

Any help is much appreciated. Thanks

Upvotes: 0

Views: 1070

Answers (1)

Jobin
Jobin

Reputation: 8282

Try this,

        <?php 
                $user = JFactory::getUser();
                if($user->id <= 0):
           ?>
        <style type="text/css" media="screen">
        .addtocart-area, .addtocart-bar, .quantity-box, .addtocart-button { display:none;}
        </style>

       <?php endif; ?>

Upvotes: 1

Related Questions