Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Created August 13, 2015 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrdesigner/981fabb5b86acb30b119 to your computer and use it in GitHub Desktop.
Save chrdesigner/981fabb5b86acb30b119 to your computer and use it in GitHub Desktop.
<?php
/*
* Add Stock Quantity in Catalog Loop
*/
function odin_stock_catalog() {
global $product;
if ( $product->is_in_stock() ) {
echo '<div class="stock" >' . $product->get_stock_quantity() . __( 'EM ESTOQUE', 'odin' ) . '</div>';
} else {
echo '<div class="out-of-stock" >' . __('SEM ESTOQUE', 'odin' ) . '</div>';
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'odin_stock_catalog' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment