Hide price for anonymous user
I have looked absolutely everywhere. Has anyone been able to find a way to hide pricing for users (not logged in)not able to see the price. Upon login the prices would appear. I want to be able to have people see what products i offer but not pricing. Once i give them access to the site they will have appropriate pricing based on roles. Any help would be greatly appreciated.
Comments
Because prices are now
Because prices are now fields... In theory (I have not tested) you should be able to control price displays based on roles with this module: http://drupal.org/project/field_permissions
Thank you for the quick
Thank you for the quick response. That helped with one other issue i am having. But, for the price issue it states that the field is locked. Any ideas how to get around this part now?
Ohh man, I didn't even think
Ohh man, I didn't even think about that. I'm used to the content permissions all being placed on the permissions page...
Here is a relevant core issue by Ryan himself... http://drupal.org/node/806102 it looks like there are a few people are having the same issue.
I can't think of anyway to "unlock" the field besides going into the database and manually changing the setting... which I really do not recommend doing.
Again thanks for the
Again thanks for the direction. Unfortunately i would almost be willing to go the route of editing the database but i would have absolutely no idea what table that would be in. The risk is almost worth trying to get past this.
Anyone else have an idea how
Anyone else have an idea how to turn this off in the database? Or other way to get around the locked price field?
Dirty solution
I found that "commerce_price.module" file has 'locked' => TRUE value so i try to modify it to FALSE.
I do in a clean kickstart install, then i add field_permissions module and it let to show only for register users.
Then i found that you have to hide the "add to cart" to anonymous also in order to complete hide prices to anonymous users (and made your site works as catalog for anonymous). For this, go to your product display field product (the one that references the products) and made it visible only to register users.
I don't know how bad it's this solution but it's the only one that works. Now i'm searching a solution for a site with products without losing them...
can any core member test about this? or explain us a little more about why it must be locked by default
Database solution
I found another solution (cleaner) after spent some hours trying crazy things
I also found that it's not actual solution for exporting from drupal commerce. Importing is easy if you have a good cvs created using feeds but i can't find a solution for exporting actual products.
For unlock price you can go to your database -> table field_config -> edit commerce_price entry to change "locked" from 1 (enabled) to 0 (disabled)
Then you can have your field price unlock for edit it and use field permissions module to made it hide to anonymous users.
Also you can lock it again after doing the change!!.
Please D8 developers, add this kind of permisions in core! :P
Thank you very much for the
Thank you very much for the help. This will work perfectly for my needs. Again, thank you so much.
:)
You are wellcome, i tried on a local install and live and i have no problems (i lock it again) and do the job we need.
Nice solution, but I need more
I'm right in the middle of a project.
I want to prevent anonymous users can not see the price and they also can not make purchases on the site without being logged.
In the solution above, if the user clicks in "Add to cart", he can still see the price on the "Shopping Cart", which I also do not want.
The idea is to get the site to work only as a gallery for anonymous users. Send the user to the login screen when they click buy is a good idea.
Anyone have any solution?
Thank you.
thankyou!
genius! thanks! almost missed out the part on the fields permissions module -.-
go to db
could u elaborate on how to " go to your database -> table field_config -> edit commerce_price entry to change "locked" from 1 (enabled) to 0 (disabled)".
Price still shown in display node
Hi,
I tried all of the above.
Add To Cart is now hidden for anonymous users in the product display node and in teaser view, so that's OK.
However, the price is only hidden in the view, because I used the product reference twice. First showed as rendered and the second as Add To Cart. In both cases, the fields are coming from the product type, where I could set custom permissions on the fields.
But on the product display node, you have only the product reference, which i'm showing with the Add to cart display form widget. It's hidden for anonymous users because of the custom permissions in the product type.
The price is an extra 'field' that's unknown in the nodes field collection, but shows up on the Manage Display form of the node. And there I have no possibility to format the field, and it doesn't follow the field permission setting of the product type.
I tried to hide the field using a module, but i cannot find the correct $node->content field name for the commerce_price.
HELP!
Tried this module
I tried this module, but it only hides the Add to cart button and quantity field. The price is still displayed.
<?php
function hook_node_view($node, $view_mode) {
$node->content['field_product']['#access'] = FALSE;
}
?>
Any help to find the right field to hide the price would be appreciated.
Found the field but don't know how to hide it
After digging in deeper, I found the field that I need, but I don't know how to access it to hide it.
I should be the field product:commerce.
I tried:
$node->content['product:commerce_price']['#access'] = FALSE;
and
$product->commerce_price['#access'] = FALSE;
I'm not getting any errors, but the price is never hidden.
Please help me to solve this.
contextual_view_modes
Have you looked at this module https://drupal.org/project/contextual_view_modes? Along with contexts you can set up lots of different view modes to use when you want.
A nice solution
You can implement hook_entity_view_alter.
Place this in custom module:
hook_entity_view_alter(&$build, $type) {
$build['product:commerce_price']['#access']=FALSE;
}
Works fine!
show shopping cart , user rules?
for my purposes, price is visible to everyone, only trade have access to shopping cart.
so I just "hidden" add to cart, from content type, manage display.
How to show shopping cart again, when registered trade login?
By rules?
I am new user, not developer, not programmer, need step by step instruction pls.
check this
This is a good start: http://www.drupalcommerce.org/user-guide/anonymous-carts-and-logged-users
Thanks