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/
Related
I am trying to create a theme with Magento Blank as parent in Magento 2 but I can't figure it out how to change the header with a custom one.
I first remove header.container from magento blank and create my container but it is created inside page-wrapper between main-content and footer and I can't make it go before main-content.
This is my layout.xml:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="register-link" remove="true" />
<referenceBlock name="authorization-link" remove="true" />
<referenceBlock name="wish-list-link" remove="true" />
<referenceBlock name="my-account-link" remove="true" />
<referenceBlock name="top.links" remove="true" />
<referenceBlock name="header.panel.wrapper" remove="true" />
<referenceBlock name="header.container" remove="true" />
<referenceContainer name="page.wrapper">
<container name="custom.header" htmlClass="headerSection" htmlTag="div">
<block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/sections.phtml">
</block>
</container>
</referenceContainer>
</body>
</page>
And this is how it looks the HTML:
I want to remove navbar from a custom magento admin panel popup. I have already removed header and footer, but can not remove navbar panel.
Please help
<remove name="footer" />
<remove name="header" />
<remove name="top.menu" />
<remove name="top.links" />
<remove name="top.container" />
<reference name="content">
<remove name="nav-bar" />
<remove name="header" />
<block type="core/template" name="xyz" template="abc/test/test.phtml" />
</reference>
Simple way,But I don't know this is better way or not but it's working.
Go to
C:\Xampp\htdocs\your project\app\design\adminhtml\default\default\template\page\menu.phtml
Then comment or delete the menu like as below
<div class="nav-bar">
<!-- menu start -->
<?php //echo $this->getMenuLevel($this->getMenuArray()); ?>
<!-- menu end -->
<a id="page-help-link" href="<?php echo Mage::helper('adminhtml')->getPageHelpUrl() ?>"><?php echo $this->__('Get help for this page') ?></a>
<script type="text/javascript">$('page-help-link').target = 'magento_page_help'</script>
</div>
After changed the code please clear the cache.
Simple way for hide the top menu of admin panel in magento.
Please follow the below steps:
open file adminhtml.xml ;
Location : /app/code/core/Mage/Adminhtml/etc/adminhtml.xml
Note : It is core file so,please override this module(best way).
<!-- Custom work for hide admin menu links -->
<catalog translate="title">
<depends><config>HideMe</config></depends>
</catalog>
<system translate="title">
<depends><config>HideMe</config></depends>
</system>
<sales translate="title">
<depends><config>HideMe</config></depends>
</sales>
<promo translate="title">
<depends><config>HideMe</config></depends>
</promo>
<report translate="title">
<depends><module>HideMe</module></depends>
</report>
<customer translate="title">
<depends><module>HideMe</module></depends>
</customer>
<newsletter translate="title">
<depends><module>HideMe</module></depends>
</newsletter>
<cms translate="title" module="adminhtml">
<depends><module>HideMe</module></depends>
</cms>
<!--Custom work for hide admin menu links end-->
It's working fine.
Thanks
Pradeep kumar
I would like to change top links
in the default set magento display
My Account | My Wishlist | My Cart | Checkout | Log in
i need to change top link that to show My Account link only after when user is LogIn
thx for help
in customer.xml at your theme before it is look like
<default>
<!-- Mage_Customer -->
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
</reference>
</default>
<customer_logged_in>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action>
</reference>
</customer_logged_in>
Remove my account link from default tag to Customer_logged_in
Change it with
After change at customer.xml
<default>
<!-- Mage_Customer -->
<reference name="top.links">
</reference>
</default>
<!--
Load this update on every page when customer is logged in
-->
<customer_logged_in>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action>
</reference>
</customer_logged_in>
hope this will sure help you.
<customer_logged_in>
<reference name="top.links">
<action method="addLink" translate="label title">
<label>Your Account</label>
<url helper="customer/getAccountUrl" />
<prepare/>
<urlParams/>
<liParams>
<id>header-account-link</id>
</liParams>
<aParams/>
<beforeText/>
<afterText/>
</action>
</reference>
We can do that easily Suppose We need to show only My-Account link after sign In,
we have to override the authorization.phtml file in custom theme and we can put our logic based on our requirement.
app/design/frontend/Namespace/Custom theme/Magento_Customer/templates/account/link/ authorization.phtml
After overriding this file we can put our login -
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** #var \Magento\Customer\Block\Account\AuthorizationLink $block */
$objectManagerlogin = \Magento\Framework\App\ObjectManager::getInstance();
$baseurl = $objectManagerlogin->get('Magento\Store\Model\StoreManagerInterface')->getStore(0)->getBaseUrl();
$dataPostParam = '';
if ($block->isLoggedIn()) {
$dataPostParam = sprintf(" data-post='%s'", $block->getPostParams());
}
?>
<?php if($block->isLoggedIn() && $baseurl || $block->isLoggedIn() ) : ?>
<li class="authorization-link" >
Sign Out
</li>
<li class="authorization-link custom-top-link-myaccount-mobile" >
My Account
</li>
<?php else : ?>
<li class="authorization-link" data-label="<?= $block->escapeHtmlAttr(__('or')) ?>">
<a <?= /* #noEscape */ $block->getLinkAttributes() ?><?= /* #noEscape */ $dataPostParam ?>>
<?= $block->escapeHtml($block->getLabel()) ?>
</a>
</li>
<?php endif; ?>
I hope this will help you in Magento2, for managing my account section based own need
The Magento checkout has a line that show the totals in the file:
frontend/base/default/template/checkout/onepage/review/info.phtml
<?php echo $this->getChildHtml('totals'); ?>
But this line shows also the shipping method if customer choose a freight method and I didn't find this to take it of my total page, I know that I can't delete it from the database because this information is used in the freight choice.
For removing this data from the total you need to override the following classes:
To hide it in shopping cart page:
Mage_Sales_Model_Quote_Address_Total_Shipping::fetch() method needs to be overridden via custom module:
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
$originalShippingDescription = $address->getShippingDescription(); // Keep old description value
$address->unsShippingDescription(); // Removes description of shipping method
parent::fetch($address);
$address->setShippingDescription($originalShippingDescription); // Sets back original description of shipping method
return $this;
}
To hide it on order overview pages in the user account, you need to perform another customization of Mage_Sales_Block_Order_Totals class. For this purpose you need to create a new block extended from Mage_Core_Block_Abstract
Create block in some your custom module
<?php
class Custom_Module_Block_Shipping_Total extents Mage_Core_Block_Abstract
{
public function initTotals()
{
if ($this->getParentBlock() && $this->getParentBlock()->getTotal('shipping')) {
$this->getParentBlock()->getTotal('shipping')->setLabel($this->__('Shipping & Handling'));
}
}
}
Add layout updates to include you block into order view.
<layout>
<!-- Your custom total on invoices view -->
<custom_invoice_totals>
<reference name="invoice_totals">
<block name="custom_total" type="custom_module/shipping_total" />
</reference>
</custom_invoice_totals>
<!-- Your custom total on shipments view -->
<custom_shipment_totals>
<reference name="shipment_totals">
<block name="custom_total" type="custom_module/shipping_total" />
</reference>
</custom_shipment_totals>
<!-- Your custom total on creditmemos view -->
<custom_creditmemo_totals>
<reference name="creditmemo_items">
<block name="custom_total" type="custom_module/shipping_total" />
</reference>
</custom_creditmemo_totals>
<!-- Applying your handles to particular pages in customer account -->
<sales_order_view>
<update handle="custom_order_totals" />
</sales_order_view>
<sales_order_print>
<update handle="custom_order_totals" />
</sales_order_print>
<sales_email_order_items>
<update handle="custom_order_totals" />
</sales_email_order_items>
<!-- applies your total in email -->
<sales_email_order_items>
<update handle="custom_order_totals" />
</sales_email_order_items>
<sales_guest_view>
<update handle="custom_order_totals" />
</sales_guest_view>
<!-- invoice pages -->
<sales_order_invoice>
<update handle="custom_invoice_totals" />
</sales_order_invoice>
<sales_order_printinvoice>
<update handle="custom_invoice_totals" />
</sales_order_printinvoice>
<sales_email_order_invoice_items>
<update handle="custom_invoice_totals" />
</sales_email_order_invoice_items>
<sales_guest_invoice>
<update handle="custom_invoice_totals" />
</sales_guest_invoice>
<!-- shipment pages -->
<sales_order_shipment>
<update handle="custom_shipment_totals" />
</sales_order_shipment>
<sales_order_printshipment>
<update handle="custom_shipment_totals" />
</sales_order_printshipment>
<sales_email_order_shipment_items>
<update handle="custom_shipment_totals" />
</sales_email_order_shipment_items>
<sales_guest_shipment>
<update handle="custom_shipment_totals" />
</sales_guest_shipment>
<!-- creditmemo pages -->
<sales_order_creditmemo>
<update handle="custom_creditmemo_totals" />
</sales_order_creditmemo>
<sales_order_printcreditmemo>
<update handle="custom_creditmemo_totals" />
</sales_order_printcreditmemo>
<sales_email_order_creditmemo_items>
<update handle="custom_creditmemo_totals" />
</sales_email_order_creditmemo_items>
<sales_guest_creditmemo>
<update handle="custom_creditmemo_totals" />
</sales_guest_creditmemo>
</layout>
After such customization on all pages on the frontend your shipping total will be without information about shipping method...
in your local cart.phtml, use following snippet:
<div class="cart-totals-wrapper">
<div class="cart-totals">
<div class="cart-totals-container">
<!-- <?php echo $this->getChildHtml('totals'); ?> -->
<?php
$_quote = Mage::getSingleton('checkout/session')->getQuote();
$_cartValue = 0;
$_items = $_quote->getAllItems();
foreach ($_items as $_item) {
$_cartValue += $_item->getRowTotalInclTax();
}
?>
<table id="shopping-cart-totals-table">
<colgroup>
<col>
<col width="1">
</colgroup>
<tbody>
<tr>
<td class="a-right" colspan="1" style=""><?php echo $this->__('Subtotal'); ?></td>
<td class="a-right" style="">
<span class="price"><?php echo $_quote->getStore()->formatPrice($_cartValue); ?></span>
</td>
</tr>
</table>
<p class="message"><?php echo $this->__('Shipping will be calculated at checkout'); ?></p>
</div>
i want to change the default value of a field in my admin panel.
an example of app/code/core/mage/page/etc/config.xml
<default>
<design>
<head translate="default_description" module="page">
<default_title>Magento Commerce</default_title>
<default_description>Default Description</default_description>
<default_keywords>Magento, Varien, E-commerce</default_keywords>
<default_robots>*</default_robots>
<default_media_type>text/html</default_media_type>
<default_charset>utf-8</default_charset>
<default_demonotice>1</default_demonotice><!--for example change this default value-->
</head>
<header translate="welcome" module="page">
<logo_src>images/logo.gif</logo_src>
<logo_alt>Magento Commerce</logo_alt>
<welcome>Default welcome msg!</welcome>
</header>
<footer translate="copyright" module="page">
<copyright>© 2008 Magento Demo Store. All Rights Reserved.</copyright>
</footer>
</design>
help please!
Look in system.xml files for the path
and in order to overwrite the value do
<default>
<module><set><field>some_value</field></set></module>
</default>