1 comments

@LoicTheAztec 2019-04-12 15:17:39

You will use the WC_Product method get_attributes() that returns an array like:

global $product;

if ( get_post_type( $post ) === 'product' && ! is_a($product, 'WC_Product') ) {
    $product = wc_get_product( get_the_id() ); // Get the WC_Product Object
}

$product_attributes = $product->get_attributes(); // Get the product attributes

// Raw output
echo '<pre>'; print_r( $product_attributes ); echo '</pre>';

It should work (for real product attributes).


Now if you use some third party plugins, like product add-Ons for example, they add some custom fields to the product, but they are not product attributes…

Related Questions

Sponsored Content

Sponsored Content