Show sku in stock reports. Closes #966.

This commit is contained in:
Mike Jolley 2012-04-23 14:35:48 +01:00
parent 1f2a09869c
commit 421273f4c7
2 changed files with 45 additions and 18 deletions

View File

@ -1490,19 +1490,32 @@ function woocommerce_stock_overview() {
<h3><span><?php _e('Low stock', 'woocommerce'); ?></span></h3>
<div class="inside">
<?php
if ($low_in_stock) :
if ( $low_in_stock ) {
echo '<ul class="stock_list">';
foreach ($low_in_stock as $product) :
$stock = (int) get_post_meta($product->ID, '_stock', true);
foreach ( $low_in_stock as $product ) {
$stock = (int) get_post_meta( $product->ID, '_stock', true );
$sku = get_post_meta( $product->ID, '_sku', true );
if ( $stock <= $nostockamount ) continue;
echo '<li><a href="';
if ($product->post_type=='product') echo admin_url('post.php?post='.$product->ID.'&action=edit'); else echo admin_url('post.php?post='.$product->post_parent.'&action=edit');
echo '"><small>' . sprintf( _n('%d in stock', '%d in stock', $stock, 'woocommerce'), $stock ) . '</small> ' . $product->post_title . '</a></li>';
endforeach;
$title = $product->post_title;
if ( $sku )
$title .= ' (' . __('SKU', 'woocommerce') . ': ' . $sku . ')';
if ( $product->post_type=='product' )
$product_url = admin_url( 'post.php?post=' . $product->ID . '&action=edit' );
else
$product_url = admin_url( 'post.php?post=' . $product->post_parent . '&action=edit' );
printf( '<li><a href="%s"><small>' . _n('%d in stock', '%d in stock', $stock, 'woocommerce') . '</small> %s</a></li>', $product_url, $stock, $title );
}
echo '</ul>';
else :
} else {
echo '<p>'.__('No products are low in stock.', 'woocommerce').'</p>';
endif;
}
?>
</div>
</div>
@ -1512,19 +1525,32 @@ function woocommerce_stock_overview() {
<h3><span><?php _e('Out of stock', 'woocommerce'); ?></span></h3>
<div class="inside">
<?php
if ($low_in_stock) :
if ( $low_in_stock ) {
echo '<ul class="stock_list">';
foreach ($low_in_stock as $product) :
$stock = (int) get_post_meta($product->ID, '_stock', true);
foreach ( $low_in_stock as $product ) {
$stock = (int) get_post_meta( $product->ID, '_stock', true );
$sku = get_post_meta( $product->ID, '_sku', true );
if ( $stock > $nostockamount ) continue;
echo '<li><a href="';
if ($product->post_type=='product') echo admin_url('post.php?post='.$product->ID.'&action=edit'); else echo admin_url('post.php?post='.$product->post_parent.'&action=edit');
echo '"><small>' . sprintf( _n('%d in stock', '%d in stock', $stock, 'woocommerce'), $stock ) . '</small> ' . $product->post_title . '</a></li>';
endforeach;
$title = $product->post_title;
if ( $sku )
$title .= ' (' . __('SKU', 'woocommerce') . ': ' . $sku . ')';
if ( $product->post_type=='product' )
$product_url = admin_url( 'post.php?post=' . $product->ID . '&action=edit' );
else
$product_url = admin_url( 'post.php?post=' . $product->post_parent . '&action=edit' );
printf( '<li><a href="%s"><small>' . _n('%d in stock', '%d in stock', $stock, 'woocommerce') . '</small> %s</a></li>', $product_url, $stock, $title );
}
echo '</ul>';
else :
} else {
echo '<p>'.__('No products are out in stock.', 'woocommerce').'</p>';
endif;
}
?>
</div>
</div>

View File

@ -154,6 +154,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Tweak - Changed category and tag link to filter product list in admin panel
* Tweak - Removed product 'exists' variable in favour of the exists() method. Tweaked exist method to look for ID in DB.
* Tweak - Only use rm=2 for paypal when SSL is enabled, to avoid security warnings when returning to the site.
* Tweak - Show sku in stock reports
* Fix - Replacing use of deprecated function get_current_theme() with wp_get_theme()
* Fix - Body classes now correct for WordPress themes with non alphanumeric characters
* Fix - PayPal http_build_query &amp; -> & on some PHP 5.3 servers