• Hello!
    I need help adjusting the Privacy policy checkbox and the text to it. When I put the the code in my functions.php file, the box appears to be above the text. I think that the input should be outside of the label, but I don’t know how to fix it.
    The code I am using is:

    add_action( 'woocommerce_review_order_before_submit', 'add_privacy_checkbox', 9 );
    function add_privacy_checkbox() {
    woocommerce_form_field( 'privacy_policy', array(
    	'type' => 'checkbox',
    	'class' => array('form-row privacy'),
    	'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
    	'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
    	'label' => 'random text alongside url.</a>',	
    	'required' => true,
    
    ));
    }
    add_action( 'woocommerce_checkout_process', 'privacy_checkbox_error_message' );
    function privacy_checkbox_error_message() {
    if ( ! (int) isset( $_POST['privacy_policy'] ) ) {
    wc_add_notice( __( 'Random text' ), 'error' );
    }
    }

    Thank you in advance!
    Alex

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • AddWeb Solution

    (@addweb-solution-pvt-ltd)

    Hi,
    change your woocommerce_form_field() with this code. It will work for you.

    woocommerce_form_field( 'privacy_policy', array(
        'type' => 'checkbox',
        'class' => array('form-row privacy'),
        'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
        'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
        'required' => true,
        'label' => 'random text alongside url.',
    ));
    Thread Starter alexheltify

    (@alexheltify)

    Hi,
    Thank you for your reply, but I’ve tried it and it didn’t work.

    AddWeb Solution

    (@addweb-solution-pvt-ltd)

    Hello, Please use the below code, which I have tried and tested locally. Hope it will work well for you.

    woocommerce_form_field( 'privacy_policy', array(
        'type' => 'checkbox',
        'class' => array('form-row privacy'),
        'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
        'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
        'label' => '<font style="vertical-align: inherit;">
        <font style="vertical-align: inherit;">I agree that my personal data will be used to execute the order. </font>	<font style="vertical-align: inherit;">At the same time, I read and agreed </font>
    </font>
    <a href="https://heltify.com/politika-za-poveritelnost/">
    <font style="vertical-align: inherit;">
    <font style="vertical-align: inherit;">to the Privacy Policy. </font>
    </font>
    </a>&nbsp;',	
        'required' => true,
    ));
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Privacy policy checbox align’ is closed to new replies.