cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Attribute for Backorders in Product View Page

Custom Attribute for Backorders in Product View Page

I would like to print a custom attribute on the product view page, when the product quantity is 0 or less (with active backorders).

 

I have:

<?php $_product = $block->getProduct() ?>

 <?php if($_product->isSaleable()): ?>
<?php echo("")?>

<?php else: ?>
<?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getCustomAttribute (), 'custom_attribute'); ?>
<?php endif; ?>

the code works if I put the status of the inventory Not Available, but the ADD TO CART button disappears.

 

It would be possible to replace this:

<?php if($_product->isSaleable()): ?>

with something like that?

<?php if($_product->getQty() < 0 ): ?>

 

could you help me? Many Thanks

 

(or, another solution could be to always activate the key ADD TO CART.)