Home › Forums › WoodMart support forum › Split: Stock lable › Reply To: Split: Stock lable
November 2, 2022 at 9:57 pm
#418203
Elise Noromit
Member
Hello,
Please add this code to the functions.php of the child theme:
if ( ! function_exists( 'woodmart_stock_status_after_title' ) ) {
/**
* Output stock status after title.
*
* @return void
*/
function woodmart_stock_status_after_title() {
if ( 'after_title' !== woodmart_get_opt( 'stock_status_position' ) ) {
return;
}
global $product;
$stock_status = $product->get_availability();
$wrapper_class = 'stock';
$wrapper_class .= 'instock' === $product->get_stock_status() ? ' in-stock' : ' out-of-stock';
$wrapper_class .= ' wd-style-default';
if ( ! empty( $stock_status['availability'] ) ) {
$stock_status_text = $stock_status['availability'];
} else {
$stock_status_text = esc_html__( 'In stock', 'woodmart' );
}
woodmart_enqueue_inline_style( 'woo-mod-stock-status' );
?>
<p class="wd-product-stock <?php echo esc_attr( $wrapper_class ); ?>">
<?php echo wp_kses( $stock_status_text, 'true' ); ?>
</p>
<?php
}
}
If you have any questions please feel free to contact us.
Best Regards