7

I'm trying to get the Add to cart button to appear on products that are Out of stock. I've already set the System->Configuration->Catalog->Inventory->Backorders=Allow Qty Below 0

My store previously did not allow back orders. If I add the following code:

<?php echo $this->getChildHtml('addtocart') ?>

The Add to cart appears on products that are In Stock but does not appear on products that are Out of stock.

Troubleshooting:

  • Inventory > Stock Options > Display Out of Stock Products is set to YES
  • Cleared all cache var/cache, var/session, restarted httpd
  • Re-indexed all indexes
  • Tried using default theme with same result

Still no success and as pointed out by Simon this is not a new problem. What I am having trouble understanding is why there would be the option(s) to Allow back orders and Allow stock level quantities to go bellow 0 and not have the Add to cart button.

UPDATE II

I downloaded and installed the latest version of Magento, did a fresh installation, added 2 products, one with inventory (In stock) the other without (Out of stock) have set Allow Qty Bellow 0, Show products out of stock and the same problem.

Would appreciate an explanation and a solution to this problem.

12
  • Tried backorders in magento ? Commented Aug 11, 2014 at 4:38
  • @TBIInfotech yes I did, I mentioned it above thank you.
    – SR_Magento
    Commented Aug 11, 2014 at 11:27
  • I have answered to this, have you checked changing setting from manage products? Commented Aug 11, 2014 at 11:30
  • Yes you answered but I already mentioned I did this in my question. I have checked these settings and the suggestions from Pronto and Amsty; I believe the problem is with the magento code. I cannot get the add to cart button to appear for products that are out of stock with the code I provided <?php echo $this->getChildHtml('addtocart') ?> and I turning off manage stock is not an option as I have scripts handling this, furthermore it incorrectly tells visitors the product is in stock when in fact it is not.
    – SR_Magento
    Commented Aug 11, 2014 at 11:43
  • 1
    Try clearing cache via var folder, or remove any custom coding done, or try using custom theme check if it is working for default theme Commented Aug 11, 2014 at 11:57

4 Answers 4

12
+50

Unfortunately, you are not missing a step here. Normally, people would think that the following two configuration options are enough to make it happen:

  1. Set System - Configuration - Catalog - Inventory - Stock Options - Display Out of Stock Products to Yes.
  2. Set System - Configuration - Catalog - Inventory - Product Stock Options - Backorder to Allow Qty Below 0.

You of course also have to make sure that the same settings are set in the specific product or that the product is configured to use the config settings.

Unfortunately, this is not true. So that it really works, the availability of the product has to be set to In Stock. Otherwise, Magento will not show the add to cart button and will not let you buy the product. This alone would maybe not be a problem if you could configure Magento not to set the product to Out of Stock each time it is ordered and falls below the Qty for Item's Status to Become Out of Stock barrier. But this is not possible. For the smart guys out here: No, it is also not possible to set this setting to a quantity below 0 via the admin settings.

Possibilities:

  1. You could fix the issue that the product is set to Out of Stock by fixing the config entry in the database: UPDATE `core_config_data` SET `value` = '-9999' WHERE `path` = 'cataloginventory/item_options/min_qty';. Although this then applies to all products, not only to the ones which are configured for backorders.
  2. You could try one of the "Preorder" or "Backorder" extensions.
  3. You could set the product to In Stock manually each time such an order occurs (of course only possible for very rare cases).
6
  • I appreciate the answer and I as you pointed out I am not alone. I do not want to pay for an extension, I'm positive that someone out there will chime in with the solution since this affects anyone running magento.
    – SR_Magento
    Commented Aug 13, 2014 at 19:35
  • I doubt it, because I think it is a major intrusion at a critical part of the system. And the extensions are not really expensive. But anyway, of course you can leave it open and look what happens :) Cheers
    – Simon
    Commented Aug 14, 2014 at 6:17
  • 1
    I have no issue purchasing extensions and have purchased many; my issue is that there should be no reason for this configuration not to work. Why would there be options to allow back orders and no way to allow them? SR
    – SR_Magento
    Commented Aug 14, 2014 at 12:14
  • I totally agree! I pinged some Magento community guys. Let us see if this helps :)
    – Simon
    Commented Aug 14, 2014 at 12:23
  • Appreciate it, wish I could give you another plus 1 :)
    – SR_Magento
    Commented Aug 14, 2014 at 12:39
8

Solution

After much, much testing here is how you can have the Add to cart button appear on products that are Out of stock.

  1. Set System->Configuration->Catalog->Inventory->Backorders=Allow Qty Below 0
  2. Set System->Configuration->Catalog->Inventory->Stock Options->Display Out of Stock Products=Yes
  3. Since Magento will not allow you to change the Qty for Item's Status to Become Out of Stock option to go bellow 0 (cannot put a negative value) it is necessary to run the following SQL statement from your phpmyadmin panel:

    UPDATE core_config_data SET value = '-1' WHERE path = 'cataloginventory/item_options/min_qty';

  4. Verify the setting has been added: System->Configuration->Catalog->Inventory verify that Qty for Item's Status to Become Out of Stock is now -1 (negative one)

  5. Set all store products to In stock: Catalog->Manage Products, Select all products -> Select "Actions"->Update Attributes -> Submit, Select Inventory -> Stock Availability = In Stock -> SAVE

  6. Re-index all indexes.

  7. Now that all products are In Stock and we now have a new rule for that will only set the products Out of stock when the value goes bellow zero (our setting is -1 [minus one]) it is now necessary to modify the theme in the front end.

list.phtml and view.phtml both contain IF statements that create a condition that if the product is "In Stock" then display the Add to cart, this needs to be removed now that the site has been modified in order to display for all products.

Example:

This code

<div class="add-to-box">
  <?php if($_product->isSaleable()): ?>     
  <?php echo $this->getChildHtml('addtocart') ?>
  <?php endif; ?>
</div>

Becomes this

<div class="add-to-box">
<?php echo $this->getChildHtml('addtocart') ?>
</div>

An alternative way to display out of stock and In stock using QTY and not stock status:

<?php $_product = $this->getProduct() ?>
<?php if((int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty() < 1): ?>
<p><strong>
  <?php echo $this->__('Out of stock') ?>
</strong></p>
<?php else: ?>
<p>
  <?php echo $this->__('In Stock')?>
</p>
<?php endif; ?> 

Very surprised that it is this time consuming to allow visitors to purchase products that are out of stock. Hope this helps someone and you won't need to use your bounty to get it done.

4
  • See @TBI-Infotech's answer. That's the correct way to do it. Attempting to hack Magento with your config update is only going to cause you problems in the future. Commented Sep 2, 2015 at 2:35
  • @JoeConstant look at the date and time of the post - your 2 years late. At the time this WAS the best way to achieve this. Thanks for the down vote! I highly suggest you READ and take everything into considerations before voting.
    – SR_Magento
    Commented Sep 2, 2015 at 10:45
  • Even 2 years ago that would not be an acceptable solution. Commented Sep 2, 2015 at 12:11
  • Whatever makes you feel better :)
    – SR_Magento
    Commented Sep 2, 2015 at 23:37
2

There is an option available in admin.

Just go to your manage product page and in inventory tab you can find

Backorders dropdown

, choose allow quantity below 0 option and save, now customer can order out of stock product also.

1

You also need to configure your store to display out of stock products:

Go to System > Configuration > Catalog | Inventory > Stock Options and set Display Out of Stock Products to Yes

7
  • This is already set and is not displaying the add to cart button. Thanks for the quick reply, let me know if you think of anything else :)
    – SR_Magento
    Commented Aug 10, 2014 at 16:24
  • As the last option you can set "manage stock" to "no" for the product.
    – Amasty
    Commented Aug 10, 2014 at 16:25
  • @Amasty this indicates incorrectly indicates that the product is in stock when it is not. I'm surprised that this isn't an easy fix.
    – SR_Magento
    Commented Aug 10, 2014 at 16:31
  • Some webshops use custom stock statuses for this. You can modify your view.phtml to warn customers. And yes, handling backorders or preorders is tricky in magento, that is why there are many extensions for this.
    – Amasty
    Commented Aug 10, 2014 at 16:52
  • I'll give it some time - hopefully someone can come up with something thanks :)
    – SR_Magento
    Commented Aug 10, 2014 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.