Get custom product attributes in Woocommerce Get custom product attributes in Woocommerce wordpress wordpress

Get custom product attributes in Woocommerce


Edited: The woocommerce_get_product_terms is deprecated since Woocommerce version 3

Go with the following as @datafeedr wrote in his answer:

global $product;$koostis = array_shift( wc_get_product_terms( $product->id, 'pa_koostis', array( 'fields' => 'names' ) ) );

or even more compact:

global $product;$koostis = $product->get_attribute( 'pa_koostis' );

Original answer:

$result = array_shift(woocommerce_get_product_terms($product->id, 'pa_koostis', 'names'));


Update for 2018. You can use:

global $product;echo wc_display_product_attributes( $product );

To customise the output, copy plugins/woocommerce/templates/single-product/product-attributes.php to themes/theme-child/woocommerce/single-product/product-attributes.php and modify that.


September 2014:

$product->get_attribute( 'your_attr' );

You will need to define $product if it's not on the page.