Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

woo variable product get field

// 4. Display custom field on the additional information area
function display_product_attributes( $product_attributes, $variations ) {
    // Get childIDs in an array
    $children_ids = $variations->get_children();

    foreach ( $children_ids as $child_id ) {
        $value = get_post_meta( $child_id, 'custom_field', true );

        // True
        if ( $value ) {
            // rows
            $product_attributes[ 'custom_field ' . $child_id ] = array(
                'label' => __('custom', 'woocommerce'),
                'value' => $value,
            );
        }
    }

    return $product_attributes;
}
add_filter('woocommerce_display_product_attributes', 'display_product_attributes', 10, 2);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #woo #variable #product #field
ADD COMMENT
Topic
Name
9+3 =