I created some custom meta boxes for products.
In writepanel-product_data.php I added:
woocommerce_wp_text_input( array( 'id' => 'orario', 'class' => '', 'label' => __('Orario', 'woocommerce') ) );
woocommerce_wp_text_input( array( 'id' => 'luogo_evento', 'class' => '', 'label' => __('Luogo Evento', 'woocommerce') ) );
woocommerce_wp_text_input( array( 'id' => 'indirizzo', 'class' => '', 'label' => __('Indirizzo', 'woocommerce') ) );
woocommerce_wp_text_input( array( 'id' => 'zona', 'class' => '', 'label' => __('Zona', 'woocommerce') ) );
woocommerce_wp_text_input( array( 'id' => 'contatti', 'class' => '', 'label' => __('Contatti', 'woocommerce') ) );
and then at row 681
update_post_meta( $post_id, 'orario', stripslashes( $_POST['orario'] ) );
update_post_meta( $post_id, 'luogo_evento', stripslashes( $_POST['luogo_evento'] ) );
update_post_meta( $post_id, 'indirizzo', stripslashes( $_POST['indirizzo'] ) );
update_post_meta( $post_id, 'zona', stripslashes( $_POST['zona'] ) );
update_post_meta( $post_id, 'contatti', stripslashes( $_POST['contatti'] ) );
It save the data I insert in the product page. I can I print it out in the single-product.php?
You would do the following:
echo get_post_meta(get_the_ID(), 'orario', true );
echo get_post_meta(get_the_ID(), 'luogo_evento', true );
echo get_post_meta(get_the_ID(), 'indirizzo', true );
echo get_post_meta(get_the_ID(), 'zona', true );
echo get_post_meta(get_the_ID(), 'contatti', true );
I hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With