This topic has 4 replies, 2 voices, and was last updated 6 years, 8 months ago ago by Olga Barlow
Is it possible to show stock amount of each product on the shop page under the price? And maybe add a word or two in front of it?
And how would I then modify the amount and text style with custom css?
Hello,
Please add following code in child theme’s functions.php file :
//Add stock status to archive pages
function etheme_stock_catalog() {
global $product;
if ( $product->is_in_stock() ) {
echo '<div class="stock" >' . $product->get_stock_quantity() . __( ' in stock', 'royal-child' ) . '</div>';
} else {
echo '<div class="out-of-stock" >' . __( 'out of stock', 'royal-child' ) . '</div>';
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'etheme_stock_catalog' );
If you want to change the styles use
.product .product-details .stock {
/*==place your rules here==*/
margin-bottom: 10px;
}
Regards
Thanks, I’ll try this tomorrow.
It seems your forum is no longer sending notifications of replies..
Hello,
Thank you for the information. We’ll check our server.
Regards
You must be logged in to reply to this topic.Log in/Sign up