Contrib type:
ModuleStatus:
Complete and workingCompatibility:
Ubercart Dev CodeLatest version:
1.0Sponsor: end user
Developer: Sundays Energy
This module allows you to control the visibility of each ubercart field based on a user role. For example you could hide the "add to cart" button and sell price but display the list price for anonymous users. Access to the fields is controlled in the usual /admin/user/access area.
Related threads:
| Attachment | Size |
|---|---|
| uc_field_access.zip | 1.98 KB |

Re: Field Access Permissions
Sounds very useful! Thanks for posting.
edit-qty
It is possible to hide the edit-qty field?
buntstich
"add to cart" button, not directing to shopping cart
For some reason, the "add to cart" buttons don't want to redirect to the shopping cart page but rather just reload the same page. This was not always the case and I am not sure what settings have changed. The settings on "Configurations > Cart Settings > Add to Cart Redirect" is just "cart" and this is the same as when it was working.
The product is added to the cart and a new text line is added to the top of the page with the product name and then "...added to your shopping cart." witht he last part as a link to your shopping cart.
You can test it here, http://womenhelpingwomen.com/store/annual-membership
or you can see the screenshot that shows the new line of text.
Re: "add to cart" button, not directing to shopping cart
It actually worked fine for me... I wonder if there was some other issue. Looking at the source for this contrib I don't see anything that affects what happens when the add to cart form is submitted.
Re: "add to cart" button, not directing to shopping cart
Ryan,
Thanks for the quick reply. It works now because I had to uninstall the "wish list" module. I think it was treating the product differently.
Sam
Re: Re: "add to cart" button, not directing to shopping cart
i keep getting the following error when i put this module in the sites/all/modules directly
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /home/www/urhirtwsh/uber/sites/all/modules/uc_field_access/uc_field_access.module on line 110
can anyone help?
thanks
Re: Re: Re: "add to cart" button, not directing to shopping cart
Looks like the module uses a PHP 5 specific feature of foreach(). Any way you can update the version of PHP on your web server?
Re: Re: Re: Re: "add to cart" button, not directing to shopping
Thanks Ryan, makes sense. thay only have v4 point something.
I'll look into modifying the code unless anyone has a suggestion?
thanks
Re: Re: Re: Re: Re: "add to cart" button, not directing to shopp
i've just commented out the following (pretty much flying blind but i don't have the wish list installed anyway) tell me if it's going to do some bad... but it seems to work fine now.
<?php
function uc_field_access_form_alter($form_id, &$form)
{
$product=$form['#parameters'][1];
$cid=$product->type;
if($form_id == 'uc_product_add_to_cart_form_' . $form['nid']['#value'])
{
if (!user_access('view '.$cid.' add_to_cart'))
{
$form['submit']['#access'] = false;
}
}
//if (($form_id == 'uc_wishlist_view_form'))
//{
// foreach ($form['items'] as $key => &$value)
// {
// if (!user_access('view '.$cid.' add_to_cart'))
// {
// $value['addcart']['#access'] = false;
// }
// if (!user_access('view '.$cid.' display_price'))
// {
// $value['#total'] = 0;
// }
// }
//}
}
?>
Re: Re: Re: Re: Re: Re: "add to cart" button, not directing to s
It looks to be specific for the wishlist form, so if you're not using the wishlist module I wouldn't worry about it.
Permissions Ignored with my Setup
Thanks for the module.
Having some problems.
I've overridden the product display page, as per the "nifty products" tutorial.
I've added this code to my node-product.tpl.php:
<?php if($node->content['cost']["#access"]) { print $node->content['cost']["#value"];} ?><?php if($node->content['sell_price']["#access"]) { print $node->content['sell_price']["#value"];} ?>
For some reason, the sell_price is getting hidden for anonymous, but the "cost" field will not display for anyone, even admin.
Could you help?