WooCommerce - Remove downloads from menu in my account page - php

I would like to remove downloads menu from my account page.
How can I do this? Is it any hook to remove a specific item from the menu?
Thanks.

Go to WooCommerce > Settings > Advanced and remove the entry for Downloads in the Account endpoints section, just leave it blank. And the menu will not be visible anymore.

You will need this lightly customized this code snippet:
function custom_my_account_menu_items( $items ) {
unset($items['downloads']);
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'custom_my_account_menu_items' );
This code goes on function.php file of your active child theme (or theme) or in any plugin file.
This code is tested and working

[data-tab="downloads"] {
display: none!important;
}

Related

Show a menu Item based on specific User role in Woocommerce

I need help showing a specific menu item if user role is "Affiliate".
Menu Item is "Affiliate Dashboard"
Don't want to use any plugin for such task.
Site is under maintenance mode so I can't show the site, However I've attached screenshot.
Please take a look and help me out.
Thanks
The following code will hide "Affiliate Dashboard" menu item if the current user role is not "affiliate":
The code:
add_action( 'wp_head', 'show_hide_affiliate_menu_item', 500 );
function show_hide_affiliate_menu_item() {
if( ! current_user_can( 'yith_affiliate' ) )
echo '<style> .top-bar-nav #menu-item-11874 { display: none !important } </style>';
}
Code goes in function.php file of your active child theme (or active theme). It should work.
Just write a if condition for do this..Example
if(Auth::user()->has('Affiliate')) {
Affiliate Dashboard
}
But it's only possible when your user have assigned specific role

Remove a sub heading text under products page title in OceanWP theme

I am trying to figure out how to change/remove the text under "Products (Varer)" on my Wordpress woocommerce website like in this screenshot:
Any help is appreciated.
According to OceanWP's docs, you can add this function to your functions.php file of the child theme to remove the subheading:
// Remove the Shop page subheading
function my_remove_shop_page_header_subheading( $subheading ) {
if ( is_shop() ) {
$subheading = false;
}
// Return the subheading
return $subheading;
}
add_filter( 'ocean_post_subheading', 'my_remove_shop_page_header_subheading' );
Alternatively, you can add one line of extra css to your website (tested and worked):
.clr .page-subheading {display: none}
Follow this steps to edit/remove sub heading.
Go to Pages > select shop page > Edit.
Under Ocean WP settings choose Title.
Enter your desired subheading or a single space in case you want to remove that altogether.
Note: A single space would remove that line altogether, won't create an empty line as of now.
I am not sure if that would change with theme/plugin updates, but is a good option if you have not created child theme. In case you have created a child theme have a look here: https://docs.oceanwp.org/article/500-remove-the-shop-page-subheading

Hide general and shipping details when adding a new order in Woocommerce admin

In the admin page when you press "add new order" there is General Details, Billing Details and Shipping Details:
I would love to hide some these with CSS. I've tried all day but have been able to achieve this unsuccessfully.
I just want to keep the Billing details visible. Is that possible?
This can be done simply with the following hooked function and some specific CSS rules:
add_action('admin_head', 'my_admin_head');
function my_admin_head() {
?>
<style>
.post-new-php.post-type-shop_order #postbox-container-2 .order_data_column_container > .order_data_column:first-child,
.post-new-php.post-type-shop_order #postbox-container-2 .order_data_column_container > .order_data_column:last-child {
display:none !important;
}
</style>
<?php
}
Code goes in function.php file of your active child theme (or active theme).
Tested and works…

Replacing Woocommerce Storefront header with a shortcode

I am using Woocommerce Storefront theme and I want to replace the original header with a custom header that I created in elementor. I have a shortcode for the new header but I don't know how to insert it into the code. I am using a blank storefront child theme and there is a function.php file and style.css file.
Thanks for the help.
Just copy the header.php from the parent theme and paste it inside the child theme. Then you can already put your custom code in it.
Reference: codex.wordpress.org/Child_Themes
You can do this in your child theme by using a hook on init
Something like this:
add_action('init', 'replace_header' );
function replace_header(){
remove_action( 'storefront_header', 'storefront_primary_navigation', 50 );
add_action('storefront_header', 'my_custom_header', 50);
}
function my_custom_header(){
do_shortecode('[your_elementor_header_shortcode attr1="value1"]')
}

How to place content from function in My Account in Woocommerce?

Hi i have this function inserted into functions.php in my theme:
function woocommerce_after_account_navigation(){
$html = '<h3>Title</h3>';
$html.='<li>Text1</li>';
$html.='<li>Text2</li>';
echo $html;
}
and have placed this hook into navigation.php file from WooCommerce templates
<?php do_action( 'woocommerce_after_account_navigation' ); ?>
but seems that dont show nothing from content that i placed into functions.php
Can someone help me what is wrong with this hook ?
Youn don't need to change anything in the My account templates (as you are using an existing hook)… To get your custom content displayed, you should need to make it this way:
add_action( 'woocommerce_after_account_navigation', 'custom_content_after_account_navigation' );
function custom_content_after_account_navigation(){
$html = '<h3>Title</h3>';
$html.='<li>Text1</li>';
$html.='<li>Text2</li>';
echo $html;
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested on WooCommerce 3 and works.
This custom content will be displayed below the My Account Menu

Categories