WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
remove billing address(css ) and email field using checkbox (2 posts)

  1. clickmac
    Member
    Posted 1 year ago #

    Of course their is a field and name my_checkbox, when you tick it, value updates to "1" so i have these function after the drama ting

    Function function_hook() {
    
    	// get plugin option array and store in a variable
    	$plugin_option_array	= get_option( 'plugin_options' );
    
    	// fetch individual values from the plugin option variable array
            $my_checkbox		= $plugin_option_array[ 'my_checkbox' ];
    ?>
    
    <?php
    if ( $my_checkbox  == '1' ) {
    echo '<style type="text/css">
    #customer_details {
    display:none;
    }
    </style>';
    function override_checkout_fields($fields) {
    unset($fields['billing']['billing_email']);
    return $fields;
    }
    add_filter( 'woocommerce_checkout_fields' , 'override_checkout_fields' );
    }

    add_action( 'wp_head', 'function_hook' );

    it works yes, removes the email, when box is ticked. but after pushing the "place order" button, it gives an error of

    ===== Email Address is a required field. ======

    but i used the "unset" feature as in the documentation here

    can someone help me solve this problem?

    http://wordpress.org/extend/plugins/woocommerce/

  2. clickmac
    Member
    Posted 1 year ago #

    perhaps their is a add_action or add_filter to register that
    "woocommerce_checkout_fields"

    globally....

    or that my function named "function_hook" that is hooked onto wp_head

    should have another action to that function?

    or the add_filter( 'woocommerce_checkout_fields' , 'override_checkout_fields' );

    cannot be inside of another function....since in this case it is inside of the function_hook
    and if it is in that case that
    add_filter( 'woocommerce_checkout_fields' , 'override_checkout_fields' );
    cannot be inside of another function example function_hook

    how do i retrieve my saved values in the options.php file that was posted from the <form> so that i can use it in the

    IF statement
    example

    <?php
    if ( $my_checkbox  == '1' ) {
    echo '<style type="text/css">
    #customer_details {
    display:none;
    }
    </style>';

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.