vendredi 16 août 2019

Woocommerce checkout checkbox if checked show information/warning

Im new in this coding stuff, I researched many sites now and try to build my own checkout field in Woocommerce. It should be a checkout field, when it is checked, some information or warning should plop up, it worked with showing on checkout page normal, but my script doesn't work.

add_filter( 'woocommerce_checkout_fields', 'add_custom_checkout_fields' ); function add_custom_checkout_fields( $fields ) {

$fields['billing']['checkbox_trigger'] = array(
    'type'      => 'checkbox',
    'label'     => __('You dont live in Germany?', 'woocommerce'),
    'class'     => array('form-row-wide'),
    'clear'     => true
);
return $fields;

} add_action( 'woocommerce_after_checkout_billing_form', 'echo_notice_billing' );

function echo_notice_billing() { echo 'It may take forever'; }

add_action( 'woocommerce_after_checkout_form', 'show_notice_billing' );

function show_notice_billing(){

?>
    <script>
    jQuery(document).ready(function($){

        $('checkbox_trigger').change(function(){

            if(this.checked){
                $('billing-notice').show();
            }
            else {
                $('billing-notice').hide();
            }
        });

    });
</script>

<?php

}




Aucun commentaire:

Enregistrer un commentaire