User friendly product availability message in Magento

Lifestyle Out of Stock

Here is a little something to use on template/catalog/product/view.phtml page. I got few inquiries on how to get the “in_stock” status of a product. Here is a working sample code that shows different messages when and if the product is in stock or out of stock.

<?php // Check to see if the item is in stock 
if($_product->stock_item->is_in_stock == 1): 
	echo $this->__('Availability') ?>:<strong><?php echo $this->__('In stock') ?></strong>
<?php else:?>
		<strong><a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) ?>contacts/" title="<?php echo $this->__('Email') ?>"><?php echo $this->__('Email') ?></a></strong>
		<?php echo $this->__('or Call for Availability') ?>&nbsp;1-222-333-444
<?php endif; ?>


  1. Hi Yasser. Sure, its possible 🙂 When I think about it, it would make a nice little Magento extension.

    For example, “product is open/closed” could be translated (in Magento terms) to (A) “product is enabled/disabled” or (B) “product is out-of-stock/in-stock”, (C) other approaches that involve theme manipulation etc.

    Approaches (A) and (B) seem to be most in line with the rest of Magento functionality.

    Both (A) and (B) would simply come down to having your product change attribute value via CRON executed piece of code.

    Case (A) would manifest itself in such way that during the “closed” period products “Status” attribute would have “disabled”. Which would completely hide your product from frontend store.

    Case (B) might be somewhat more interesting to you as you could achieve effect where your product would be visible on frontend store but no one could buy it as it would be marked as “Out of Stock”. Plus if you add the additional custom attribute (lets say “closed_product_label”) in mix like a string attribute “Sorry, orders on this product are closed during x-y hours.” that you would also set programmatically via some CRON executed code. Meaning in this case you would set the “qty/stock” + “closed_product_label” values at the same time.

    In essence this should be a quick and simple task. However if you where to ask me to give you a development estimate, I would say a day of work (cca 8h of development), since it’s not just about development, as there are costs of communicaiton, testing, deploying, etc 🙂

    Hope my answer helps you solve your request. Cheers.

  2. i would like to know is there any possibility to open product in specific time per day to order?

    I need customer make order when the product time is open such as restaurant. order accept daily from 11am to 11 pm?

    I would be happy to hear you soon. thanks and best regards

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.