I've got a simple block that I'm using to add a button directly next to "Add to Cart"

<referenceBlock name="product.info.addtocart">
    <block class="Magento\Framework\View\Element\Template" template="Vendor_Module::product/view/button.phtml" ifconfig="vendor/module/enable" before="product.info.addtocart.instantPurchase"/>

The biggest problem I have is that the block product.info.addtocart is not shown when the product is out of stock, but i still wish my button to appear.

If I move the button to product.info.form.content then button appears on all products, but falls outside the add-to-cart container and loses it's CSS properties, and is displayed on a new line from "Add to Cart" instead of next to it.

2 Answers 2


The add to cart button is not shown when the product is out of stock because of your settings.

You can change your settings in the back-end of Magento under Stores -> Configuration -> Catalog -> Inventory

Here you will find the option Backorders and that is set to No and you can change that to "Allow Qty below 0". Now customers can order the product even tough it is out of stock.

Notice that you can also set "Manage Stock" to "No" if you don't use stock.

If you don't want to set this setting globally you can also set these settings per product in the back-end by opening each product separately and click on "Advanced Inventory" under Quantity.

  • Hi Riccardo, thanks for this but this isn't what I'm looking for. We use backorders for products that we know we can source from the supplier, but if a customer visits a product that is genuinely out of stock, we'd at least like the button shown, as we're using it to still generate a sales lead. Commented Jan 4, 2021 at 13:13

The easiest answer I found was to create a second block called in product.info.form.content with an if statement on $product->isSalable()

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.