I have the following code working to create the Additional information tab in woocommerce with my own values however I want to pull the information from the built-in product custom field.
add_filter( 'woocommerce_display_product_attributes', 'custom_product_additional_information', 10, 2 ); function custom_product_additional_information( $product_attributes, $product ) { // First row $product_attributes[ 'attribute_' . 'custom-one' ] = array( 'label' => __('Label One'), 'value' => __('Value 1'), ); // Second row $product_attributes[ 'attribute_' . 'custom-two' ] = array( 'label' => __('Label Two'), 'value' => __('Value 2'), ); return $product_attributes; }
This is the current code I use to output the custom field, how do I output this in Value 1 in functions.php file in the working code above?
echo get_post_meta( get_the_ID(), 'Size', true );
Advertisement
Answer
Try the following replacing in your code:
'value' => __('Value 1'),
with:
'value' => $product->get_meta('Size'),
It should work.