Home Forums WoodMart support forum Customize stock status on product archive

Customize stock status on product archive

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #440891

    atpd23
    Participant

    Hello,

    How can I change text “In stock” shown on a product archive to “In stock > 5” if there are more than 5 pieces per product.

    I can do that by a hook for a single product page, but that hook doesn’t apply for the product archive. Here is the hook:

    
    add_filter( 'woocommerce_get_availability', 'custom_get_availability', 1, 2);
    function custom_get_availability( $availability, $_product ) {
        $stock = $_product->get_stock_quantity();
        
    // Change text "In Stock' to 'In stock > 5' when quantity more than 5
        if ($_product->is_in_stock() && $stock > 5) {
    		$availability['availability'] = __('In stock > 5', 'woocommerce');
    	}
    
        return $availability;
    }
    

    The same I need for the product archive, there is still shown only “In stock”. Please see the images for the clarification.

    Best Regards

    Attachments:
    You must be logged in to view attached files.
    #440950

    Hello,

    This is Woocommerce functionality and WoodMart does not influence this option.

    You need to find a plugin or a developer who would customize the Woocommerce functionality for you.

    If you have any questions please feel free to contact us.

    Best Regards

    #441014

    atpd23
    Participant

    Hello,

    It seems it’s a WoodMart functionality because when I change theme to the Twenty Twenty-Three it disappears on shop / archive pages. Only product pages keep stock status while I have hooked it there.

    Stock status on shop / archive pages should be hooked by WoodMart I guess.

    Best Regards

    #441252

    Hello,

    You can translate/rewrite all theme and plugin texts via PO file in WordPress. Here is a video tutorial that should help you translate your website texts with a Loco Translate plugin https://www.youtube.com/watch?v=D3NsDdMzsls&list=PLMw6W4rAaOgKKv0oexGHzpWBg1imvrval&index=3

    Please check the video tutorial to see how to save the translation file correctly. You can remove the plugin and translations would remain. Also, translations would remain after each theme update.

    In order to translate the WooCommerce strings, you need to create a separate translation in Loco > Plugins > WooCommerce in the same way as shown in the video.

    Best Regards

Viewing 4 posts - 1 through 4 (of 4 total)