Q:

Magento 2 - Check if static block is enabled

On my Magento 2 store I have a static block that outputs a message to inform customers that the prices are not currently available. On my template files I'd like to wrap the prices and Add to Cart buttons to an if/else statement, so those elements are not created if that static block is enabled:
if ( 'static block "disable_store" is active' ) {
    echo "No prices available at this time";
} else {
    ... show the price etc ...
}

The bit I can't figure out is what to put on the if line. Please note that I don't want to output the contents of the block here, just to check if it's enabled or not.

A:

Not need to check the if the block is enabled or not because magento2's toHtml() always return the html when static block is enabled. You can use the below code for checking:
$html = $this->getLayout()
->createBlock('Magento\Cms\Block\Block')->setBlockId(BLOCK_ID)->toHtml();

if($html){
    echo "No prices available at this time";
}
else{
    ... show the price etc ...
}

