Skip to content

Instantly share code, notes, and snippets.

@ximosa
Created December 16, 2020 16:54
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 ximosa/2c3545cb7cce47f620b1deddaaefd3b0 to your computer and use it in GitHub Desktop.
Save ximosa/2c3545cb7cce47f620b1deddaaefd3b0 to your computer and use it in GitHub Desktop.
Mostrar el stock en la lista de productos de WooCommerce
add_action( 'woocommerce_after_shop_loop_item_title', 'dcms_show_stock_list_products' );
function dcms_show_stock_list_products() {
global $product;
if ( $product->is_in_stock() ) {
echo '<div class="stock" >' . $product->get_stock_quantity() . ' en stock</div>';
} else {
echo '<div class="out-stock" >No hay stock</div>';
}
}
----------------------
estilos css
-----------------
li.product .out-stock,
li.product .stock {
font-weight: bold;
background-color: yellow;
max-width: 120px;
margin: 10px auto;
color: black;
}
li.product .out-stock {
background-color: lightcoral;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment