How would I pull off something like hiding a price & add to cart button with quantity input from catalog view and from product nodes if the users browsing the cart are not registered and logged in (and displaying a custom message like "LOG IN TO VIEW PRICING" or something)?

In uc_product_view(), each element has an #access property that determines whether it will be shown or not. This is how the settings for the product fields get enforced. In addition, the cost field only allows users with the 'administer products' permission to see it.

You can use hook_nodeapi('view') to change or modify these elements however you want.

Anonymous users have a user id of 0, so you can do something like this:

now, how would I edit that code so to add an updated value instead of the display price/sell price/add to cart and display a link to user registration pages instead in order to view the prices/add to cart.

also, would this same process work in uc_catalog.module too, for catalog views too?

Make a module of your own and call it "custom" or something. This involves writing a .info file and putting that function in custom.module. The function would be called custom_nodeapi() as well. Once it's in the modules directory, you can enable it like any other Drupal module and you should see it working.

What I did was create custom.module and placed it under sites/all/modules/custom. But, the function inside I named uc_product_nodeapi() because I thought that the hook part of [hook]_nodeapi had to be the name of the module I am accessing. It seems to work as expected.

It works because Drupal loads the module file, and uc_product_nodeapi() doesn't exist in uc_product.module. Once the modules are loaded, it doesn't matter what file they came from. Hooks are called by module_invoke(), and since uc_product is an active module, the function uc_product_nodeapi() is a valid hook.

You want to name your hooks after your module so you are guaranteed not to have any name collisions. If I happen to put my own version of uc_product_nodeapi() in uc_product.module, PHP would crash on you.

Sorry for being that newbie. I just tried that solution, but i copypasted that code into uc_product.module and it didn't work.
Should i change instead of '#access'?
Or shouldn't i paste it into that module?

I got that working just fine, but the question still remains - how would I code it so that if the user is not logged in I would "hide" the sell_price and few other fields AND change the #value of sell_price to actually display a login link AND show that sell_price variable (since I am having a problem with it being hidden due to this:

Sorry for being that newbie. I just tried that solution, but i copypasted that code into uc_product.module and it didn't work.
Should i change instead of '#access'?
Or shouldn't i paste it into that module?

help pls.

c

Same question, its just copypaste the code? what more need to be changed? I create a custom module, activate it and nothing happen. I just want to hide the add to cart button for anonymous users.

carl0s and diego, I think the problem is that pages are cached for anonymous users, so they are still seeing the old nodes. If you empty out your cache database tables, they should see what they are supposed to.

I finally realized that I had forgotten to specify the "view" op in my code, but that shouldn't have affected too much. Instead, it'll be the product template file that you have.I'd have to see it to figure out why it's not using the values from hook_nodeapi().

Also very new at this. I think I have more or less an idea of what to do here, but I'd really appreciate it if you could put this in baby terms for me. This is an extremely important feature that my client has requested. Could you give me step by step instructions on how to accomplish this...?

How would I pull off something like hiding a price & add to cart button with quantity input from catalog view and from product nodes if the users browsing the cart are not registered and logged in (and displaying a custom message like "LOG IN TO VIEW PRICING" or something)?

Also the following code works for me to hide unless the user is authenticated. Just change "authenticated user" to whatever role you want them to have before they can see the product information and it will be hidden. This hides the whole section of product information but can easily be altered to just hide the price.

<!-- HTML for users not signed in --> <strong>Log in to see pricing & shipping information.</strong>

<?php } ?>

I'm using the module and theme code in tandem. It would be nice if not only this functionality (hide price if not logged in) but separate price tiers by role were added to UberCart core (or at least a full, clean module for Ubercart 2).