WordPress.org

Forums

WooCommerce - excelling eCommerce
out of stock and sales labels (1 post)

  1. JanjaWat1
    Member
    Posted 11 months ago #

    After updating woocommerce all the products went on sale. Now I know that this happened because of some of the products not having any pricing. The ones that have pricing, I was able to re-save the posts and it would fix it. But we have items that don't have a pricing that we would like to show a call for info.

    I was thinking that changing the out-of-stock label to call-for-info would be the way to go but I can't get it to work.
    I found some codes from the past that should do that but they don't seem to work.
    I added this to my functions file in my parent theme. If I add it to my child theme, it breaks the page.
    Can somebody let me know, how to do that, please?

    add_filter( 'woocommerce_get_availability', 'custom_get_availability', 1, 2);
    function custom_get_availability( $availability, $_product ) {
    global $product;
    $stock = $product->get_total_stock();
    if ( $_product->is_in_stock() ) $availability['availability'] = __($stock . ' AVAILABLE', 'woocommerce');
    if ( !$_product->is_in_stock() ) $availability['availability'] = __('CALL FOR INFO', 'woocommerce');
    return $availability;
    }

    https://wordpress.org/plugins/woocommerce/

Reply

You must log in to post.

About this Plugin

About this Topic