0

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

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

1 Answer 1

1

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>
                </div>
            <?php else: ?>
                <div class="stock unavailable" title="<?= /* @escapeNotVerified */ __('Availability') ?>">
                    <span><?= /* @escapeNotVerified */ __('Out of stock') ?></span>
                </div>
            <?php endif; ?>
        <?php endif; ?>

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

2
  • 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, 2018 at 8:43
  • wow! thank you very much @naveed-asim. so save my day. many times I struggled in xml to move its position, it turns out that there is this simple way. Sep 19, 2021 at 0:30

Your Answer

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

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