Snippets

Visser Labs Adding static Product fields to the Products export type

You are viewing an old version of this snippet. View the current version.
Revised by Michael Visser 6bcc8d0
<?php
function custom_woo_ce_extend_product_fields( $fields ) {

    $fields[] = array(
        'name' => 'static_field',
        'label' => __( 'Static Field', 'woo_ce' ),
        'hover' => __( 'Static Field within functions.php', 'woo_ce' )
    );
    return $fields;

}
add_filters( 'woo_ce_product_fields', 'custom_woo_ce_extend_product_fields' );

function custom_woo_ce_extend_product_item( $product, $product_id ) {

    $product->static_field = 'Static value';
    return $product;

}
add_filters( 'woo_ce_product_item', 'custom_woo_ce_extend_product_item', 10, 2 );
?>
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.