New field not saved to Vendors Add new product
-
Hi,
I followed this instruction to add new field to tmpl-add-product-popup.php.
https://wedevs.com/support/topic/adding-metadata-to-product-form/
Here is my code in tmpl-add-product-popup:
<!-- Novo polje: Kolicina jednog pakovanja*/ --> <div class="dokan-form-group"> <div> Koli?ina jednog pakovanja (neobavezno)</div> <div style = "color:gray;font-size:10px;"> L - litar, ml - Mililitar, Kg - Kilogram, g - Gram</div> <div class="dokan-input-group"> <input class="dokan-form-control" name="_new_field" id="_new_field" type="text" placeholder="Primjer: 1L ili 500g" value="<?php echo dokan_posted_input( '_new_field' ); ?>"> </div> </div>
and this is code in functions.php:
add_action( 'woocommerce_product_options_general_product_data', 'x_add_fields' ); function x_add_fields() { global $woocommerce, $post; echo '<div class="options_group">'; // Number Field woocommerce_wp_text_input( array( 'id' => '_new_field', 'label' => __( 'New Field', 'woocommerce' ), 'placeholder' => '', 'description' => __( 'Primjer= 1L, 500ml, 1Kg', 'woocommerce' ), 'type' => 'number', 'custom_attributes' => array( 'step' => 'any', 'min' => '0' ) ) ); echo '</div>'; } // Save Fields add_action( 'woocommerce_process_product_meta', 'x_add_fields_save' ); add_action( 'dokan_process_product_meta', 'x_add_fields_save' ); add_action( 'dokan_new_product_added', 'x_add_fields_save' ); function x_add_fields_save( $post_id ){ // Number Field $woocommerce_new_field = $_POST['_new_field']; if( !empty( $woocommerce_new_field) ) update_post_meta( $post_id, '_new_field', esc_attr( $woocommerce_new_field ) ); }
Why my field is not save on products page?
- This topic was modified 4 years, 9 months ago by .
- This topic was modified 4 years, 9 months ago by .
- This topic was modified 4 years, 9 months ago by .
- This topic was modified 4 years, 9 months ago by .
- This topic was modified 4 years, 9 months ago by .
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘New field not saved to Vendors Add new product’ is closed to new replies.