2

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 T&C 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 t&c 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"> <span>Przeczytał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;
 } 

2 Answers 2

1

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.

0

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' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.