Magento – add ‘BackOrdered’ status to product page in place of Available or Out of Stock

backorderPHP

i have seen various code snipets to add a 'Back Ordered' status to my product page, but it's not working for me.

my file for product display is:
…./public_html/app/design/frontend/default/MYTEMPLATE/template/catalog/product/view/type/default.phtml

existing code

what can i do to the code above to get a 'Back Ordered' Status on the page in place of 'In Stock' when the inventory quantity is 0. having them go to the checkout page to see this is a waste for customers.

Best Answer

Use allow qty below 0 on the product and add

<?php $product_inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product) ?>
<?php if($product_inventory->getQty() <= 0 && ($product_inventory->getBackorders() == 1 || $product_inventory->getBackorders() == 2)): ?>
<p class="choseyourclass"><?php echo $this->__('Availability:') ?><span><?php echo $this->__('Back Ordered') ?></span></p>

Before the first if and make the first if an elseif.

You could also do it with an attribute and set this on inventory update with the above condition, this would decrease load avoiding the cataloginventory model call. You would have to set the attribute manual at first tough (do a massupdate trough the Products grid or use import/export).

(For example observe cataloginventory_stock_item_save_after (I think there will be more needed))

There might be a typo or something in the example as I just typed it by heart.

Related Topic