I would like to set some products to "non-saleable", removing the "Add to cart" button and adding a link to contact form.
I'm looking for this solution for a few weeks. Searching, I found this post:
http://www.e-commercewebdesign.co.uk/blog/magento-tutorials/non-salable-products-with-attribute-sets.php
But I can't make it work. Someone could help me with more details?
That tutorial will work, but I would do it a different way.
First of all, that tutorial forces you to use a specific attribute set ID. As with product IDs, category IDs, etc this can change if you are managing development/production server environments. I would not recommend this.
Personally (and I know there are better ways), I'd create a new product attribute, something along the lines of 'Not For Sale'. Make this attribute 'Yes/No' with a default of No (it is for sale).
Then, where you have an add to cart button, in view.phtml for example, find the chunk of code that displays the add-to-cart button, something like:
<?php echo $this->getChildHtml('addtocart') ?>
Wrap this chunk with the following:
<?php if(!$_product->getNotForSale()) : ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php endif ?>
Then for those products you don't want to be purchased, set the attribute value in product management to 'Yes'.
Additionally, you could tie an else statement in there to display an alternate button or whatever.
This method is fundamentally the same, but gives you more fine-grained control as you won't have to mess with various attribute sets and their IDs. It's also a lot easier to control your attribute names than your attribute set IDs.
--- edit --- To place content instead of the button:
<?php if(!$_product->getNotForSale()) : ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php else : ?>
<?php echo $this->__('Call Us to Order') ?>
... or whatever else you may want here ...
<?php endif ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With