Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * WooCommerce Order Rows CSS by Role
- *
- * @author dale3h
- */
- add_filter( 'post_class', 'wc_highlight_order_rows', 10, 3 );
- function wc_highlight_order_rows( $classes, $class, $post_id ) {
- $post = get_post( $post_id );
- if ( $post && in_array( $post->post_type, wc_get_order_types( 'order-meta-boxes' ) ) ) {
- $user = get_userdata( $post->_customer_user );
- if ( $user->roles ) {
- foreach ( $user->roles as $role ) {
- $classes[] = 'role-' . $role;
- }
- }
- }
- return $classes;
- }
- add_action( 'admin_head', 'wc_highlight_order_rows_stylesheet' );
- function wc_highlight_order_rows_stylesheet() {
- global $typenow;
- if ( in_array( $typenow, wc_get_order_types( 'order-meta-boxes' ) ) ) {
- ?>
- <style>
- .striped > tbody > tr:nth-child(even).role-customer {
- background-color: #f5fff5;
- }
- .striped > tbody > tr:nth-child(odd).role-customer {
- background-color: #f0faf0;
- }
- </style>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement