Woocommerce orders table columns
// Add new columns (or reorder columns)
add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column', 20 );
function custom_shop_order_column($columns) {
$reordered_columns = array();
foreach( $columns as $key => $column){
$reordered_columns[$key] = $column;
if( $key == 'column_id' ){ // column_id - id of the column after which you want to place the new column.
// It can be an already existing column, then in this way you can change the order of the columns
$reordered_columns['new_column_id'] = __( 'New Column Title','textdomain');
}
if( $key == 'other_column_id' ){
$reordered_columns['other_new_column_id'] = __( 'Other New Column Title','textdomain');
}
}
return $reordered_columns;
}
// Add content for new columns
add_action( 'manage_shop_order_posts_custom_column' , 'custom_orders_list_column_content', 20, 2 );
function custom_orders_list_column_content( $column, $post_id ) {
switch ( $column ) {
case 'other_column_id' :
$payment_method = get_post_meta( $post_id, '_payment_method', true ); // get peyment method for example
if(!empty($payment_method))
echo $payment_method
break;
}
}
Тут могла быть ваша реклама.
Рубрики: PHP | Web | WooCommerce | WordPress Listen element content changesCheckboxes and bowser’s Back Button