PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 22, 2022

[FIXED] How remove link from customer menu when customer in general group?

 August 22, 2022     magento, magento2, magento2.2     No comments   

Issue

How do I remove a link from customer menu when customer group is general?

I know about the ifconfig tag, but it does not give me the possibility to hide a custom link when a customer in the general group.

I use Magento 2.2.4.

Customer menu


Solution

class Current extends \Magento\Framework\View\Element\Html\Link\Current //block
{
    /**
     * @return string
     */
    public function toHtml()
    {
        if (SOME CONDITION HERE) {
            return parent::toHtml(); //show link
        }

    return ''; //hide link
}

//Layout

<referenceBlock name="customer_account_navigation">
        <block class="...\Current" name="customer-account-navigation-product">
            <arguments>
                <argument name="path" xsi:type="string">.../index</argument>
                <argument name="label" xsi:type="string">Product</argument>
            </arguments>
        </block>
    </referenceBlock>


Answered By - Andry
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing