Skip to content

Commit

Permalink
Stock quantity. closes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskoster committed Oct 13, 2016
1 parent 2c4f69d commit d036e62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function remove_pac_styles() {

= 1.0.3 - 13/10/2016 =
* Fix - Column layout
* Fix - Stock quantities of 1 are now displayed.

= 1.0.2 - 06/10/2016 =
* Fix - Specify a default for Customizer settings.
Expand Down
13 changes: 8 additions & 5 deletions woocommerce-product-archive-customiser.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,14 @@ function woocommerce_pac_show_product_categories() {
*/
function woocommerce_pac_show_product_stock() {
global $product;
$stock = $product->get_total_stock();
if ( ! $product->is_in_stock() ) {
echo '<p class="stock out-of-stock"><small>' . esc_attr__( 'Out of stock', 'woocommerce-product-archive-customiser' ) . '</small></p>';
} elseif ( $stock > 1 ) {
echo '<p class="stock in-stock"><small>' . sprintf( esc_attr__( '%s in stock', 'woocommerce-product-archive-customiser' ), esc_attr( $stock ) ) . '</small></p>';
$stock = $product->get_total_stock();
$product_availability = $product->get_availability();
$availability_text = $product_availability['availability'];

if ( $product->is_in_stock() ) {
echo '<p class="stock in-stock"><small>' . esc_attr( $availability_text ) . '</small></p>';
} else {
echo '<p class="stock out-of-stock"><small>' . esc_attr( $availability_text ) . '</small></p>';
}
}
}
Expand Down

0 comments on commit d036e62

Please sign in to comment.