The Add to cart button and Price shows on the Main Catalog page for all users

Comments

pmflav’s picture

Having the same problem.
Looking into it.

meowdogs’s picture

TY

ycimlynn’s picture

subscribe

psy11’s picture

Same problem...
What to do?
No answear from author..

joelstein’s picture

Sorry, I haven't had time to look into this. Currently I'm heads down on a few client projects. Bear with me, and feel free to submit patches in the meantime.

psy11’s picture

When it's possible to get an fix?

Once again thanks for yourr work.

joelstein’s picture

I made this project for a client, and my work for that client has ended. I'm currently wrapped up in several paying projects, so it's hard to give this much attention. If somebody wants to submit a patch or try to figure it out, I'll be happy to review it. Otherwise, feel free to contact me directly for paid support. ;)

joelstein’s picture

You are referring to the view which is provided by uc_product, right? UC Price Visibility doesn't currently have Views support.

There are several ways to alter what appears in your view (Views Custom Field is one quick and dirty way).

In order for UC Price Visibility to affect this view, Views support would need to be added. I think the class "uc_product_handler_field_price" would need to be overridden, but I'm not sure. Hopefully this gives somebody direction toward contributing a patch.

designate’s picture

subscribe

alessio_m’s picture

Had the same problem on D7 + U3

I'm not a developer but worked this out pretty easily by changing the Catalog (Table or Grid) on my Views

Just set it to display the Teaser (or any other Display) of your Content Type (under FORMAT > Show : Content | Teaser), which you have already set on Content Type > Manage Display > Teaser

3cwebdev’s picture

I fixed this issue by simply creating a Views field template for the Buy It Now field. I created a template file called views-view-field--buyitnowbutton.tpl.php and placed it in my theme's directory and added the following code.


 $vis_roles = $row->_field_data['nid']['entity']->uc_price_visibility;
 global $user;
 $visible = FALSE;
 foreach (array_keys($vis_roles) as $rid) {      
      if (isset($user->roles[$rid])) {
        $visible = TRUE;
        break;
      }
    }
 
if (!$visible){
 print variable_get('uc_price_visibility_message', '');
}else{
 print $output; 
}


pascalmortier’s picture

I fixed it by creating a template file 'views-view-field--sell-price.tpl.php'.
I put the template file in the theme's map.

<?php
global $user; 
$visible=0;
//tabel naar array voor deze node
$visibilities = db_fetch_array(db_query("SELECT * FROM {uc_price_visibility} WHERE nid = %d", $row->nid));
//rollen die deze node mogen zien in array plaatsen
$visiblitiesroles = explode(',', $visibilities['roles']);
//aantal waarden in deze array tellen
$aantalvisibilities = count($visiblitiesroles);

//kijken hoeveel rollen de user heeft
$aantaluserrollen = count($user->roles);

//de rollen doorlopen en kijken of ze matchen met de user zijn rollen
for($t=0;$t<$aantalvisibilities;$t++)
	{
		//kijken of er een match is 
		if (array_key_exists($visiblitiesroles[$t],$user->roles))  
		{
		//bij match, zet varialbe visible op 1
		$visible=1;
		}
	}
			
//verwerken resultaat
// bij match, druk prijs af
if($visible==1)
	{
		print $output;
	}
//geen match, druk de visibility boodschap af
else
	{
		print variable_get('uc_price_visibility_message', '');	
	}
?>
fizk’s picture

Status: Active » Fixed

The Add To Cart button should be hidden now:

http://drupalcode.org/project/uc_price_visibility.git/commit/a72fd2ce530...

If anyone knows of a way that this module can also hide the price in the catalog view without modifying any templates, please submit a patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mustanggb’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work

Here is my quick attempt at hiding the price.

function uc_price_visibility_views_post_execute(&$view) {
  foreach ($view->result as $row) {
    $node = node_load($row->nid);
    if (!uc_price_visibility_is_visible($node)) {
      unset($row->uc_products_sell_price);
    }
  }
}

i92guboj’s picture

Hello.

I guess there's still no "official" solution to this?