Author Topic: Remove button Add to Cart for only some groups of users  (Read 21059 times)

clabis71

  • Beginner
  • *
  • Posts: 38
Remove button Add to Cart for only some groups of users
« on: December 28, 2011, 21:39:45 pm »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10088
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Remove button Add to Cart for only some groups of users
« Reply #1 on: December 28, 2011, 22:22:10 pm »
This feature is at the moment missing, but it is relativly easy to add, we just need to extend the catalogue mode per shoppergroups.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

clabis71

  • Beginner
  • *
  • Posts: 38
Re: Remove button Add to Cart for only some groups of users
« Reply #2 on: January 01, 2012, 10:30:29 am »
deadlines?

IllusionStudio

  • Beginner
  • *
  • Posts: 7
Re: Remove button Add to Cart for only some groups of users
« Reply #3 on: January 12, 2012, 09:46:01 am »
This feature is absolutely essential for my shop, too. Is there any publishing date planned?

Lindhardsen

  • Beginner
  • *
  • Posts: 18
Re: Remove button Add to Cart for only some groups of users
« Reply #4 on: January 18, 2012, 20:55:42 pm »
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

  • Beginner
  • *
  • Posts: 3
Re: Remove button Add to Cart for only some groups of users
« Reply #5 on: February 03, 2012, 02:17:37 am »
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

  • Beginner
  • *
  • Posts: 12
Re: Remove button Add to Cart for only some groups of users
« Reply #6 on: February 03, 2012, 07:48:35 am »
Yeap, I definitely need this for one of the development I'm doing right now too! :)

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10088
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Remove button Add to Cart for only some groups of users
« Reply #7 on: February 03, 2012, 13:09:04 pm »
2.0.1c is a step in that direction.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Lindhardsen

  • Beginner
  • *
  • Posts: 18
Re: Remove button Add to Cart for only some groups of users
« Reply #8 on: February 06, 2012, 20:49:40 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

  • Beginner
  • *
  • Posts: 38
Re: Remove button Add to Cart for only some groups of users
« Reply #9 on: February 08, 2012, 12:55:39 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

  • Beginner
  • *
  • Posts: 12
Re: Remove button Add to Cart for only some groups of users
« Reply #10 on: February 14, 2012, 03:24:40 am »
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

  • Beginner
  • *
  • Posts: 9
Re: Remove button Add to Cart for only some groups of users
« Reply #11 on: February 14, 2012, 16:21:15 pm »
yes, yes, yes need this feature in my shop!
please tell me when come on this?

Lindhardsen

  • Beginner
  • *
  • Posts: 18
Re: Remove button Add to Cart for only some groups of users
« Reply #12 on: February 15, 2012, 23:29:16 pm »
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

  • Beginner
  • *
  • Posts: 18
Re: Remove button Add to Cart for only some groups of users
« Reply #13 on: February 15, 2012, 23:34:15 pm »
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

  • Beginner
  • *
  • Posts: 12
Re: Remove button Add to Cart for only some groups of users
« Reply #14 on: February 18, 2012, 14:02:46 pm »
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! :)