Meta Box data not saving to post billing order details (woocommerce)
-
I have added a meta box to the order details page which pulls a list of users under the “courier” role. Now i just can’t get it to save the data to the post. Also, i want to add a column to the admin order page showing the selected name and lastly i need to pull this data when I export the rest of the order details. I hope I’m at least on the right path.
<?php //create metabox add_action( 'add_meta_boxes', 'add_courier_meta_boxes' ); function add_courier_meta_boxes() { add_meta_box( 'woocommerce-courier', __( 'Courier' ), 'courier_meta', 'shop_order', 'side', 'default' ); } function courier_meta($post) { wp_nonce_field( 'save_courier_meta', 'courier_meta_nonce' ); //get users by role $args1 = array ( 'id' => '_Courier_Select', 'role' => 'courier', 'orderby' => 'user_nicename', 'order' => 'ASC' ); $couriers = get_users($args1); echo '<select names= "Name">'; foreach ($couriers as $user) { echo '<option name="_user" value="' . $couriers . '">' . $user->display_name.'</option>'; } echo '</select>'; } // this section of code is suppose to save whats selected in the dropbox add_action('save_post','save_courier_meta'); function save_courier_meta($post_id) { if ( ! isset( $_POST['courier_meta_nonce'] ) ) { return $post_id; } if ( ! wp_verify_nonce( $_POST['courier_meta_nonce'], 'save_courier_meta')) { return $post_id; } if ( ! current_user_can( 'edit_post' )){ return $post_id; } update_post_meta( $post_id, '_Courier_Select'); }
- The topic ‘Meta Box data not saving to post billing order details (woocommerce)’ is closed to new replies.