Skip to content

Validate if render referenceBlock in checkout layout

I have tried validate if render referenceBlock in checkout layout, but it does not work.

I added block VendorModuleBlockIndex in layout after referenceBlock

Vendor/Module/view/frontend/layout/checkout_index_index.xml

<referenceBlock name="checkout.root">
        <block class="ElTiempoEfectyBlockIndex" name="is_book">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="steps" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="billing-step" xsi:type="array">
                                            <item name="component" xsi:type="string">uiComponent</item>
                                            <item name="children" xsi:type="array">
                                                <item name="payment" xsi:type="array">
                                                    <item name="children" xsi:type="array">
                                                        <item name="renders" xsi:type="array">
                                                            <!-- merge payment method renders here -->
                                                            <item name="children" xsi:type="array">
                                                                <item name="efecty" xsi:type="array">
                                                                    <item name="component" xsi:type="string">Vendor_Module/js/view/payment/method-renderer</item>
                                                                    <item name="methods" xsi:type="array">
                                                                        <item name="efecty" xsi:type="array">
                                                                            <item name="isBillingAddressRequired" xsi:type="boolean">true</item>
                                                                        </item>
                                                                    </item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </block>
    </referenceBlock>

In block validate if render with _toHtml() method

Vendor/Module/Block/Index.php

namespace ElTiempoEfectyBlock;

class Index extends MagentoFrameworkViewElementTemplate
{

    /**
     * Render block HTML
     *
     * @return string
     */
    protected function _toHtml()
    {
        $isBook = true;

        if ($isBook) {
            return parent::_toHtml();
        }
        return '';
    }
}

Any ideas would be the error?

Thanks!