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:

I've patched this in WooCommerce 3.4.1, which should be available soon. In the meantime, you can make this modification:

  1. First, check if this file exists in your theme: woocommerce/single-product/add-to-cart/variable.php.
  2. 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.
  3. 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>
  4. The issue should now be gone.

As mentioned, you can update WooCommerce to the next release when it's available which will fix the issue anyway, this is just a temporary measure.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.