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.
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.
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>
Step 1: First of all, you need a create customer_account.xml in your theme in:
app/design/frontend/_YOUR_VENDOR_/_YOUR_THEME_/Magento_Customer/layout/customer_account.xml
Step 2: Add Remove the link to the file:
To shorten and simplify the story, in the example below I will immediately show you how to delete all links from the navigation one by one.
<!-- Store credit -->
<referenceBlock name="customer-account-navigation-customer-balance-link" remove="true"/>
<!-- Downloadable product link -->
<referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/>
<!-- Subscription link -->
<referenceBlock name="customer-account-navigation-newsletter-subscriptions-link" remove="true"/>
<!-- Billing agreement link -->
<referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>
<!-- Product review link -->
<referenceBlock name="customer-account-navigation-product-reviews-link" remove="true"/>
<!-- My credit card link -->
<referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>
<!-- Account link -->
<referenceBlock name="customer-account-navigation-account-link" remove="true"/>
<!-- Account edit link -->
<referenceBlock name="customer-account-navigation-account-edit-link" remove="true"/>
<!-- Address link -->
<referenceBlock name="customer-account-navigation-address-link" remove="true"/>
<!-- Orders link -->
<referenceBlock name="customer-account-navigation-orders-link" remove="true"/>
<!-- Wish list link -->
<referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>
<!-- Gift card link -->
<referenceBlock name="customer-account-navigation-gift-card-link" remove="true"/>
<!-- Gift registry -->
<referenceBlock name="customer-account-navigation-giftregistry-link" remove="true"/>
<!-- Reward points -->
<referenceBlock name="customer-account-navigation-reward-link" remove="true"/>
<!-- Order by SKU -->
<referenceBlock name="customer-account-navigation-checkout-sku-link" remove="true"/>
Please view more detail in https://inchoo.net/magento-2/managing-my-account-navigation-links-magento-2/