add 'woocommerce_admin_stock_html' filter

This commit is contained in:
Manos Psychogyiopoulos 2016-06-01 15:06:10 +03:00
parent 507e3e85c7
commit 410c09d6b0
2 changed files with 9 additions and 5 deletions

View File

@ -397,17 +397,20 @@ class WC_Admin_Post_Types {
echo '</a>';
break;
case 'is_in_stock' :
if ( $the_product->is_in_stock() ) {
echo '<mark class="instock">' . __( 'In stock', 'woocommerce' ) . '</mark>';
$stock_html = '<mark class="instock">' . __( 'In stock', 'woocommerce' ) . '</mark>';
} else {
echo '<mark class="outofstock">' . __( 'Out of stock', 'woocommerce' ) . '</mark>';
$stock_html = '<mark class="outofstock">' . __( 'Out of stock', 'woocommerce' ) . '</mark>';
}
// 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;

View File

@ -112,10 +112,11 @@ class WC_Report_Stock extends WP_List_Table {
case 'stock_status' :
if ( $product->is_in_stock() ) {
echo '<mark class="instock">' . __( 'In stock', 'woocommerce' ) . '</mark>';
$stock_html = '<mark class="instock">' . __( 'In stock', 'woocommerce' ) . '</mark>';
} else {
echo '<mark class="outofstock">' . __( 'Out of stock', 'woocommerce' ) . '</mark>';
$stock_html = '<mark class="outofstock">' . __( 'Out of stock', 'woocommerce' ) . '</mark>';
}
echo apply_filters( 'woocommerce_admin_stock_html', $stock_html, $product );
break;
case 'stock_level' :