Magento – Check if product has custom options Magento 2

custom-optionsifmagento2

I want to display some text next to the price of a product if it has custom options. I have placed some code in final_price.phtml but it doesn't show the message on custom option products.

Can anyone please advise an update to the below to get this working?

<span class="special-price">
    /** Show text if has custom option */ <?php if ($block->hasOptions()):?>
        <?php echo ('from'); ?>
    <?php endif;?> /** Show text if has custom option */
    <?php /* @escapeNotVerified */ echo $block->renderAmount($finalPriceModel->getAmount(), [
        'price_id'          => $block->getPriceId('product-price-' . $idSuffix),
        'price_type'        => 'finalPrice',
        'include_container' => true,
        'schema' => $schema
    ]); ?>
</span>

Best Answer

Maybe you try sth like

$block->getSaleableItem()->getTypeInstance()->hasOptions($block->getSaleableItem());
Related Topic