Change WooCommerce outside icon text box

We use the Neighborhood theme on Wordpress and Woo Commerce to sell one-time, unique items. Inventory management works well in ensuring that the goods sold cannot be purchased, again displaying the goods as in stock. This is basically fine, and indeed, the "In Stock" display, "referring" to the price according to the product description, does not cause problems, and we even found a code to change this display if necessary. This works great - adding the following code to a function. Php in the subject:

add_filter('woocommerce_stock_html', 'change_stock_message', 10, 2);
function change_stock_message($message, $stock_status) {
    if ($stock_status == "Out of stock") {
        $message = '<p class="stock out-of-stock">Sold</p>';    
    } else {
        $message = '<p class="stock in-stock">Available</p>';           
    }
    return $message;
}

However, what we really want to do is change the text on an icon that is not in stock, such as an image. http://neighborhood.swiftideas.net/product/common-projects-achilles/ .

enter image description here

Changing CSS is not a problem, therefore text font, background, size, etc. it's easy to change by adding something like this to custom-css:

.out-of-stock-badge {
    background: red;
    font-size: 12px;
}

How to change the text outside the sign-icon from "Out of stock" to "SOLD"?

+4
source share
2 answers

@maksbd19, , woocommerce ( ). content-product.php single-product\product-image.php. " " "" :

...} else if (is_out_of_stock()) {
    echo '<span class="out-of-stock-badge">' . __( 'Sold', 'swiftframework' ) . '</span>';
} else if (!$product->get_price()) {...

, -.

0

, . , -

add_filter('woocommerce_sale_flash', 'woocommerce_sale_flashmessage', 10, 2);
function woocommerce_sale_flashmessage($flash){
    global $product;
    $availability = $product->get_availability();

    if ($availability['availability'] == 'Out of stock') :
        $flash = '<span class="out-of-stock-badge">'.__( 'SOLD', 'woocommerce' ).'</span>';

    endif;
    return $flash;
}

functions.php .

0

All Articles