I have this php script to functions.php file for adding a custom fields (barcode/ean number) to Woocommerce products edit admin panel.
//add barcode field
function add_barcode(){
woocommerce_wp_text_input(
array(
'id' => '_barcode',
'label' => __( 'Barcode', 'woocommerce' ),
'placeholder' => '',
'desc_tip' => 'true',
'description' => __( "Enter barcode number.", "woocommerce" )
)
);
}
add_action('woocommerce_product_options_inventory_product_data','add_barcode');
function add_barcode_save( $product ){
if( isset( $_POST['_barcode'] ) ) {
$product->update_meta_data( '_barcode', sanitize_text_field( $_POST['_barcode'] ) );
} else {
$product->delete_meta_data( '_barcode' );
}
}
add_action( 'woocommerce_admin_process_product_object', 'add_barcode_save' );
The custom field it appears correctly and i can save with this php script. But i want to add this custom field to the quick edit panel also for faster editing.
Can anybody write me the additional php script for this?
Thanks in advance.
2
Answers
finally i found a solution after searching on google.
the barcode input field appears before SKU. how i can move it bellow the SKU field?
I don’t suppose you know how to populate the text field in the quick edit view to show the barcode? We’ve used this approach but are struggling with the text field population.
IMG of Barcode Field