-
AuthorPosts
-
October 2, 2019 at 8:17 pm #1144256
Hello,
I would like my In Stock and Out of Stock message to appear in French (when on the French translation of the website).
Right now I have both languages shown together as a temporary fix (Available / Disponible).
I would like to keep both languages separate if possible. Any suggestions?
Thank you!
}
add_action( ‘woocommerce_after_shop_loop_item_title’, ‘wcs_stock_text_shop_page’, 25 );
function wcs_stock_text_shop_page() {
global $product;
$availability = $product->get_availability();
if (!empty($availability[‘availability’])) {
$status = $availability[‘availability’] == ‘Out of stock’ ? ‘Sold’ : $availability[‘availability’];
echo apply_filters( ‘woocommerce_stock_html’, ‘<p class=”stock ‘ . esc_attr( $availability[‘class’] ) . ‘”>’ . esc_html( $status ) . ‘</p>’, $status );
}
}add_filter( ‘woocommerce_get_availability’, ‘custom_get_availability’, 1, 2);
function custom_get_availability( $availability, $_product ) {
//change text “In Stock’ to ‘Available’
if ( $_product->is_in_stock() ) $availability[‘availability’] = __(‘Disponible / Available’, ‘woocommerce’);//change text “Out of Stock’ to ‘Sold’
if ( !$_product->is_in_stock() ) $availability[‘availability’] = __(‘Vendu / Sold’, ‘woocommerce’);
return $availability;
}October 3, 2019 at 7:11 pm #1144585Hey mikepatten,
Please refer to the following:
https://kriesi.at/support/topic/woocommerce-hide-price-mark-sold-throughout-website/
Best regards,
Jordan ShannonOctober 3, 2019 at 7:58 pm #1144605I’ve already translated the individual strings so I don’t think a plugin will help. The code in functions overrides the French text.
I figure there must be a way to tweak the code.
October 3, 2019 at 8:25 pm #1144617Hey,
You would not need to add custom functions to translate that string when using WPML. Please make sure you have – https://wpml.org/documentation/related-projects/woocommerce-multilingual/ plugin activated. You can translate strings using – https://wpml.org/documentation/getting-started-guide/string-translation/
Regards,
YigitOctober 3, 2019 at 9:12 pm #1144620Yes, I have the plugin and the strings have translations.
The problem is that the functions codes does not display the languages automatically.
October 7, 2019 at 12:52 am #1145571Hi,
Perhaps try using “If” language statements, so your functions will only fire if your site is called in a certain language.
Please read this solution.Best regards,
MikeNovember 21, 2019 at 12:05 am #1158635I found the solution.
WPML > Theme and plugins localization > Scan stringsThis updated and added strings that I could add translations to.
Now its appearing properly in both languages.
November 21, 2019 at 12:22 am #1158636Hi,
I’m glad this was resolved! If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘In / out of stock language’ is closed to new replies.