Home / Forums / WoodMart support forum / I cannot change the stock availability text in the product catalog
Home › Forums › WoodMart support forum › I cannot change the stock availability text in the product catalog
I cannot change the stock availability text in the product catalog
- This topic has 7 replies, 2 voices, and was last updated 1 year, 10 months ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
August 21, 2024 at 6:02 pm #591595
ssxwebmasterParticipantCan you please help me out here?
i am trying to change the stock status text in the product catalog page but i cannot find the hook needed to do it.i have the following code snippet below that works just fine in the product page…. but i can’t for the life of me figure out how to change the text in the catalog page….
here is the snippet
add_filter( ‘woocommerce_get_availability_text’, ‘custom_get_availability_text’, 100, 2 );
function custom_get_availability_text( $availability, $product ) {
if ( $product->get_stock_quantity() <= 0 ) {
$custom_availability = $product->get_attribute( ‘prime-custom-availability’ );if ( empty( $custom_availability ) ) {
$availability = ‘Not available’;
} else {
$availability = $custom_availability;
}
}
else {
$availability = ‘Express Delivery’;
}return $availability;
}August 22, 2024 at 10:10 am #591666Hello,
Please use the Loco translate plugin on your site. After installing the plugin please Navigate to Loco >> Themes >> Woodmart >> Edit the translation which you are using for the site >> Click the Sync button >> Find the words and add the translation for them and save it.
Also, please Navigate to Loco >> Plugins >> Woocommerce >> Edit the translation which you are using for the site >> Click the Sync button >> Find the words and add the translation for them and save it.
Also, please Navigate to Loco >> Plugins >> Woodmart-Core >> Edit the translation which you are using for the site >> Click the Sync button >> Find the words and add the translation for them and save it.
https://wordpress.org/plugins/loco-translate/
Note:
1. Custom (recommended)
2. This is Loco’s protected folder under “wp-content/languages/loco/” which is safe from automatic updates and provides priority over the above locations.
https://localise.biz/wordpress/plugin/manual/msginit?utm_medium=plugin&utm_campaign=wp&utm_source=admin&utm_content=plugin-msginit#order
If this folder doesn’t exist you may need to create it and ensure it has the correct permissions.
https://localise.biz/wordpress/plugin/manual/filesystemIf the issue still exists then please send me the WP admin login details of your site so I will check and solve the issue for you.
For more information please read the theme documentation here:
https://xtemos.com/docs-topic/translate-woodmart-theme-with-loco-translate/Best Regards.
August 22, 2024 at 11:24 am #591704
ssxwebmasterParticipantdid you read my post?
Loco has NOTHING to do with what i want. i don’t want a translation… i want a custom code.
i need to change through a code snippet, what it says there based on a custom availability field.
please read my code and tell me why your products archive in product catalog, doesn’t use the “woocommerce_get_availability_text” hook.August 22, 2024 at 1:11 pm #591741Hello,
Please send me the WP admin login details of your site so I will check and solve the issue for you.
Best Regards.
August 22, 2024 at 1:49 pm #591757
ssxwebmasterParticipantAizaz you don’t need WP admin details, you can test what i am saying with your demos
here…
https://woodmart.xtemos.com/mega-electronics/product-category/laptops-tablets-pcs/check the attached screenshot and the url of your demo and you will understand what i am talking about.
i want my code snippet (the one i provided above) to be able to change the text from the “In Stock” field to my custom availability.
i know that the snippet works just fine because if i use it in the product page which uses the hook “woocommerce_get_availability_text”, it works just fine.
it doesn’t work in your product catalog
Attachments:
You must be logged in to view attached files.August 23, 2024 at 12:48 pm #592017Hello,
THere is no need to use the snippet code to change the text or words in the theme. You can easily change it everywhere on the site by using a simple Translation plugin.
If you want to use the code then it requires customizations and this is beyond our limitations and support policy.
Regards.
Xtemos StudiosAugust 23, 2024 at 5:14 pm #592127
ssxwebmasterParticipantAizaz,
i don’t know how more specific i can be.
i don’t want to TRANSLATE the status…
i want to manipulate it EXACTLY like i did at the product page. The code above works! but only in the product page.Manipulate by change the text based on conditions coming from a woocommerce HOOK.
have you spend 1 minute reading carefully the code snippet i gave you above? have you tried to actually understand what i am saying above?
is there an actual support department or am i stuck with just you? because clearly there is a communication issue.
you are playing dumb and now you threw the “beyond our limitations” card. and it has taken us 3 days!i am asking a very specific question that requires an answer from your development team.
August 26, 2024 at 10:41 am #592476Hello,
Unfortunately, this hook does not work with our stock status; this was done intentionally and cannot be fixed.
However, if you need to modify it, you can copy the
woodmart_stock_status_after_title()function frominc/integrations/woocommerce/template-tags.phpat line 2482 into your child theme and customize it according to your needs.Best Regards.
-
AuthorPosts
Tagged: availability, custom, status, stock
- You must be logged in to create new topics. Login / Register