5

On a Configurable product, the following gets displayed if the Configurable product has stock /is saleable. However, when one of the items in the dropdown of Simple products is actually out of stock the following is not correct.

<?php if ($this->displayProductStockStatus()): ?>
    <?php if($_product->isSaleable()): ?>
        <p class="availability in-of-stock">Availability: <span><?php echo $this->__('In stock') ?></span></p>
    <?php else : ?>

    <?php endif; ?>
<?php endif; ?>

What i'm trying to do is get that In stock text to change to out of stock when the out of stock product is selected. I wondered if anyone else has tried fixing this magento bug before?

  • Do you mean dynamically, e.g. using Javascript? – Robbie Averill Mar 10 '16 at 20:41
0

As doubleplusgood suggested, this functionality is controlled by Javascript and not PHP. In a default 1.9.3 install running RWD as the theme, when you click on a configurable product's simple product option swatch that is in stock, you get this result:

enter image description here

When you select a swatch for a product that is out of stock, you get this:

enter image description here

So while the code you posted is for a check against the stock of the product, it does not control the status for the a configurable product that has some simples with and without stock. The logic that controls that functionality (disabling the add to cart button and changing the 'out of stock' text) is in this file:

rwd/default/js/configurableswatches/swatches-product.js

So given that information I would take two guesses to what might be causing your issue.

  1. You have some kind of javascript error, the file is not loading correctly or you are using a custom template that doesn't have the correct class name for the HTML element that the javascript is targeting.

  2. You have a setting in the admin that allows for products that are out of stock to still be sold (system-> config-> catalog-> inventory). Check these settings as they can override what the theme might be doing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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