From 410c09d6b0ecd9523abdb473cb1a2c242f5eadce Mon Sep 17 00:00:00 2001 From: Manos Psychogyiopoulos Date: Wed, 1 Jun 2016 15:06:10 +0300 Subject: [PATCH] add 'woocommerce_admin_stock_html' filter --- includes/admin/class-wc-admin-post-types.php | 9 ++++++--- includes/admin/reports/class-wc-report-stock.php | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index ecbd897f838..097edd8d700 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -397,17 +397,20 @@ class WC_Admin_Post_Types { echo ''; break; case 'is_in_stock' : + if ( $the_product->is_in_stock() ) { - echo '' . __( 'In stock', 'woocommerce' ) . ''; + $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; } else { - echo '' . __( 'Out of stock', 'woocommerce' ) . ''; + $stock_html = '' . __( 'Out of stock', 'woocommerce' ) . ''; } // If the product has children, a single stock level would be misleading as some could be -ve and some +ve, some managed/some unmanaged etc so hide stock level in this case. if ( $the_product->managing_stock() && ! sizeof( $the_product->get_children() ) ) { - echo ' (' . $the_product->get_total_stock() . ')'; + $stock_html .= ' (' . $the_product->get_total_stock() . ')'; } + echo apply_filters( 'woocommerce_admin_stock_html', $stock_html, $the_product ); + break; default : break; diff --git a/includes/admin/reports/class-wc-report-stock.php b/includes/admin/reports/class-wc-report-stock.php index 60ed6cab18b..174b63925da 100644 --- a/includes/admin/reports/class-wc-report-stock.php +++ b/includes/admin/reports/class-wc-report-stock.php @@ -112,10 +112,11 @@ class WC_Report_Stock extends WP_List_Table { case 'stock_status' : if ( $product->is_in_stock() ) { - echo '' . __( 'In stock', 'woocommerce' ) . ''; + $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; } else { - echo '' . __( 'Out of stock', 'woocommerce' ) . ''; + $stock_html = '' . __( 'Out of stock', 'woocommerce' ) . ''; } + echo apply_filters( 'woocommerce_admin_stock_html', $stock_html, $product ); break; case 'stock_level' :