News:

Looking for documentation? Take a look on our wiki

Main Menu

Remove button Add to Cart for only some groups of users

Started by clabis71, December 28, 2011, 21:39:45 PM

Previous topic - Next topic

clabis71

Hi,

use joomla 1.7.3 and VM2

I need not to bring up the add to cart button for a specific group of users, but I can not do it, I managed to hide only the prices but it remains button shopping cart and then appears the words if you want to continue or view the shopping cart. Clicking it displays prices again even if that group of users is not enabled, how can I fix this?
In the version of Joomla 1.1.9 was displayed the words that had not been allowed to add to cart.

Milbo

This feature is at the moment missing, but it is relativly easy to add, we just need to extend the catalogue mode per shoppergroups.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/


IllusionStudio

This feature is absolutely essential for my shop, too. Is there any publishing date planned?

Lindhardsen

I add myself to the list of users who need this.

Are there any plans to implement this, and if so, is there any planned release date?

On the other hand, if we need to implement this ourselves, does anyone have some code to share?

Thanks in advance!
/Jan

tambay1001

yes. this is the one i've been looking for! Disabling "Add to Cart button" and "Ask a question about this product". I just want to display available products and its details. this would be a good feature.

clementstigma

Yeap, I definitely need this for one of the development I'm doing right now too! :)

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Lindhardsen

Quote from: Milbo on February 03, 2012, 13:09:04 PM
2.0.1c is a step in that direction.

Milbo, can you please explain a little more regarding what is coming in 2.0.1?

I actually ended up doing my own hack for this:
Now, prices are controlled by the standard functionality, so you can show them to all users if you want, or not.
What I have added, is a check to determine if the user is logged in or not. If the user is logged in, everything looks like normal.
If the user is not logged in, the "Add to Cart" is not shown. Also, you can choose whether or not to display the "Ask a question" button.
There is no "gui" to control this, if you implement my changes, this is what you get, you cannot turn it on/off from within VM control panel.

Should anyone be interested in this solution, I can probably share it with you ;)
But again, it should be interesting to hear what is included in the next release.


clabis71

Quote from: Milbo on February 03, 2012, 13:09:04 PM
2.0.1c is a step in that direction.

I installed the 2.0.1e release, but I see no solution to the problem, add to cart button still work even if you are not registered

clementstigma

Quote from: Lindhardsen on February 06, 2012, 20:49:40 PM
Quote from: Milbo on February 03, 2012, 13:09:04 PM
2.0.1c is a step in that direction.

Milbo, can you please explain a little more regarding what is coming in 2.0.1?

I actually ended up doing my own hack for this:
Now, prices are controlled by the standard functionality, so you can show them to all users if you want, or not.
What I have added, is a check to determine if the user is logged in or not. If the user is logged in, everything looks like normal.
If the user is not logged in, the "Add to Cart" is not shown. Also, you can choose whether or not to display the "Ask a question" button.
There is no "gui" to control this, if you implement my changes, this is what you get, you cannot turn it on/off from within VM control panel.

Should anyone be interested in this solution, I can probably share it with you ;)
But again, it should be interesting to hear what is included in the next release.

Heya, I'm in serious need of this hack, could you kindly share the solution which you used please? :)
I've been trying to figure it out on my own but it's just been insane!

cyberx

yes, yes, yes need this feature in my shop!
please tell me when come on this?

Lindhardsen

OK, here we go :D

In order to remove the Add to cart, follow these steps:

In the folder /components/com_virtuemart/views/productdetails/tmpl/ open the file called default.php (or <yourthemename>.php, if you are using a custom theme).
Approx. at the line number 145 (below the line that says: <?php // Add To Cart Button), add these lines:
                    $user =& JFactory::getUser();
                    if($user->id) {   

So that the start of the section now reads:
                    <?php // Add To Cart Button
                   
                    $user =& JFactory::getUser();
                    if($user->id) {               
                    if (!VmConfig::get('use_as_catalog',0)) { ?>
                    <div class="addtocart-area">

And then we need to close this up (this was actually what caused most headache to me personally... Kind of hard to grip the structure of the mixed html and php code in the same file):
At approx. line number 238, change to that it reads:
                    <?php }  // Add To Cart Button END
                    } ?>

Basically what this does, is to remove the Add to Cart button, unless you are a logged in user.

If you have comments on this, if you like it or not, please leave a comment! If you like it helped you as much as it did myself, feel free to leave a small token of appreciation on Paypal,  https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CU6U3PQ4FK5RW ;-) This is not much code, but I can promise I spend many hours figuring this out!

Lindhardsen

Also, in my implementation, we have replaced the "Ask seller a question" button with a "Log in to see prices" hyperlink, if the user is not logged in. Let me know if anyone are interested in the little addition as well.

/Jan

clementstigma

Hi Lind,

Thanks for the code!
I'm using a custom theme by Flexible Web Design or something so the code somehow didn't work for me.
Basically, I used the same codes but removed:
1. the { after if ($user->id)
2. didn't add any additional lines to Add to Cart Button END

I messed around with it and did the following:

1. After  <?php // Add To Cart Button, add:
                $user   = &JFactory::getUser();
                if ($user->id)

Final Code:
         <?php // Add To Cart Button
            
            $user   = &JFactory::getUser();
                                if ($user->id)
            if (!VmConfig::get('use_as_catalog',0)) { ?>
            <div class="addtocart-area">

Hope this helps anyone else using custom themes...thanks Lind again for sharing the code.
I'll make a PP payment once my project pays me at the end of the month! :)