cancel
Showing results for 
Search instead for 
Did you mean: 

Display expected delivery time if not in stock

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Display expected delivery time if not in stock

Hello

I'm searching for a solution to display the expected delivery time if something is not in stock.

It should be only a text label (supporting multilanguage)

eg. "expected delivery in 1-2 weeks" or "expected delivery in 3-4 weeks"

 

It should show up somewhere in the area where the article price and the buy button is. - but only if stock qty is below 1

 

Does anybody know a way how to easily achieve that or a plugin which achieves that?

 

Regards

Patrick

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Display expected delivery time if not in stock

I found a easy solution to do it.

 

I created a attribute which is included in default set. There i have all my delivery times in all languages.

 

and then copied:

vendor/magento/module-catalog/view/frontend/templates/product/view/type/default.phtml

to:

app/design/frontend/{Package}/{theme}/Magento_Catalog/templates/product/view/type/default.phtml

& now instead of the "out of stock" label i just display my custom attributes text 'est_shippingtime':

<?php /* @var $block \Magento\Catalog\Block\Product\View\AbstractView */?>
<?php $_product = $block->getProduct() ?>

<?php if ($block->displayProductStockStatus()) :?>
    <?php if ($_product->isAvailable()) :?>
        <div class="stock available" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
            <span><?= $block->escapeHtml(__('In stock')) ?></span>
        </div>
    <?php else :?>
        <div class="stock unavailable" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
            <span><?= $_product->getAttributeText('est_shippingtime'); ?></span>
        </div>
    <?php endif; ?>
<?php endif; ?>

& don't forget to configure magento to show the stock status, otherwise it's not displayed

 

 

 

View solution in original post

1 REPLY 1

Re: Display expected delivery time if not in stock

I found a easy solution to do it.

 

I created a attribute which is included in default set. There i have all my delivery times in all languages.

 

and then copied:

vendor/magento/module-catalog/view/frontend/templates/product/view/type/default.phtml

to:

app/design/frontend/{Package}/{theme}/Magento_Catalog/templates/product/view/type/default.phtml

& now instead of the "out of stock" label i just display my custom attributes text 'est_shippingtime':

<?php /* @var $block \Magento\Catalog\Block\Product\View\AbstractView */?>
<?php $_product = $block->getProduct() ?>

<?php if ($block->displayProductStockStatus()) :?>
    <?php if ($_product->isAvailable()) :?>
        <div class="stock available" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
            <span><?= $block->escapeHtml(__('In stock')) ?></span>
        </div>
    <?php else :?>
        <div class="stock unavailable" title="<?= $block->escapeHtmlAttr(__('Availability')) ?>">
            <span><?= $_product->getAttributeText('est_shippingtime'); ?></span>
        </div>
    <?php endif; ?>
<?php endif; ?>

& don't forget to configure magento to show the stock status, otherwise it's not displayed