hide Add button and price for unregistered users

10 posts / 0 new
Last post
elifio
elifio's picture
hide Add button and price for unregistered users

Hello:

I want to hide price and add button for unregister users.

Only registered user can views this.

It can be done easily via CSS or do I need to modify tpl template/view ????

support
support's picture
Hi there Elifio:

Hi there Elifio:

Please check this post. I'm pretty sure it is what you need: http://drupal.stackexchange.com/questions/102842/commerce-hide-add-to-ca...

Best!!!

elifio
elifio's picture
hide

thanks...

think this use this the previous time...

I will change the tpl

elifio
elifio's picture
hide prize and add cart only for anonymus users

Hello again:

I tried creating a simple module as shown in the link, but no way ..

I've also tried to do what I did in my previous template that was something like

global $user;
if ( $user->uid ) { ?>
<?php print t('Precio sin iva') ?>: <?php print strip_tags(render($content['field_preciosiniva'])) ?>
<?php } ?>

but of course in this template does not help me because the tpl are different

I am not sure if I have to rewrite one view or one tpl ...

and what tpl ???

thanks in advance

any ideas?

support
support's picture
Hi Elifio:

Hi Elifio:

No need to create a new module. As themes are seen as "modules" too by Drupal, you can just go to the file template.php of the theme folder and where the function name is:

function mymodule_form_commerce_cart_add_to_cart_form_alter (

just use

function stock_form_commerce_cart_add_to_cart_form_alter (

Best!!!

elifio
elifio's picture
Uauuuu.... Great support...

Uauuuu.... Great support...

thanks... for all

I put the function of the link in template.php and perfect...

elifio
elifio's picture
I'll want hide de price for

I'll want hide de price for unregister users

Install de module field permission https://www.drupal.org/project/field_permissions and enabled it.
In Type content, field price (commer price) you can not change.
So I created another field field-newprice and I have added to the view

I have hidden the original price

I have modigy in less creating a new .views-field-field-newPrice class with the same properties as views-field-commerce-price
(label include)

and I've saved
after I modified similarly the product detail.

support
support's picture
Hi there Elifio:

Hi there Elifio:

Great it worked! Now, about your second post, I don't know what you need??

Best!!!

elifio
elifio's picture
thanks nothing

thanks nothing

Was a guide for others people...

perhaps the phrase "I'll want hide de price for unregister users" should be "if you read this post and you want to hide the price"

:)

support
support's picture
LOL! Ok, no problem.

LOL! Ok, no problem.

Log in to post comments