Created
December 16, 2020 16:54
-
-
Save ximosa/2c3545cb7cce47f620b1deddaaefd3b0 to your computer and use it in GitHub Desktop.
Mostrar el stock en la lista de productos de WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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