mardi 10 octobre 2023

can't manage to solve why checkbox checked as default don't work

I'm trying to get the approve newsletter in the checkout to be checked as default and it doesn't check it. any idea why?

`function add_newsletter_checkbox() {
    // Display the newsletter checkbox
    echo '<div class="newsletter-checkbox">';
    
    woocommerce_form_field( 'newsletter_checkbox', array(
        'type'          => 'checkbox',
        'class'         => array('form-row-wide'),
        'label_class'   => array('woocommerce-form__label checkbox'),
        'input_class'   => array('woocommerce-form__input checkbox'),
        'required'      => false,
        'label'         => ('Subscribe to our newsletter', 'woocommerce' => array('default' => 1)
        'value'         => true, // Set the value for the checkbox
    ));

    echo '</div>';
}
add_action( 'woocommerce_checkout_after_terms_and_conditions', 'add_newsletter_checkbox' );
`

another thing i hope you can help me solve- on the fields that are optional at the end of the line is written '(optional)'. how can i get it off? thanks!

i tried to change the different fields of the code to get it to check as default the checkbox.




Aucun commentaire:

Enregistrer un commentaire