วิธีลบลิงก์ "ข้อตกลงการเรียกเก็บเงิน" และ "รายการโปรดของฉัน" จากเมนูนำทางในหน้าบัญชีลูกค้า
วิธีลบลิงก์ "ข้อตกลงการเรียกเก็บเงิน" และ "รายการโปรดของฉัน" จากเมนูนำทางในหน้าบัญชีลูกค้า
คำตอบ:
เพิ่มตัวจัดการเลย์เอาต์ใหม่ไปยังหนึ่งในสถานที่:
VendorName/ModuleName/view/frontend/layout/customer_account.xmlapp/design/frontend/VendorName/themeName/Magento_Wishlist/layout/customer_account.xml(และเลย์เอาต์ที่คล้ายกันสำหรับโมดูลข้อตกลงการเรียกเก็บเงิน)เนื้อหาการจัดการเลย์เอาต์:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>
        <referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>
    </body>
</page>app/designดูเหมือนจะเป็นสถานที่ที่ดีสำหรับนักพัฒนาธีม
                    รายการการลบ XML บัญชีลูกค้าเต็มรูปแบบสำหรับ M2 มันจะมีประโยชน์สำหรับนักพัฒนาอื่น ๆ ที่พยายามลบลิงค์อื่น ๆ ฉันคิดว่าเป็นความคิดที่ดีที่จะให้มีข้อมูลเพิ่มเติมสำหรับนักพัฒนารายอื่น
<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <!-- Remove unwanted account navigation links -->
        <!-- Put this file in: app/design/frontend/[Namespace]/[Theme]/Magento_Customer/layout/customer_account.xml -->
        <!-- 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"/>
        <!-- Order by SKU -->
        <referenceBlock name="customer-account-navigation-checkout-sku-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"/>
    </body>
</page>customer-account-navigation-delimiter-1และcustomer-account-navigation-delimiter-2เป็นชื่อของส่วนที่ว่าง / ตกแต่ง - ตัวคั่น aka
                    app/code/<Vendor>/<Module>/view/frontend/layout/customer_account.xmlจะไม่ทำงานถ้าผมสร้างโครงสร้างเป็น ฉันมีโฟลเดอร์ธีมแยกต่างหาก
                    ในการติดตั้งผู้วิเศษของฉัน (รุ่นพาณิชย์ 2.2.2) มีลิงค์อื่น:
<!-- Invitations -->
<referenceBlock name="customer-account-navigation-magento-invitation-link-container" remove="true"/>ฉันเพิ่ม CSS ต่อไปนี้เพื่อซ่อนแท็บข้อตกลงการเรียกเก็บเงินในหน้าบัญชีลูกค้าของฉัน มีวิธีที่ดีกว่าในการทำตามที่กล่าวถึง แต่วิธีนี้ง่ายและรวดเร็ว!
nav.account-nav li.nav.item [href * = "billing_agreement"] {display: none;}
คุณสามารถทำสิ่งเดียวกันกับ Wishlist หรือลิงค์อื่น ๆ ที่คุณต้องการลบ เพียงกำหนดเป้าหมายองค์ประกอบโดยใช้ตัวเลือกดังที่อธิบายไว้ที่นี่: https://www.w3schools.com/cssref/css_selectors.asp
ตอนแรกฉันซ่อนลิงก์ในบัญชีลูกค้า MENU โดยใช้ CSS ตามที่ #Cristina พูดถึงเพราะฉันคิดว่าการแก้ปัญหาด้วย xml จะลำบากมาก
แต่มันก็ไม่ซับซ้อนเลย คุณเพียงแค่ต้องเลือกลิงค์ที่คุณต้องการลบ
มีความสำคัญอะไร: โดยดูที่แหล่งที่มาของรหัสของหน้า - ไม่มีลิงก์ไปที่ตรงข้ามกับโซลูชัน CSS (แสดง: ไม่มี;)
ลบลิงก์บัญชีลูกค้าที่ไม่จำเป็นใน Magento 2 เพื่อจัดการส่วน "บัญชีของฉัน"
ได้รับการแก้ปัญหาการเขียนโปรแกรมที่https://meetanshi.com/blog/remove-unnecessary-customer-account-links-in-magento-2/
<referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>(2) ใช้ปลั๊กอินเห็นgithub.com/magepal/magento2-customer-account-links-manager