I'm having a problem with WooCommerce. I added a field that does not have the default WooCommerce that would be to add the amount of products that go into the product's master box.
The code I'm using in my function.php is as follows:
<?php
//ADICIONANDO UM NOVO CAMPO NA AREA DE EDICAO DO PRODUTO
/// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
// Save Fields
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
/**Fields Container
**/
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Textarea
woocommerce_wp_text_input(
array(
'id' => '_embalageminput',
'label' => __( 'Embalagem', 'woocommerce' ),
'placeholder' => '',
'description' => __( 'Quantidade de Peças por Caixa.', 'woocommerce' )
)
);
// END Textarea
echo '</div>';
}
function woo_add_custom_general_fields_save(){
// Textarea
$woocommerce_embalagem = $_POST['_embalageminput'];
if( !empty( $woocommerce_embalagem ) )
update_post_meta( $post_id, ‘_embalageminput’, esc_attr( $woocommerce_embalagem) );
echo get_post_meta( get_the_ID(), '_embalageminput', true );
}
?>
When I update the product and come back it does not have the field with the value displayed. Does anyone know what I might be missing?