I pasted this code in function.php, but it didn't rename the product page tab as it supposed to (http://www.noushasasart.com/product/harsh-bark/)
function woo_remove_product_tabs($tabs) {
unset($tabs['reviews']); // Remove the reviews tab
$tabs['description']['title'] = __('Additional Information'); // Rename the
description tab
return $tabs;
}
how can I solve this?
You have forgotten the filter hook:
add_filter( 'woocommerce_product_tabs', 'woo_customize_tabs', 100, 1 );
function woo_customize_tabs( $tabs ) {
unset($tabs['reviews']); // Remove the reviews tab
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
return $tabs;
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
All code is tested on Woocommerce 3+ and works.
Update (related to your comment) | Rename product description heading (inside the tab):
To rename description heading use woocommerce_product_description_heading filter hook this way:
add_filter( 'woocommerce_product_description_heading', 'rename_product_description_heading', 10, 1 );
function rename_product_description_heading( $heading ) {
return __( 'Additional Information', 'woocommerce' );
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
All code is tested on Woocommerce 3+ and works.
Official related documentation: Editing product data tabs
Related
I have a question about changing text of place_order.
Check out page will reload form by update_checkout Event, So the place_order text will change back to original text ‘proceed to Paypal’.
I've tried to use Jquery and function hook to change text but still change back.
function woo_custom_order_button_text() {
return __( 'Your new button text here', 'woocommerce' );
}
How can I change the text of #place_order by not disable the update_checkout Event?
To change the place order button text when Paypal is the chosen payment gateway use the following:
add_filter( 'gettext', 'change_checkout_paypal_pay_button_text', 10, 3 );
function change_checkout_paypal_pay_button_text( $translated_text, $text, $domain ) {
if( 'Proceed to PayPal' === $text ) {
$translated_text = __('Your custom text', $domain); // <== Here the replacement txt
}
return $translated_text;
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
Now to change the place order text for others payment gateways, you will use in addition the following:
add_filter( 'woocommerce_order_button_text', 'custom_checkout_place_order_text' );
function custom_checkout_place_order_text( $button_text ) {
return __( 'Your custom text here', 'woocommerce' ); // <== custom text Here
}
Code goes in functions.php file of your active child theme (or active theme). Tested and works.
How to move the product meta to the beginning of the product description tab?
I try:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_product_tabs_description', 'woocommerce_template_single_meta', 10 );
Remove works, but add_action() doesn't.
You can keep the first code line. Then to insert single product meta on product description tab, before description, you can use 2 different ways:
1). Using Hooks as follows:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_filter( 'woocommerce_product_tabs', 'woocommerce_custom_product_tabs', 999 );
function woocommerce_custom_product_tabs( $tabs ) {
// We overwrite the callback function with a custom one
$tabs['description']['callback'] = 'woocommerce_product_meta_and_description_tab';
// (optional) We can also overwrite the title
$tabs['description']['title'] = __('Meta and description', 'woocommerce');
return $tabs;
}
function woocommerce_product_meta_and_description_tab() { // this is where you indicate what appears in the description tab
wc_get_template( 'single-product/meta.php' ); // The meta content first
wc_get_template( 'single-product/tabs/description.php' ); // The product description after
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
2). Or Overriding templates:
You can override single-product/tabs/description.php template file via your theme as explained in this official documentation.
Once you have copied the file to the woocommerce folder inside your active theme, open edit single-product/tabs/description.php file and add the following line inside it:
wc_get_template( 'single-product/meta.php' );
It will displays the product meta information inside the product description tab.
Don't forget to keep in your active child theme's functions.php file:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
Related: WooCommerce action hooks and overriding templates
There actually is a way to do this within your functions without copying files from woocommerce and overriding them in your child theme.
Per WooCommerce documentation, you can customize the product data tabs. With a small modification to the code they provided, you can do what you're asking:
/**
* Customize product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$tabs['description']['callback'] = 'woo_custom_description_tab_content'; // Custom description callback
return $tabs;
}
function woo_custom_description_tab_content() { // this is where you indicate what appears in the description tab
wc_get_template( 'single-product/meta.php' ); // add this to add meta to content
the_content(); // keep this in to preserve original functionality
}
I would like to customize My account > Orders page, changing from action column, the "view" button text to "view tickets" in the Orders list table.
Is it possible to do it only on My account > Orders page?
Here is a screenshot for clarifications:
To rename My account > Orders: "view" action button text, use the following:
// Rename My account > Orders "view" action button text
add_filter( 'woocommerce_my_account_my_orders_actions', 'change_my_account_my_orders_view_text_button', 10, 2 );
function change_my_account_my_orders_view_text_button( $actions, $order ) {
$actions['view']['name'] = __( 'View ticket', 'woocommerce' );
return $actions;
}
To Rename My account "Orders" menu item, use the following (if needed):
// Rename My account "Orders" menu item
add_filter( 'woocommerce_account_menu_items', 'rename_my_account_orders_menu_item', 22, 1 );
function rename_my_account_orders_menu_item( $items ) {
$items['orders'] = __("Ticket Orders", "woocommerce");
return $items;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
If you need to target only My account > "orders" table, use is_wc_endpoint_url('orders') conditional tag:
// Rename My account > Orders "view" action button text
add_filter( 'woocommerce_my_account_my_orders_actions', 'change_my_account_my_orders_view_text_button', 10, 2 );
function change_my_account_my_orders_view_text_button( $actions, $order ) {
if( is_wc_endpoint_url( 'orders' ) )
$actions['view']['name'] = __( 'View ticket', 'woocommerce' );
return $actions;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
I'm trying to use ACF to add a custom attribute to the "Additional Information" tab for the products in WooCommerce. I want the admin to be able to upload a PDF that then should be set and linked in the table found in the "Additional Information" tab.
I've found the default template for the attributes in the plugin directory for WooCommerce, more precisely woocommerce/templates/single-product/product-attributes.php. This is how the template looks. I can easily just put the the_field("pdf") there to display the custom field, but the problem I'm running into is that the Additional Information tab will only show if attributes has been added through WooCommerce.
Is there some way to add additional conditional tags for when to display the Additional Information tab? If I somehow could add if (get_field("pdf")) to that code, I think this would be solved.
Updated: In Woocommerce if any dimensions, weight or product attributes (set to be displayed on product) exist, "Additional Information" tab will be displayed…
So if the tab is hidden and you have added on single-product/product-attributes.php template a custom field get_field("pdf") to be displayed that has a value, you can force "Additional Information" tab to appear using:
add_filter( 'woocommerce_product_tabs', 'woo_customize_tabs', 100, 1 );
function woo_customize_tabs( $tabs ) {
if( ! isset($tabs['additional_information']) && null !== get_field("pdf") ){
$tabs['reviews']['priority'] = 30;
$reviews = $tabs['reviews'];
unset($tabs['reviews']);
$tabs['additional_information'] = array(
'title' => __( 'Additional information', 'woocommerce' ),
'priority' => '20',
'callback' => 'woocommerce_product_additional_information_tab',
);
$tabs['reviews'] = $reviews;
}
return $tabs;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
In wordpress woocommerce under single product page, i want to change the default tab headings:
Change "Description" to Features and
Change "Additional Information" to "Specifications"
Under which PHP file should i make these changes, for it to take effect ?
Here is how you would rename the tabs (just add to your theme functions.php file) - This is valid for older versions of WooCommerce per their documentation:
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
$tabs['description']['title'] = __( 'Features' ); // Rename the description tab
$tabs['additional_information']['title'] = __( 'Specifications' ); // Rename the additional information tab
return $tabs;
}