Check the user logged in or Not in a custom block layout

To work out the customer id and customer details in a custom module we need to call a reference container in the layout page.

Here an example showing a reference container of custom Quote Block

        <referenceContainer name="content">
            <block class="JJ\Quote\Block\Quoteblock" name="my_tab" template="JJ_Quote::quote.phtml" cacheable="false"> </block>
        </referenceContainer>

Use Cacheable to fetch each customer logged in or not and get the customer Id to custom module.

public function newFunction()
{
    $section = $this->customerSession;
    if($section->isLoggedIn()) {
$customer = $section->getCustomer();
$inactive = $customer->getData('customer_status');
}

Leave a comment

Your email address will not be published. Required fields are marked *