My want is to move the "In stock" part in between the "Qty" and "Add to Cart" button; However this is made hard by the fact that these two components are in the same template and not wrapped in a container or block, so I can't use the xml to move the "stock" before or after these elements.

What would be a good approach to get this result? the content in the green square, moved to where the red line is

  • Why you don't want edit list.phtml? – Evgeny Levinsky Mar 15 '18 at 16:29
  • Hello @Evgeny, image is for product view page. – Pawan Mar 15 '18 at 16:33

Open product/view/addtocart.phtml file of your theme and add below code snippet between qty and action button div :

<?php if ($block->displayProductStockStatus()): ?>
            <?php if ($_product->isAvailable()): ?>
                <div class="stock available" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
                    <span><?= /* @escapeNotVerified */ __('In stock') ?></span>
            <?php else: ?>
                <div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
                    <span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
            <?php endif; ?>
        <?php endif; ?>

it will show stock availability status between qty and add to cart button

  • That actually did it; I was afraid this might conflict with removing it in the .xml but not calling the child html must mean it stays there separately. Thanks Naveed! – Nub Nub Mar 16 '18 at 8:43

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.