Support » Plugin: WooCommerce » How can I put “Not for sale” on product listing for inventory=0 (sold) items?

  • Resolved lesliedeanbrown

    (@lesliedeanbrown)


    Part of the reason is the following:
    At the moment the price disappears when the item is sold out.
    But this is interfering with my isotope filtering grid.

    It makes the next row of products not line up correctly.

    I want the sold out items listed to remain on the product page.
    So I thought a workaround could be to add some text “Not for sale” where the price normally shows up. This would realign the grid so to speak.

    How can I implement this change?
    What code would I need to add, and where?

    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter lesliedeanbrown

    (@lesliedeanbrown)

    Correction,
    It looks like the price wasn’t listed on one of the items (abstract work), that’s why the price wasn’t showing up.

    Is there a way to input/display “Not for sale” into this normally numerical-only field?

    This is kind of two separate issues I suppose.

    I’d also like to hide the price on other sold items automatically and replace it with “Not for Sale” right after they’ve been bought. Because I don’t always want people knowing what people paid for things…

    Thread Starter lesliedeanbrown

    (@lesliedeanbrown)

    I managed to google it and fix the issue myself. Source.
    I added this code to functions.php

    😃

    add_filter("woocommerce_variable_sale_price_html", "my_remove_prices", 10, 2);
    add_filter("woocommerce_variable_price_html", "my_remove_prices", 10, 2);
    add_filter("woocommerce_get_price_html", "my_remove_prices", 10, 2);
    function my_remove_prices($price, $product)
    {
        if (!$product->is_in_stock())
        {
            $price = "SOLD";
        }
        return $price;
    }
    Plugin Support Igor H (woo-hc)

    (@ihereira)

    Hello there 🙂

    I want the sold out items listed to remain on the product page.

    * Please navigate to WooCommerce > Settings > Products > Inventory, be sure the setting “Hide out of stock items from the catalog” is unchecked.

     Out of stock visibility Hide out of stock items from the catalog
    Link to image: https://snipboard.io/BZAxIT.jpg

    Is there a way to input “Not for sale” into this normally numerical-only field?

    This article explains how to change it:
    https://stackoverflow.com/questions/65963520/replace-displayed-price-by-a-text-for-out-of-stock-woocommerce-products

    Hope this provides you clarity.

    Plugin Support Igor H (woo-hc)

    (@ihereira)

    Hi there,

    Happy to know you found a solution.

    Sorry for the confusion, it appears you found it while I was typing my previous response 😉

    I’ll mark this thread as resolved now. If you have any further questions, I recommend creating a new thread. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How can I put “Not for sale” on product listing for inventory=0 (sold) items?’ is closed to new replies.