I want to remove the additional tab from checkout step.I tried the followoing code ,its remove the notes field but the tab still exist.
add_filter( 'woocommerce_checkout_fields' , 'bbloomer_remove_checkout_order_notes' );
function bbloomer_remove_checkout_order_notes( $fields ) {
unset($fields['order']['order_comments']);
return $fields;
}
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
I tried by using css.That hide the tab and its data but didn't move the tab to next on click.So i think it will be good if i found some filter type code.Thanks
Related
I want to remove, for shop-managers, the ability to mark an order as completed. To do so, I used the following based on "Hide a specific action button conditionally in Woocommerce admin Orders list" answer in my theme's functions.php file:
add_filter( 'woocommerce_admin_order_actions', 'custom_admin_order_actions', 900, 2 );
function custom_admin_order_actions( $actions, $the_order ){
if(isset(wp_get_current_user()->roles[0]) && wp_get_current_user()->roles[0] == 'shop-manager')
unset($actions['complete']);
return $actions;
}
By this, I succesfully removed the complete button from the shop_order page. However, the shop-manager is still able to complete the order using the Complete button that appears in the order preview. To avoid this, I tried the next action after the previous one:
add_action( 'woocommerce_admin_order_preview_start', 'custom_display_order_data_in_admin' );
function custom_display_order_data_in_admin(){
// Call the stored value and display it
echo '<div>Class = "button hidden wc-action-button wc-action-button-complete complete"</div><br>';
}
However, this does not remove the button from the preview window because it does not substitute the line in the code.
Is there a way to remove this ability from the shop_order page and the order preview at once? If not, how can I hide this button from the preview window?
To remove the "complete" update order status button from admin order preview for "Shop manager" user role, use the following:
add_filter( 'woocommerce_admin_order_preview_actions', 'filter_admin_order_preview_actions', 10, 2 );
function filter_admin_order_preview_actions( $actions, $order ) {
if( current_user_can('shop-manager') && isset($actions['status']['actions']['complete']) ) {
unset($actions['status']['actions']['complete']);
}
return $actions;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Two things I am trying to do on the product pages of this website: https://lovesometea.com/product/green-coconut/
1) Delete "additional information" tab
2) Add Attribute "Size" above the product description
To delete the "additional information" tab, I have been following this: https://idevie.com/tutorials/how-to-make-woocommerce-product-attributes-more-prominent
So this is what I did:
1) Added a custom plug-in and activated it - http://code.tutsplus.com/tutorials/making-woocommerce-product-attributes-more-prominent--cms-25438
2) Tried removing "additional information" by editing the tabs.php in /wp-content/plugins/woocommerce/templates/single-product/tabs
/**
* Removes the "Additional Information" tab that displays the product attributes.
*
* #param array $tabs WooCommerce tabs to display.
*
* #return array WooCommerce tabs to display, minus "Additional Information".
*/
function tutsplus_remove_product_attributes_tab( $tabs ) {
unset( $tabs['additional_information'] );
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'tutsplus_remove_product_attributes_tab', 100 );
This is where I'm stuck. I even tried deleting the additional-information.php file all together (in the same tabs folder) and additional information still displays!
I tried putting the above code in three different areas of the tabs.php file but no effect on the tab on the product page.
Any other suggestions? Perhaps there is a different/better method with the latest woocommerce version?
This worked for me for removing the tabs:
Adding this in functions.php:
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
To return the attributes to display under description, I couldn't figure it out so I just added the sizes in the description
Maybe you need to change the priority from 100 to 98 as in woocommerce documentation , put the code in functions.php file
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
I can unset fields from billing and shipping but why I can't unset fields from additional field section. I am adding a condition on these fields. Maybe I am using wrong meta keys.
function wc_remove_checkout_field( $fields ) {
unset( $fields['billing']['test_field'] ); //this one working
unset( $fields['additional']['delivery_time'] ); //this one not even if I replace additional with order.
return $fields;
}
add_filter( 'woocommerce_checkout_fields' , 'wc_remove_checkout_field' );
Creating fields usings this plugin WooCommerce Checkout Field Editor
You can use this filter to remove the order notes field:
add_filter('woocommerce_enable_order_notes_field', '__return_false');
If you want to stick with your method using unset, you need to replace "additional" with "order":
unset($fields['order']['order_comments']);
I am trying to remove the password field in the checkout page.
Here is what I have tried (code is in my functions.php theme file):
// Hook in
add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
// Our hooked in function - $address_fields is passed via the filter!
function custom_override_default_address_fields( $address_fields ) {
$checkout_fields['account']['required'] = false;
return $checkout_fields;
}
But it didn't work.
What is the hook for removing the password field in woocommerce checkout page?
Thanks.
The hook woocommerce_default_address_fields is only used for default address fields and not for the account fields.
To make the passwords fields optional you should need using woocommerce_checkout_fields hook, this way:
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
// There is 2 password fields
fields['account']['account_password']['required'] = false;
fields['account']['account_password-2']['required'] = false;
return $fields;
}
To remove those passwords fields you should need to use unset() PHP function this way:
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['account']['account_password']);
unset($fields['account']['account_password-2']);
return $fields;
}
But I am not sure that is really possible, as it's something mandatory in WooCommerce checkout process, when you have enabled the option to register in checkout pageā¦
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Official Reference: Customizing checkout fields using actions and filters
the products in our woocommerce shop don't need any of the default tabs so I have managed to disable them being that I only need to have the product description below the product however, while I want to keep the actual description, I believe the tab itself is redundant since there aren't any other tabs.
Basically, I want to remove the tab's & title altogether but keep the content box below it without modifying the woocommerce core php template file. Is there a way to add a filter to my WordPress theme's functions.php?
function woocommerce_default_product_tabs( $tabs = array() ) {
global $product, $post;
// Description tab - shows product content
if ( $post->post_content ) {
$tabs['description'] = array(
'title' => __( 'Description', 'woocommerce' ),
'priority' => 10,
'callback' => 'woocommerce_product_description_tab'
);
}
While CSS is great, if the stylesheet doesn't load correctly, you could end up showing someone tabs without meaning to. It is best to remove the content before loading (server side), by using a filter, as you had mentioned.
See code below as provided from Woothemes for unsetting data tabs.
EDIT Place within the functions.php file inside your theme.
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
EDIT As noted by #BasvanDijk
To remove altogether, you can use the following
add_filter( 'woocommerce_product_tabs', '__return_empty_array', 98 );
If you want to remove tabs from woo-commerce product details page, then add this code in your function.php
Option 1-
Go to functions.php and Add the following code.
(Go to Admin panel > Appearance > Editor > functions.php)
add_filter( 'woocommerce_product_tabs', 'woo_remove_tabs', 98 );
function woo_remove_tabs( $tabs ){
if(is_product()){
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
}
return $tabs;
}
By using this filter we can Remove the tabs From the Woocommerce Product Pages.
Option 2-
Or for an alternative approach just add this to your functions.php
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10);
Option 3-
Hide the tab by adding this to the bottom of woocommerce.css
.woocommerce_tabs .tabs {
display: none;
}
Read more -Woo-commerce: Remove tab from product page
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_product_description', 40 );
This work for me with the contributions i got here. Other than removing the tab and also to place back the text.
Credits to Swapnali & Mustafa
Here is the working code:
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );
function wcs_woo_remove_reviews_tab($tabs) {
unset($tabs['reviews']);
return $tabs;
}
for some reason the code to add to functions.php file did not work for me, even tho it is in the woo commerce codex.
I was getting lots of comment spam to these products that showed reviews.
in the end I manually removed the review tab from all the products using built in wordpress/woocommerce functionality.
go to the product lising page
click the checkbox to select all products (it will only select the products on this page so you may have to go thru several pages to repeat)
from the bulk actions drop down, select edit
click apply
you will now see all the bulk edit actions you can do. Choose the "comments" drop down, and select "Do not allow"
click update
make sure to delete any cache if using a caching plugin
Excuse me but the question is not only removing tabs but also keeping the product description. If you ever tried the code above you would realize that while removing tabs you are actually removing the product description. And this is not the desired case.
You should somewhere add the following code to add it back. But unfortunately this time you can add the description side by side the picture and making a narrow column. I couldn't find the solution to add it nicely below the picture where the tabs existed before.
The code:
function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 40 );
Using a combination of the answers above, nesting the function within the action so you can use within a conditional:
add_action( 'wp', 'custom_remove_tabs_by_tag' );
function custom_remove_tabs_by_tag() {
if ( is_product() && has_term( 'tag-term', 'product_tag' ) )
{
// Remove All Product Tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
// Add Product Description
add_action( 'woocommerce_after_single_product_summary',
function () { woocommerce_get_template( 'single-product/tabs/description.php' );},
40 );
}