Reputation: 211
I will be adding custom product attributes to the product data for products in my woocommerce catalogue.
How can I fetch the values of this field to display in the product page/template?
Thanks
Upvotes: 1
Views: 574
Reputation: 254373
You could use the following using WC_Product
get_attribute()
method:
global $product; // if the WC_Product object is not defined
if ( ! is_a($product, 'WC_Product') ) {
$product = wc_get_product( get_the_ID() );
}
echo '<p>' . $product->get_attribute( 'secimg' ) . '</p>';
Its should work.
Upvotes: 3