• Daniel P.

    (@danidub)


    Hello, we tried everything to change the “No shipping method available” text using the “new” block based checkout. Even the hooks of the legacy checkout (that didn’t work either).

    Any ideas on how to change this message?

    Thank you.

    • This topic was modified 3 days ago by Daniel P..
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Hi Daniel

    I don’t think this string can be translated in the editor because it appears only when needed, but there are ways to translate strings using filters in JavaScript.

    This documentation covers it: https://developer.www.ads-software.com/block-editor/reference-guides/filters/i18n-filters/#basic-example

    I just tested this myself in the browser console and it worked:

    function myPluginGettextFilter( translation, text, domain ) {
    if ( text === 'No shipping options are available for this address. Please verify the address is correct or try a different address.' ) {
    return 'This is your replacement text';
    }
    return translation;
    }

    wp.hooks.addFilter(
    'i18n.gettext',
    'my-plugin/override-add-to-reusable-blocks-label',
    myPluginGettextFilter
    );

    Hope that helps.

    Thread Starter Daniel P.

    (@danidub)

    Hi @mikejolley,

    Thank you for answering. I’ve tried the JS snippet in my browser without any luck. We have the checkout in Spanish so the messages we need to translate are:

    • “A?ade una dirección de envío para ver las opciones de envío.”
    • No hay opciones de envío disponibles

    I’ve tried any string but nothing changes in the frontend:

    function myPluginGettextFilter( translation, text, domain ) {
    if ( text === 'No hay opciones de envío disponibles' ) {
    return 'Some different text';
    }
    return translation;
    }

    // Adding the filter
    wp.hooks.addFilter(
    'i18n.gettext',
    'my-plugin/override-add-to-reusable-blocks-label',
    myPluginGettextFilter
    );

    Any ideas?

    Thank you again.

    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    I understand your concern. I tested the above code on my site, and it’s not working correctly either. However, I was able to successfully change the text using the Loco Translate plugin, as demonstrated in this screenshot: https://go.screenpal.com/watch/cZXr6AnVy6g.

    Could you please try using the Loco Translate plugin to update the text? If you prefer not to use the plugin and want a code-based solution, please note that we don’t provide support for customizations.

    If you need more in-depth support or want to consider professional assistance for customization, I can recommend?WooExperts?and?Codeable.io?as options for getting professional help. Alternatively, you can also ask your development questions in the??WooCommerce Community Slack?as custom code falls outside our usual?scope of support.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.