Support » Plugin: WooCommerce » Chance x products in stock text

  • Resolved daen123123

    (@daen123123)


    Hello,

    I want to chance the “x products in stock” text. If I select a product right now it is saying “2 available” but I want it to say “only 2 available” how can I chance the text?

    Thank you in advance.

    Daniel

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Stef

    (@serafinnyc)

    Your theme is already setup so you would simply add this to a WC template file.

     <?php 
            global $product; 
            $numleft  = $product->get_stock_quantity(); 
            if($numleft==0) {
               // out of stock
                echo "There are no items available at this time."; 
            }
            else if($numleft==1) {
                echo "Only ".$numleft ." Available";
            }
            else {
                echo "Only ".$numleft ." Available";
            }
    ?>

    Then add this to remove any sign of “In Stock”

    add_filter( 'woocommerce_get_stock_html', '__return_empty_string' );

    When a product is out it will revert to default message
    “There are no items available at this time.”

    Stef

    (@serafinnyc)

    Forgot to mention that this will only work on Simple Products. Variations is/would be more difficult to do. I’d have to think about it.

    Thank you very much for your help Stef:)

    Stef

    (@serafinnyc)

    You’re welcome. Tried a Variable one. Got it to work but the display isn’t going to look good. Variations are harder and there’s not enough room to display the outcome.

    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hi @daen123123

    I’m glad Stef was able to help out here. We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Thanks,

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.