Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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;
    }

    #1144585

    Hey mikepatten,

    Please refer to the following:

    https://kriesi.at/support/topic/woocommerce-hide-price-mark-sold-throughout-website/

    Best regards,
    Jordan Shannon

    #1144605

    I’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.

    #1144617

    Hey,

    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,
    Yigit

    #1144620

    Yes, I have the plugin and the strings have translations.

    The problem is that the functions codes does not display the languages automatically.

    #1145571

    Hi,
    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,
    Mike

    #1158635

    I found the solution.
    WPML > Theme and plugins localization > Scan strings

    This updated and added strings that I could add translations to.

    Now its appearing properly in both languages.

    #1158636

    Hi,

    I’m glad this was resolved! If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘In / out of stock language’ is closed to new replies.