Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
How to remove “Availability: In Stock” from product detail pages
 
Rob22193
Jr. Member
 
Total Posts:  26
Joined:  2008-11-14
 

Anybody know how to remove the text “Availability: In Stock” from the product detail page?  I’ve seen a few threads asking this but have not come across an answer yet.  Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gui
Guru
 
Avatar
Total Posts:  588
Joined:  2008-03-09
 

Well you have a few options for that. Depends on what you want to do or show.

1. You can change the language file to show a different text or nothing. 

2. The line is picked up from the files in the following directory
/public_html/magento/app/design/frontend/default/default/template/catalog/product/view/type/

By removing this piece of code

<?php echo $this->__('Availability: In stock.'?>
you keep the functionality of the “Out of stock” working.

3. alternatively you can add some code to check the stocklevel and return the standard “In stock” only when you have stock.

This is my code that uses the custom attribute ‘availability’ to show the delivery time when an item is not in stock:

<?php if($_product->isSaleable()): ?>
<class="availability">
    
<?php 
    $stockLevel 
= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
        if (
$stockLevel <= "0")
                echo 
$_product->getResource()->getAttribute('availability')->getFrontend()->getValue($_product);
    else
        echo 
$this->__('Availability: In stock.');
?> </p>
        
<?php else: ?>
    
<class="availability"><?php echo $this->__('Availability: Out of stock.'?></p>
<?php endif; ?>

Please note that if you do not have a custom theme, any hacks will be overwritten next time you update. I only use this on simple and grouped products, since I don’t have any other.

Hope that helps you going.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rob22193
Jr. Member
 
Total Posts:  26
Joined:  2008-11-14
 

Thanks.  That worked perfectly.

 
Magento Community Magento Community
Magento Community
Magento Community
 
coooool
Jr. Member
 
Total Posts:  13
Joined:  2008-12-08
 

I followed the second method. This is helpful !!

 
Magento Community Magento Community
Magento Community
Magento Community
 
MaikelSmith
Member
 
Avatar
Total Posts:  59
Joined:  2009-03-31
 

How about:

echo $_product->getResource()->getAttribute('delivery_time')->getFrontend()->getLabel($_product);
echo 
': ';
echo 
$_product->getResource()->getAttribute('delivery_time')->getFrontend()->getValue($_product);

Just to print out the Label of the attribute as well…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gui
Guru
 
Avatar
Total Posts:  588
Joined:  2008-03-09
 

That would come in handy. However when I try this I get a blank product page. Everything is stopped at the “availability” call.

I can echo the getLabel seperately and getValue, but when I try to combine them like your example. It stops working. Do you have this working?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gui
Guru
 
Avatar
Total Posts:  588
Joined:  2008-03-09
 

allright, got it working, must be done this way:

<class="availability">
    
<?php 
    $stockLevel 
= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
        if (
$stockLevel <= "0"{
                
echo $_product->getResource()->getAttribute('availability')->getFrontend()->getLabel($_product);
                echo 
': ';
                echo 
$_product->getResource()->getAttribute('availability')->getFrontend()->getValue($_product);
}    elseif ($stockLevel "0"{
        
echo $this->__('Availability: In stock.');
}        
?> 
</p>

Just noticed that the getLabel function only gets the real admin label and not the translation. At least in this case. Is that normal behaviour?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jASK
Jr. Member
 
Total Posts:  4
Joined:  2009-06-25
 

Hi!

do you think there might be a way to implement this in a configurable product to achieve the following:

the customer chooses e.g. another size from a dropdown. on this event i want to check the availability of the new size and display it. i would think you need some ajax for this? anyone having a hint? or maybe there already is a solution?

thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
carbonfiberhood
Jr. Member
 
Total Posts:  17
Joined:  2010-08-08
SEIBON Carbon Fiber Hood distributing facility
 

Another way to do this is just make the css class hidden.

All I did was edit my style.css and change this line

from

/* Availability */
.availability { margin:0;}

to

/* Availability */
.availability { margin:0visibilityhidden;}
 
Magento Community Magento Community
Magento Community
Magento Community
 
Marusya
Jr. Member
 
Total Posts:  15
Joined:  2010-08-08
 

Hello Carbon,

The CSS update worked for me. Seems to work very well.  cool smile

http://www.marusya.us

 
Magento Community Magento Community
Magento Community
Magento Community
 
junomedia
Sr. Member
 
Avatar
Total Posts:  142
Joined:  2008-09-10
Nottingham, England
 

Thanks, Worked perfectly!

 
Magento Community Magento Community
Magento Community
Magento Community
 
bfly03
Member
 
Total Posts:  59
Joined:  2010-06-14
 

I know it’s a little off the main subject, but I am looking to put my ‘In stock.’ to the right of my ‘Price,’ would that be done in the css?

thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
llclj
Jr. Member
 
Total Posts:  5
Joined:  2011-05-09
 

Thanks! I also updated the CSS though I appreciate the code as I may implement a longer term solution using that.

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshuajarman
Sr. Member
 
Avatar
Total Posts:  76
Joined:  2009-04-08
 

The CSS method is the best longterm method, as it doesn’t require any template files to be overridden, is upgrade proof, still allows modules and javascript to interact with that piece of code behind the scenes, etc.

I recommend a slight variation on the above:

.availability { displaynone}

If you just want to display availability when out of stock use this:

.availability.in-stock { displaynone}

If you just want to display availability when in stock use this:

.availability.out-of-stock { displaynone}

Couldn’t be simpler and more upgrade proof then that!

Enjoy! grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 

Joshua, thanks for sharing, a very good tip! 
Btw, if someone wants not just hide the status, but add a meaningful message like “Just 3 items left” or “Will be available next day” or even put a nice image to indicate the product is in stock, they can check the Custom Stock Status plugin.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chriswillows
Jr. Member
 
Total Posts:  1
Joined:  2011-12-15
 

From the Admin Panel > System > Configuration > Design > HTML Head > Miscellaneous Scripts, copy/paste:

<style type="text/css">
.availability { display: none; }
.availability.in-stock { display: none; }
.availability.out-of-stock { display: none; }
</style>

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2