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.
1 Answer
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
-
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 NubMar 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
list.phtml
?