• Resolved khan11177

    (@khan11177)


    Hello,
    I am trying to Put conditions on checkout fields because they are needed to be compliant with the regulations. This code works fine but i can’t break line to that conditions will appear on separate pages.Please help me if it’s possible.. Below you can find where i need a break.

    add_action(‘woocommerce_checkout_before_terms_and_conditions’, ‘checkout_additional_checkboxes’);
    function checkout_additional_checkboxes( ){
    $checkbox1_text = __( “My first checkbox text”, “woocommerce”);

    <////////// I need to break this above line from the line below.

    $checkbox2_text = __( “My Second checkbox text”, “woocommerce” );
    ?>
    <p class=”form-row custom-checkboxes”>
    <label class=”woocommerce-form__label checkbox custom-one”>
    <input type=”checkbox” class=”woocommerce-form__input woocommerce-form__input-checkbox input-checkbox” name=”custom_one” > <span><?php echo $checkbox1_text; ?></span> <span class=”required”>*</span>
    </label>
    <label class=”woocommerce-form__label checkbox custom-two”>
    <input type=”checkbox” class=”woocommerce-form__input woocommerce-form__input-checkbox input-checkbox” name=”custom_two” > <span><?php echo $checkbox2_text; ?></span> <span class=”required”>*</span>
    </label>
    </p>
    <?php
    }

    add_action(‘woocommerce_checkout_process’, ‘my_custom_checkout_field_process’);

    function my_custom_checkout_field_process() {
    // Check if set, if its not set add an error.
    if ( ! $_POST[‘custom_one’] )
    wc_add_notice( __( ‘You must accept “My first checkbox”.’ ), ‘error’ );
    if ( ! $_POST[‘custom_two’] )
    wc_add_notice( __( ‘You must accept “My second checkbox”.’ ), ‘error’ );
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support EastOfWest a11n

    (@eastofwest)

    Hi there,

    I implemented your code on my sandbox site, and here’s how it displays in the Storefront theme:

    Screenshot showing a rendering of the posted code

    If by “linebreak” you mean space between the elements, then you can achieve that with CSS. In fact, if they appear in one continuous line in the theme you’re using, that’s probably due to some CSS that’s overriding the default style. This should fix it:

    .form-row label.custom-one,
     .form-row label.custom-two {
        display: block;
    }

    You can add to that rule margin:5px 0; or something along those lines to increase the space between the two lines too.

    Thread Starter khan11177

    (@khan11177)

    @eastofwest Yes sir they appear in a single line and i tried your suggested css and it did not work even with some variations.

    Can you please tell me one more thing? The text which i will put in checkboxes is really long, is there is a way to hide long text and show just the beginning and write “Read more”?

    Plugin Support mouli a11n

    (@mouli)

    @khan11177

    Can you please tell me one more thing? The text which i will put in checkboxes is really long, is there is a way to hide long text and show just the beginning and write “Read more”?

    This would require some custom coding so I would suggest that you get in touch with a web developer using the resources below.

    For assistance with customization or development with your site, we recommend that you seek help from:

    * A local web developer
    * Codeable.io (https://woocommerce.com/codeable/) who offer free estimates
    * WooExperts (http://www.woocommerce.com/experts/)
    * Stackexchange (http://wordpress.stackexchange.com/help/on-topic)

    they appear in a single line and i tried your suggested css and it did not work even with some variations.

    Please can you send us a link to the page so we can check the CSS directly.

    We look forward to hearing back from you.

    Plugin Support Damianne P (a11n)

    (@drwpcom)

    Hi @khan11177. I hope that you have managed to resolve the issue. Since we haven’t heard from you in a while, I’m going to go ahead and mark this thread as resolved. If you still need help with this issue or have any other questions about the WooCommerce plugin, please start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Woocommerce Line Break’ is closed to new replies.