Last active
March 16, 2016 14:41
-
-
Save kreamweb/e050557f5aca58378c91 to your computer and use it in GitHub Desktop.
YITH WooCommerce Subscription add list of all renew in the order status list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| ///Renewal subscription | |
| add_filter( 'views_edit-shop_order', 'yith_add_renewal_subscription' ); | |
| function yith_add_renewal_subscription( $views ) { | |
| $post_status = wc_get_order_statuses(); | |
| $args = array( | |
| 'post_type' => 'shop_order', | |
| 'post_status' => array_keys( $post_status ), | |
| 'meta_key' => 'is_a_renew', | |
| 'meta_value' => 'yes', | |
| 'posts_per_page' => -1 | |
| ); | |
| $posts = get_posts( $args ); | |
| $count = $posts ? count( $posts ) : 0; | |
| $link = sprintf( '<a href="edit.php?is_a_renew=yes&post_type=shop_order">%s<span class="count"> (%d)</span></a>', __( 'Renewal subscription', 'yit' ), $count ); | |
| $views['renewal_subscription'] = $link; | |
| return $views; | |
| } | |
| add_filter( 'request', 'yith_renewal_subscription_request_query' ); | |
| function yith_renewal_subscription_request_query( $vars ) { | |
| if ( isset( $vars['post_type'] ) && $vars['post_type'] == 'shop_order' ) { | |
| if ( ! empty( $_GET['is_a_renew'] ) ) { | |
| $vars['meta_key'] = 'is_a_renew'; | |
| $vars['meta_value'] = wc_clean( $_GET['is_a_renew'] ); | |
| } | |
| } | |
| return $vars; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment