How to edit T&C checker text in Woocommerce checkout page? gettext?

I'm trying to edit wording in terms conditions checkbox on checkout page (order review section), but without luck. It was easy to edit other fields like billing and shipping fields. But I'm not sure how to target this specific TC checkbox.

For other input fields the code below works fine:

        // WooCommerce Rename Checkout Fields
    add_filter( 'woocommerce_checkout_fields' , 'custom_rename_wc_checkout_fields' );

    // Change placeholder and label text
    function custom_rename_wc_checkout_fields( $fields ) {
    $fields['billing']['billing_first_name']['placeholder'] = 'Type your first name...';
    $fields['billing']['billing_first_name']['label'] = 'Your First Name';
    return $fields;
    }

In terms conditions label, there isn't any label for="" and the text is nested in span, so how to target that specific field? HTML output for tc checkbox is:

 p class="form-row terms wc-terms-and-conditions"
     label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox"
        input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="terms" id="terms" spanPrzeczytałem/am i akceptuję a href="#" target="_blank" class="woocommerce-terms-and-conditions-link"regulamin/a/span span class="required"*/span
     /label
     input type="hidden" name="terms-field" value="1"
 /p

=========

I know that this is the question more related with Woocommerce, but maybe gettext is more generic... I also tried this code, and it didn't work:

add_filter('gettext', 'rd_translate_tc');
add_filter('ngettext', 'rd_translate_tc');

function rd_translate_tc($translated) {

   $translated = str_ireplace('Przeczytałem/am i akceptuję 
   regulamin', 'New translated content', $translated);

 return $translated;
 } 

Topic woocommerce-offtopic labels translation Wordpress

Category Web


try with this function in function.php

function ca_terms_and_conditions_checkbox_text( $option ){
        $idioma = pll_current_language();   
        if($idioma == "en"){
            $traduccion = "I have read and agree to the terms and conditions of the website and the privacy policies";
            $option = __($traduccion, 'woocommerce');
        }   
    return $option;
}

add_filter( 'woocommerce_get_terms_and_conditions_checkbox_text', 'ca_terms_and_conditions_checkbox_text' );

Woocommerce has moved some settings to the WP customizer.

Go to: WP admin menu -> Appearance -> Customizer -> Woocommerce -> Checkout.

There you can set the Privacy & Terms.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.