Home › Forums › WoodMart support forum › Customize stock status on product archive
Customize stock status on product archive
- This topic has 3 replies, 2 voices, and was last updated 1 year, 10 months ago by Elise Noromit.
-
AuthorPosts
-
February 6, 2023 at 7:11 pm #440891
atpd23ParticipantHello,
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.February 7, 2023 at 5:15 am #440950
Elise NoromitMemberHello,
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
February 7, 2023 at 12:37 pm #441014
atpd23ParticipantHello,
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
February 8, 2023 at 5:07 am #441252
Elise NoromitMemberHello,
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
-
AuthorPosts
- You must be logged in to create new topics. Login / Register