/    Sign up×
Bounties /Pin to ProfileBookmark

how to edit woocommerce additional information attributes field label

I am working on a website where the client is asking to change the label field text of additional information tab.  for details please check this screenshot. https://freeimage.host/i/H49M4nt

to post a answer
MagentoPHPUX EngineerWordPress

4 Replies

Davinci•003 auto-replyTo edit the label of the additional information attributes field in WooCommerce, you can use the following code snippet:


add_filter( 'woocommerce_attribute_label', 'custom_attribute_label', 10, 3 );
function custom_attribute_label( $label, $name, $product ) {
if ( $name == 'additional_information' ) {
$label = 'Your Custom Label';
}
return $label;
}


This code snippet will change the label of the additional information attributes field to "Your Custom Label".

Was this helpful?

Copy linkTweet thisAlerts:
@surisinghauthorJun 02.2023 — Hi Buddy,

But i don't want to change additional information, but under of it there is an attribute which is "Weight" and I just want to rename it with Capacity.
Copy linkTweet thisAlerts:
@JuanPreuytJun 17.2023 — You would have to create a custom attribute. You can do this via a plugin like advanced custom fields.

To add a custom atrribute you can do the following:


// -----------------------------------------
// 1. Add custom field input @ Product Data > Variations > Single Variation

add_action( 'woocommerce_variation_options_pricing', 'bbloomer_add_custom_field_to_variations', 10, 3 );

function bbloomer_add_custom_field_to_variations( $loop, $variation_data, $variation ) {
woocommerce_wp_text_input( array(
'id' => 'custom_field[' . $loop . ']',
'class' => 'short',
'label' => __( 'Custom Field', 'woocommerce' ),
'value' => get_post_meta( $variation->ID, 'custom_field', true )
) );
}

// -----------------------------------------
// 2. Save custom field on product variation save

add_action( 'woocommerce_save_product_variation', 'bbloomer_save_custom_field_variations', 10, 2 );

function bbloomer_save_custom_field_variations( $variation_id, $i ) {
$custom_field = $_POST['custom_field'][$i];
if ( isset( $custom_field ) ) update_post_meta( $variation_id, 'custom_field', esc_attr( $custom_field ) );
}

// -----------------------------------------
// 3. Store custom field value into variation data

add_filter( 'woocommerce_available_variation', 'bbloomer_add_custom_field_variation_data' );

function bbloomer_add_custom_field_variation_data( $variations ) {
$variations['custom_field'] = 'Custom Field: ' . get_post_meta( $variations[ 'variation_id' ], 'custom_field', true ) . '';
return $variations;
}


Ive used this snippet for quite a while and it works well. Hope this helps bud.
Copy linkTweet thisAlerts:
@AhmadassayyaafJul 29.2023 — To change the label field text of the additional information tab in WooCommerce, you can use the following steps:

1. Log in to your WordPress admin dashboard.

2. Go to "Appearance" and then "Theme Editor."

3. In the right-hand side, you should see "Theme Files." Look for "functions.php" and click on it to open the file.

4. Add the following code to the "functions.php" file, which will allow you to change the label text:

``php
function change_additional_information_tab_label( $tabs ) {
$tabs['additional_information']['title'] = __( 'New Label Text', 'woocommerce' );
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'change_additional_information_tab_label' );
`

5. Replace
'New Label Text'` with the desired text you want to display as the label for the additional information tab.

6. Click "Update File" to save the changes.

Now, when you visit a product page on your website, the label for the additional information tab should display the new text you specified in the code. Make sure to double-check the changes to ensure they appear as expected. Always back up your theme files before making any modifications.
×

Success!

Help @surisingh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...