Hey I need to put "in stock" text after price at my shop page.
Screen
I found this code
add_filter( 'woocommerce_get_price_html', 'prepend_append_icon_to_price', 10, 2 );
function prepend_append_icon_to_price( $price, $product ) {
if( has_term( 'fast-shipping', 'product_cat', $product->get_id() ) && ! is_product() ){
$price .= '<span style="float:right"><i class="fas fa-shipping-fast"></i></span> ';
}
return $price;
}
And I have this code
function envy_stock_catalog() {
global $product;
if ( $product->is_in_stock() ) {
echo '<div class="stock" >' . $product->get_stock_quantity() . __( ' in stock', 'envy' ) . '</div>';
} else {
echo '<div class="out-of-stock" >' . __( 'out of stock', 'envy' ) . '</div>';
}
}
add_action( 'woocommerce_after_shop_loop_item_title', 'envy_stock_catalog' );
Now i need to combine these codes, can you help me ? Please 🙂
2
Answers
Ok, thanks @fasstechies i edited the code and now it's working :) thx.
You can do such type of things to fulfill your requirement. You can place this code in your functions.php.