客户群一般时如何从客户菜单中删除链接?我知道 ifconfig 标签,但是当客户在一般组中时,我无法隐藏自定义链接。我使用 Magento 2.2.4。
问问题
1766 次
2 回答
1
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
}
//布局
<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>
于 2018-07-24T06:46:54.140 回答
0
第1步:首先,您需要在您的主题中创建customer_account.xml:
app/design/frontend/_YOUR_VENDOR_/_YOUR_THEME_/Magento_Customer/layout/customer_account.xml
第 2 步:添加删除文件的链接:
为了缩短和简化故事,在下面的示例中,我将立即向您展示如何从导航中删除所有链接。
<!-- 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"/>
请在https://incho.net/magento-2/managing-my-account-navigation-links-magento-2/中查看更多详细信息
于 2018-07-20T11:01:10.737 回答