Disable Product - Price, Add to Cart, Wishlist

Contrib type: 
Module
Status: 
Bug testing
Moderation: 
Not ready for moderation

Downloads

Latest version: 
1.2
Compatibility: 
Ubercart 2.x

Sometimes you want to list products in the catalog but you don't want people to buy them. This module lets you disable the price and/or "add to cart" on a per product basis. Works in the UI the same as the shippable product checkbox.
Test on a development site first.


PreviewAttachmentSize
Drupal 52.85 KB
Drupal 6 Version2.08 KB
spoetnik's picture
Offline
Joined: 11/15/2007
Juice: 28
Button removed, price not??

Thanks for this modules. I wanted this functionality pretty bad
Testing this module, and it seems the "Add to cart button"is gone (yeah), but the price still shows.

See this for instance http://www.side-shore.nl/board/royal-62-love-machine

Any ideas??

ivan's picture
Offline
Joined: 06/04/2008
Juice: 9
Re: Disable Product - Price, Add to Cart, Wishlist

this is just what i need! i wonder if i can replace "add to cart" button into some text like "Out of stock!" ?

bakyildiz's picture
Offline
Joined: 01/23/2008
Juice: 185
Or instead of "Out of stock!" a custom message will be very nice

Nice contribution. As ivan mentioned some message should be given to customer. Other wise they will try to find a button to add to cart. BTW, instead of "Out of stock!" a custom message can ve much better for special cases.

albies's picture
Offline
Joined: 01/02/2008
Juice: 90
bugs

installed on drupal 5.7 and ubercart 5.x-1.4
1-
first of installation I haved 1st error when open my page module (now not remember message)
but resolved so: go on file .info and remove this " " at "Add to cart"

after installed:
2nd error:
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /...../sites/all/modules/ubercart/contrib/uc_disable_product/uc_disable_product.module on line 56

foreach ($form_values['items'] as $key => &$value)
I removed the &

not know why this error but I use php4 so not know if php5 this work, someone can to test?)

3- for uninstall I have message (write below **)
I resolved so in file .install
function uc_disable_product_uninstall()
{
db_query("ALTER TABLE {uc_products} DROP `hide_price` ");
db_query("ALTER TABLE {uc_products} DROP `disable_add_to_cart` ");
db_query("ALTER TABLE {uc_products} DROP `disable_wishlist` ");
}

have removed this rows /*!40100 DEFAULT CHARACTER SET UTF8 */ ;

I not tested module (too much error) and also there isn't a readme text how to use;
example: if you want remove the "add wishlist" button you must remove comment in .module file; I notice only because look at code;

**
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARACTER SET UTF8 */' at line 1 query: ALTER TABLE uc_products DROP `hide_price` /*!40100 DEFAULT CHARACTER SET UTF8 */ ; in /...../includes/database.mysql.inc on line 172.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARACTER SET UTF8 */' at line 1 query: ALTER TABLE uc_products DROP `disable_add_to_cart` /*!40100 DEFAULT CHARACTER SET UTF8 */ ; in /...../includes/database.mysql.inc on line 172.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARACTER SET UTF8 */' at line 1 query: ALTER TABLE uc_products DROP `disable_wishlist` /*!40100 DEFAULT CHARACTER SET UTF8 */ ; in /...../includes/database.mysql.inc on line 172.

albies's picture
Offline
Joined: 01/02/2008
Juice: 90
Re: Disable Product - Price, Add to Cart, Wishlist

on drupal 5.10 and ubercart 5.x-1.4
I have this message:
when install (and not active themodule)
warning: Error parsing sites/all/modules/ubercart/uc_disable_product/uc_disable_product.info on line 2 in C:\...\drupal\includes\module.inc on line 195.

and when active the module:
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in C:\...\drupal\sites\all\modules\ubercart\uc_disable_product\uc_disable_product.module on line 56

this error if use php 4.x
with php5.x not more errors.

Think (regard 2nd error)
because
at line 56--> foreach ($form_values['items'] as $key => &$value)
php4.x cannot work with & of $key => &$value

foreach ($form_values['items'] as $key => &$value)

So all work only on php5.x

albies's picture
Offline
Joined: 01/02/2008
Juice: 90
Re: Disable Product - Price, Add to Cart, Wishlist

I tested but there are some bugs:
1) images uploaded aren't visible;
2) when Hide product price, really in teaser remain the price (sell_price) and in the product node remain also the sell_price; so is hidden only the display_price

jpd
jpd's picture
Offline
Joined: 01/09/2009
Juice: 2
disable the price and/or "add to cart" per product class

I would like to disable the price and/or "add to cart" on a per product class basis. How would I change the module disable_product module to work on a product class instead of an individual product?

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1113
Re: disable the price and/or "add to cart" per product class

THIS MOD IS AWESOME!! IT IS PERFECT!!

It worked right out the box for me, version UC1.6

Thankyou very much!

hedac's picture
Offline
Joined: 12/14/2007
Juice: 144
Re: Disable Product - Price, Add to Cart, Wishlist

I would love to see this for v2.x drupal 6.

sandro's picture
Offline
Joined: 06/16/2009
Juice: 27
Re: Disable Product - Price, Add to Cart, Wishlist

Would like to see this for Ubercart 2.x too...

Fasttracks0's picture
Offline
Joined: 07/11/2009
Juice: 9
Re: Re: Disable Product - Price, Add to Cart, Wishlist

I would also love to see this ported to Ubercart 2... I used this module on my Ubercart site and am at a loss right now after migration to Durpal 6 and Ubercart 2...

Any chance of getting this module ported to Drupal 6?

My use:
I have products that are for display only as they are attributes for individual products. So, a product has an attribute for say a special type of wood, people need to see this attribute and some background information on it so I've created a product for that wood where they can see and read about it first...

Any help would be great... I haven't an idea where to start even if I could code...

Fasttracks0's picture
Offline
Joined: 07/11/2009
Juice: 9
Re: Disable Product - Price, Add to Cart, Wishlist

I've used "Deadwood" on this code and it did convert without any errors... The module installs without any errors but doesn't work? Any of the programmers out there willing to look this over?

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 302
D6 Version uploaded

I've uploaded a D6 version.

Biodiesel * (ubercart + drupal) = Sundays Energy

hedac's picture
Offline
Joined: 12/14/2007
Juice: 144
Re: D6 Version uploaded

tried in Ubercart 2, drupal 6.
it can hide the add to cart button, but still has to hide the product attributes options.

I figured out how to also disable product options by adding this line
$form['attributes']['#access'] = FALSE;

here:
if ($node->disable_add_to_cart) {
$form['submit']['#access'] = FALSE;
$form['attributes']['#access'] = FALSE;
}

Tristan's picture
Offline
Joined: 11/24/2009
Juice: 14
Re: Re: D6 Version uploaded

I also wanted to turn of the quantity, so fallowing your lead

$form['qty']['#access'] = FALSE;

here:
if ($node->disable_add_to_cart) {
$form['submit']['#access'] = FALSE;
$form['attributes']['#access'] = FALSE;
$form['qty']['#access'] = FALSE;
}

seems to work.

rho
rho's picture
Offline
Joined: 06/29/2009
Juice: 13
Drupal Actions

I used this module in a recent project that was very dependent on Drupal related triggers using rules. Namely having a product expire after the current time has passed the time specified in a date field, among other things. Anyway, it made more sense for me to use Drupal's actions/triggers system vs. UC conditional actions. I wrote a quick patch to this module to allow it to hook in as a Drupal action. It's behavior should be fairly self explanatory. Hope someone finds this useful.

AttachmentSize
disable_action.patch 2.44 KB
albies's picture
Offline
Joined: 01/02/2008
Juice: 90
Re: Disable Product - Price, Add to Cart, Wishlist

version for drupal 6 with php5 make an error of reference

I not know if is correct but in this rows I removed & first of variables

row 34
uc_disable_product_schema_alter(&$new_schema);
row 36
db_add_field(&$ret, 'uc_products', $name, $spec);
row 47
uc_disable_product_schema_alter(&$new_schema);
row 49
db_drop_field(&$ret, 'uc_products', $name);

is sufficient or also insert other codes? example some unset etc ?(see bottom)
-------------------------------------------------------------------------------------------------------------------------------------------

*** by php manual
After hours of confusion and reading tons of posts I finally figured out that replacing PHP 4 style object creation, where new is assigned by reference:

$node_obj =& new someClass($somearg, $moreargs);

which in PHP 5.3.0 generates an E_STRICT message telling you that "Assigning the return value of new by reference is deprecated"

with the following, where & has been removed:

$node_obj = new someClass($somearg, $moreargs);

in some cases (at least in recursive loops while creating a tree of nodes containing child nodes) requires

unset($node_obj);

before the actual object assignment line to avoid all child nodes becoming identical.

albies's picture
Offline
Joined: 01/02/2008
Juice: 90
Re: Disable Product - Price, Add to Cart, Wishlist

when I create a product see option for hide price.
but not see for hide button Add to cart

Alaska's picture
Offline
Joined: 10/16/2007
Juice: 1434
Broken Module

Running D6.16 with Uber 2.2 and have the same issue as in number 17 above with PHP 5.2.11.

row 34
uc_disable_product_schema_alter(&$new_schema);

etc.

Is there a patch to repair this module or a fix of some sort?

RikdeBoer's picture
Offline
Joined: 04/11/2010
Juice: 8
See also: UC Members-Only Permissions module

I needed very similar functionality, but was not aware of this thread, so wrote my own module: Ubercart Members-Only permissions.
You may find it useful. It's for Drupal 6.x, UC 2.x

Alaska's picture
Offline
Joined: 10/16/2007
Juice: 1434
Min/Max

An interesting module.

However, in my application there is the need to hide the cart button along with the price once an item has been sold. The product is manually moved to a sold catalog, removed from all other catalogs, has an inventory of zero and republished. Thought that product disable might work to hid the button and remove the price, but it appears it is not yet ready for use in D6.

Did get min/max to work by setting product maximum to 1 and then setting product minimum to 300. That will then trigger the error message which was rewritten to state the product was sold out. And it also prevents the use of the add to cart button. Messy but it works.....

ubzub's picture
Offline
Joined: 06/18/2010
Juice: 42
Procedure for using this module

How can i use this module?Can u provided step by step process?
Thanks

adamgonzalez1984's picture
Offline
Joined: 08/19/2010
Juice: 31
Not working with rules

I installed this module then I applied the patch but it doesn't seem to be working for me. I am able to hide the buy it now button when I'm creating or editing the product but I can't do it through rules. I have a triggered rule that is scheduled based on a "Order by" CCk field. This rule works when trying to do other things like adding text to the product telling people that the product is now expired. I tried to set this up to disable a product using rules but every time that I go into the rule settings and set the "Product and its derivatives sale availability: " field to "Not available for sale" and save the settings It doesn't stick. If you go back into the settings the "Product and its derivatives sale availability: " field is set back to "No Change" Any ideas as to what is causing this issue?

Thanks.

P.S. Is this module on drupal.org? If not I was wondering if someone could post it.

andrews501's picture
Offline
Joined: 11/15/2010
Juice: 71
Error in lines 34, 36, 47, 49

Hello all,

I just installed the disable product module for drupal 6 but it seems there is an error in the install file as I received a warning in lines 34, 36, 47, and 49.

I solved it by removing & that is next to $new_schema in each of the lines mentioned above.

Now I am about to see if it works. And then add the patch.

Working on drupal 6.19, ubercart 2.0

Thanks

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1113
Re: Error in lines 34, 36, 47, 49

I just downloaded and installed version 6.x-1.2 onto D6.20 without the modifications andrews501 performed. It installed without a hitch and I have full functionality.

Mike

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1113
Re: Disable Product - Price, Add to Cart, Wishlist

We get a lot of customers reporting they can't find our Add to Cart icon on products that are not available for sale. So I quickly made an addition (hack) for this and I thought I would share how I set up a display message when you disable the Add to Cart button/icon.

I first created a variable, "not-for-sale", in uc_disable_product.module as follows (lines 51-55):

    variable_set('not-for-sale', 'false');
    if ($node->disable_add_to_cart) {
      $form['submit']['#access'] = FALSE;
      variable_set('not-for-sale', 'true');
    }

Now I check this variable in my node-product.tpl.php as follows:

        <div class="status" style="clear: left; width: 300px; text-align: center;<?php if ((!$teaser) && (variable_get('not-for-sale', NULL) == 'false')) { print ' display: none;'; } ?>"">
            This item is currently on back order.<br />Please <b><a href="<?php print base_path(); ?>contact">contact us</a></b> for product availability.
        </div>

I placed this div just above my "cartButtons" div and I now have a nice status message that appears whenever we select products as not available for sale. I prevent the message from displaying on teasers because I'd at least want a customer to view all the details about our product before they just quickly turn away.

Hope this information can help someone,
BigMike

samgreco's picture
Offline
Joined: 07/30/2009
Juice: 271
Re: Re: Disable Product - Price, Add to Cart, Wishlist

Being a programming neophite, how would I do this for hidden prices?

We are trying to hide prices on products where the manufacturer does not allow online prices under a specified amount. But if the customer clicks the add to cart button, they can get a discounted price. So what I am trying to do is hide the price and have the phrase "Click Add to Cart to get our price" instead.

Any guidance would be VERY appreciated.

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1113
Hello samgreco, I am a huge

Hello samgreco,

I am a huge programming neophyte myself Smiling

Have you looked into creating your own product template file? Take a look at: http://www.ubercart.org/forum/development/3868/nifty_products_tutorial_p... With this, you can use php code to control what is output to the browser.

For instance, you could try this, which would display the text you want for product's whose node ID is either 12 or 24. You can have the code check for as many node IDs here as you need by using the OP operator: ||

<?php if (($node->nid == 12) || ($node->nid == 24)): ?>
  <div class="sell_price">
    Sell Price: Click Add to Cart to get our price
  </div>
  <?php else: ?>
  <div class="sell_price">
    Sell Price: <?php print uc_currency_format($node->sell_price) ?>
  </div>
<?php endif; ?>

Or another way that comes to mind is an adaptation of Alaska's 'Items on sale' method (reply #9 here: http://www.ubercart.org/forum/support/543/items_sale_how#comment-32280)

This method will eliminate the need to continuously update your node-product-template.php with additional node IDs. Instead, when you edit a product at configure it's list price at a higher level than it's sell price, this will effectively hide the sell price from the browser. This way you can do everything from your browser without having to alter your theme file over and over again.

<?php if ($sell_price < $list_price): ?>
  <div class="sell_price">
    Sell Price: Click Add to Cart to get our price
  </div>
  <?php else: ?>
  <div class="sell_price">
    Sell Price: <?php print uc_currency_format($node->sell_price) ?>
  </div>
<?php endif; ?>

There are many other methods but hopefully this gets you a good start!

Regards,
BigMike

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1113
Re: Hello samgreco, I am a huge

You might be able to take advantage of the Custom Publishing Options module for this.

I plan to use this module for giving us more publishing options (I've not installed it yet), but I wonder if you can pull the values in through php to your product theme template, then you can just have a simple check box at the bottom of your product edit page that could enable or disable the display of the sale price Smiling

But don't ask me how to do this yet, I've not installed the module yet! hahaha

Mike

samgreco's picture
Offline
Joined: 07/30/2009
Juice: 271
Thanks again BigMike. Could I

Thanks again BigMike.

Could I use a CCK field instead of List Price in this example? We have a few hundred items in there already and it would be much easier if we only had to do the items we add going forward Smiling

Sam

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1113
Re: Thanks again BigMike. Could I

Sorry I can't help you on that as I don't have much experience with CCK fields. That is an area I'd like to learn more about. I did some searching and came across this: http://drupal.org/node/62466 Might give you some useful information.

Good luck my friend!
BigMike

EDIT: I can't seem to find the Edit link for a previous post so I'm posting a correction here. I wrote, "by using the OP operator: ||" and I meant to say, "by using the OR operator: ||". OR not OP.

samgreco's picture
Offline
Joined: 07/30/2009
Juice: 271
Well. So far so good.  I did

Well. So far so good. I did this:


<div class="map-field"></div>
  <?php if ($sell_price < $field_map[0]['value']): ?>
  <label>MAP Price:</label><?php print $node-->field_map[0]['view'] ?>;
   <div class="sell_price">Click Add to Cart to get our price</div>
<?php else: ?>
<div class="sell_price">
<label>Our Price:</label> <?php print $sell_price; ?>
</div>
<?php endif; ?>
  <?php

That takes care of my product pages. BUT, I have 2 different views that I use. How do I do the same thing there?

Just so you can see what I am doing - GetAVProducts.Com

Dominion79's picture
Offline
Joined: 08/08/2010
Juice: 16
Price

I'm using Drupal 6.19 and Ubercart 2

I'm using a custom template file to display my product

I noticed that if I used a default template the price would hide as normal but when I use my custom template the price doesn't hide as expected.

I used this bit of php in my custom template to get the price to hide as expected.

<span class="price">
<?php
       
if ($node->hide_price == TRUE) {
            print
"Product not for sale";
        } else {
            print
uc_currency_format($node->sell_price);
        }
   
?>

</span>

I hope this helps someone.

diwwin's picture
Offline
Joined: 11/02/2010
Juice: 24
Re: Disable Product - Price, Add to Cart, Wishlist

the module seems to work for me in D6.20. Only the quantity box needs to be hidden too. How do you do that? I am using Display Suite to present the node fields and a fusion subtheme if that makes any difference.

essbee's picture
Offline
Joined: 07/21/2010
Juice: 29
Fix for Quantity field

Add this after line 52 to hide the quantity field.

<?php
unset($form['qty']); // ADDED BY SB 10/03/2011 to hide the qty field
?>

so now that section reads:

<?php
if (strpos($form_id, 'uc_product_add_to_cart_form_') === 0) {
   
$node = &$form['#parameters'][2];
    if (
$node->hide_price) {
      unset(
$node->content['list_price']);
      unset(
$node->content['cost']);
      unset(
$node->content['sell_price']);
      unset(
$node->content['display_price']);
    }
    if (
$node->disable_add_to_cart) {
     
$form['submit']['#access'] = FALSE;
      unset(
$form['qty']); // ADDED BY SB 10/03/2011 to hide the qty field
   
}
    if (
$node->disable_wishlist) {
     
$form['wishlist']['#access'] = FALSE;
    }
  }
?>
diwwin's picture
Offline
Joined: 11/02/2010
Juice: 24
Thanks for the tip

Wow thanks man.
Works like a charm.

diwwin's picture
Offline
Joined: 11/02/2010
Juice: 24
not as simple as I thought

Well, I have the "add to wishlist" button too, and it also needs the quantity box to function. Is it possible to rewrite this section to hide the quantity box only when "add to cart" AND "wishlist" are hidden?? And can message be printed that says "sold out"?

<?php
   
if ($node->disable_add_to_cart) {
     
$form['submit']['#access'] = FALSE;
      unset(
$form['qty']); // ADDED BY SB 10/03/2011 to hide the qty field 
   
}
    if (
$node->disable_wishlist) {
     
$form['wishlist']['#access'] = FALSE;
    }
?>
BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1113
Re: Disable Product - Price, Add to Cart, Wishlist

We like to give our customers the convenience of adding products to their carts and then returning after a couple of days to purchase everything. But the trouble is that when we run out of stock on something, and we use this mod to remove the Add To Cart link, we sometimes still get new orders in with products that we've already "disabled".

Is it possible to add an additional check somewhere that will prevent previously carted products cart from being purchased when the product is disabled"?

Thanks
Mike

diwwin's picture
Offline
Joined: 11/02/2010
Juice: 24
Re: Re: Disable Product - Price, Add to Cart, Wishlist

I would like this too. We sell plants, so once we run out, we are out until the following year.

ossa's picture
Offline
Joined: 03/24/2011
Juice: 25
Drupal 7

Hi any plans for D7 with this. Great feature, just what I need!
Thanks

hedac's picture
Offline
Joined: 12/14/2007
Juice: 144
Re: Disable Product - Price, Add to Cart, Wishlist

could this be integrated with Views price field? Using views the price is always shown.

thekenshow's picture
Offline
Joined: 01/11/2010
Juice: 16
Patch for Pass by Reference Errors on D6 + PHP5

Here's a patch for D6 that fixes the "Call-time pass-by-reference has been deprecated" errors on PHP 5, as reported in #17.

Also, about hiding the Quantity box #34 - it can be disabled simply by setting Default quantity to add to cart to 0.

PS. Thanks for this module, just what I needed this morning!

AttachmentSize
passByRefDeprecated-51572.patch 1.03 KB
jaytee (not verified)
jaytee's picture
test

alert("test")

tefnut's picture
Offline
Joined: 12/22/2010
Juice: 112
DRUPAL 7

Yes, I REALLY NEED a drupal 7 version!!!!

Thanks

carrie's picture
Offline
Joined: 11/09/2011
Juice: 6
Some errors

I have an error when I want to remove the "Add to Cart" and it takes if off the product page too. How do I stop it from doing that? Thanks.

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 302
Full project created on drupal.org

Biodiesel * (ubercart + drupal) = Sundays Energy

make-online-shop's picture
Offline
Joined: 01/01/2011
Juice: 511
Is it reliable on D6 store ?

Hello,

Can you confirm that this module to hide ADD TO CART button works well ?

Thanks a lot.

djkentuckyham's picture
Offline
Joined: 12/15/2011
Juice: 4
Price

2.5 years later and it totally saved my bacon. thanks!!

Lan
Lan's picture
Offline
Joined: 05/20/2014
Juice: 16
hide "Add To Cart button" when set up the attribute

Hi All,

I am using ubercart 7.x-3.6 module with drupal 7.26. I m making a website that is similar function with this website http://www.sigmaphoto.com/product/70-300mm-f4-56-dg-macro. and i tried to use ubercart attribute to make this work, but all of the attributes are linking to the "add to cart button" even though the price is 0.

how can we have the "add to cart" button dynamically. if product is not for sale, we take customer to a find a dealer link, else we show both find a dealer and add to cart button for products. (please see the attached image).

Any help would be immensely appreciated.

Thanks,
Lan

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1113
Re: hide "Add To Cart button" when set up the attribute

I don't believe this module is compatible with Drupal 7.x, could this be the problem?

Mike