Add to cart button

Posts: 42
Joined: 08/08/2007

I have 2 websites Retail and wholesale one is working perfect but the wholesale website I want to hide price and add to cart button as well but on the place of add to cart button there will be written Log in to view prices

I have searched everywhere but didnt found proper code or module to help me and all other members who are looking for this feature in Ubercart.

There are lods of discussion about this feature but not proper solution here is some discussions

http://www.ubercart.org/forum/development/848/hide_price_unless_logged
http://www.ubercart.org/forum/support/2713/hide_sell_price_catalog_view
http://www.ubercart.org/forum/ideas_and_suggestions/2989/hide_price_fiel...
http://www.ubercart.org/forum/support/2922/access_control_catalog

Thanks in advance

--

www.taggedcheap.co.uk The cheapest price shop

Posts: 42
Joined: 08/08/2007

No one is here to help me??

--

www.taggedcheap.co.uk The cheapest price shop

Posts: 410
Joined: 08/13/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer

Hi,

to do that, I think the best way to proceed is to redeclare the theme_uc_product_display_price in your template.php file and make a condition with the user role to show the price only for certain authentificated users.

To test if the user is logged, you can make the conditions on the $user->uid

<?php
global $user;
if (
$user->uid) {
// Show price
} else {
// hide price
}
?>

Posts: 42
Joined: 08/08/2007

hi

I dont know any programing is there any easy way to do please help me!!

--

www.taggedcheap.co.uk The cheapest price shop

Posts: 3214
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

surbir, that probably is the easiest way to do it. Sticking out tongue For custom modifications, the best suggestion I have if you can't do it yourself is to post up a bounty and see if anyone is willing to do the work for you.

Posts: 410
Joined: 08/13/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer

Hi,

My father always said to me : "When you don't know, you learn".

The way I give you is very simple, even without programming skills. You just have to create a template.php file in your theme folder and copy and paste the theme_uc_product_display_price() in it and replace "theme_" by "phptemplate_".

More infos about how override themes function here.

You are lucky, Drupal possess a very good API system and a complete handbook, that is not the case of all CMS...

So, to resume, in your template.php file, just put that :

<?php
function phptemplate_uc_product_display_price($price){
  global
$user;
  if (
$user->uid) {
   
$output = '<div class="display_price">';
   
$output .= uc_currency_format($price);
   
$output .= '</div>';
   
  } else {
   
$output = t('Sorry, you have to be registered to see products prices');
  }
  return
$output;
}
?>

But try to understand the way to override theme functions, because this is the main way to customize drupal.

Good luck

zmove

Posts: 42
Joined: 08/08/2007

Hi thanks zmove all done here is my website

http://wholesale.taggedcheap.co.uk

--

www.taggedcheap.co.uk The cheapest price shop

Posts: 42
Joined: 08/08/2007

I have used this function to hide price that was good but stil add to cart button was active to hide add to cart button I have used this

<?php



function uc_product_forms(){
 
$products = db_query("SELECT DISTINCT nid FROM {uc_products}");

 
  global
$user;
 
  if (
$user->uid) {
              while (
$product = db_fetch_object($products)){
               
$forms['uc_product_add_to_cart_form_'. $product->nid] = array('callback' => 'uc_product_add_to_cart_form');
               
$forms['uc_catalog_buy_it_now_form_'. $product->nid] = array('callback' => 'uc_catalog_buy_it_now_form');
              }    
  }

  return
$forms;
}
?>

after doing this I am getting this error in logs

<?php
call_user_func_array
() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argumented is expected to be a valid callback, 'uc_product_add_to_cart_form_168' was given in /home/designsd/public_html/wholesale/includes/form.inc on line 218.
?>

As I have 10 products on front page so I will get 10 times error with differnt form id
Can anyone helps me

Thanks in advance

--

www.taggedcheap.co.uk The cheapest price shop

Posts: 70
Joined: 04/05/2008
Bug Finder

zmove

Good information there.

Thanks.

Posts: 64
Joined: 01/11/2008

I've had one reply to my bounty from webmasterkai but he hasn't replied my reply yet, so still waiting.

He said he could write a plug in to control what can be removed with check boxes and what roles can see the cart parts.

Posts: 10
Joined: 05/03/2008

Hi,

Does anyone know if it's possible to hide the price based on the role/group a user is the member of?

Thanks.

--

“I cannot give you the formula for success, but I can give you the formula for failure – which is: Try to please everybody.” - Journalist Herbert Bayard Swope

Posts: 64
Joined: 01/11/2008

This is being worked on for me. It'll be released once its finished hopefully sometime later this week.