Merge pull request #11021 from franticpsyx/woocommerce-admin-stock-html-filter

[2.6] Add 'woocommerce_admin_stock_html' filter
This commit is contained in:
Mike Jolley 2016-06-01 17:28:18 +01:00
commit a7ca7653c6
2 changed files with 9 additions and 5 deletions

View File

@ -397,17 +397,20 @@ class WC_Admin_Post_Types {
echo '</a>'; echo '</a>';
break; break;
case 'is_in_stock' : case 'is_in_stock' :
if ( $the_product->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 { } 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 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() ) ) { 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; break;
default : default :
break; break;

View File

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