Attribute Label Displays As HTML Code

You may have noticed when using Attribute Swatches in WooCommerce 3.4.0 the attribute label is displaying on the frontend as HTML code:

Attribute labels

You can attempt to make this modification in your theme:

First, check if this file exists in your theme: woocommerce/single-product/add-to-cart/variable.php.

If the file did not exist in your theme, find it in the woocommerce plugin folder under templates/single-product/add-to-cart/variable.php. I wouldn’t usually recommend it, but in this case you can modify the core template file as it will be updated to the same thing in 3.4.1 anyway.

Open the template file and change this line:

<td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo esc_html( wc_attribute_label( $attribute_name ) ); ?></label></td>

To this:

<td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>

The issue should now be solved.

Are you using WooCommerce Attribute Swatches yet?

Start your 14-day free trial right now and get instant access to the features described in this article.

or learn more

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.

WooCommerce Attribute Swatches

WooCommerce Attribute Swatches

Not got the plugin yet? Get instant access right now, free for 14 days.

or learn more

Still need help?

If you haven't found what you're looking for in our documentation, please contact support.

Get Support