Rename woocommerce Products label

In this post, we will explore how we can rename the default “Products” label in the woocommerce installation. While doing so, we will have to take care of the fact that our changes are retained after the woocommerce or wordpress is updated and our modification does not cause any problems.

Basically the products in woocommerce are a custom post type named “products”. Therefore, just like other post types, woocommerce products are also registered as custom post type using the function register_post_type().

Lucky for us, woocommerce allows us to edit the parameters passed to “register_post_type()” using a filter “woocommerce_register_post_type_product”. 

Here is how we can rename woocommerce Products to “My Custom Label”

add_filter( 'woocommerce_register_post_type_product', 'at_post_type' );

function at_post_type( $args ){
$labels = array(
'name' => __( 'My Custom Label', 'at-custom-plugin-textdoamin' ),
'singular_name' => __( 'My Custom Label', 'at-custom-plugin-textdoamin' ),
'menu_name' => _x( 'My Custom Label', 'Admin menu name', 'at-custom-plugin-textdoamin' ),
'add_new' => __( 'Add My Custom Label', 'at-custom-plugin-textdoamin' ),
'add_new_item' => __( 'Add New My Custom Label', 'at-custom-plugin-textdoamin' ),
'edit' => __( 'Edit', 'at-custom-plugin-textdoamin' ),
'edit_item' => __( 'Edit My Custom Label', 'at-custom-plugin-textdoamin' ),
'new_item' => __( 'New My Custom Label', 'at-custom-plugin-textdoamin' ),
'view' => __( 'View My Custom Label', 'at-custom-plugin-textdoamin' ),
'view_item' => __( 'View My Custom Label', 'at-custom-plugin-textdoamin' ),
'search_items' => __( 'Search My Custom Label', 'at-custom-plugin-textdoamin' ),
'not_found' => __( 'No My Custom Label found', 'at-custom-plugin-textdoamin' ),
'not_found_in_trash' => __( 'No My Custom Label found in trash', 'at-custom-plugin-textdoamin' ),
'parent' => __( 'Parent My Custom Label', 'at-custom-plugin-textdoamin' )
);

$args['labels'] = $labels;
$args['description'] = __( 'This is where you can add new My Custom Label to your store.', 'at-custom-plugin-textdoamin' );
return $args;
}

This will give us :

tt

Leave a Reply

Your email address will not be published. Required fields are marked *