php - WooCommerce Products Custom Fields (woocommerce) -
i created textafield field type , when put text , hit publish it’s displaying on front-end. when remove text clean front-end , click on publish again stays on textarea field , on front-end. please ?
function.php
function woo_add_custom_general_fields() { global $woocommerce, $post; woocommerce_wp_text_input( array( 'id' => '_text_field', 'label' => __( 'titre produit', 'woocommerce' ), 'placeholder' => '', 'desc_tip' => 'true', 'description' => __( 'enter custom value here.', 'woocommerce' ) ) ); function woo_add_custom_general_fields_save( $post_id ){ // textfield $woocommerce_text_field = $_post['_text_field']; if( !empty( $woocommerce_text_field ) ) update_post_meta( $post_id, '_text_field', esc_html( $woocommerce_text_field ) );
simply remove condition.
if( !empty( $woocommerce_text_field ) )
currently checking if text field not empty update content of text field.
when remove above condition, update field whether put content or not.
Comments
Post a Comment