WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
WooCommerce - Free Checkout Solution Here (2 posts)

  1. cruxwireweb
    Member
    Posted 2 years ago #

    Finally, I figured out how to make WooCommerce only ask for first name, last name, email address, and order notes during checkout for orders of $0. If you want to do this too, add the following code to your functions.php.

    // REMOVE FIELDS FROM WOO CHECKOUT PAGE IF ORDER TOTAL IS ZERO
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    function custom_override_checkout_fields( $fields ) {
    	global $woocommerce;
    	$my_carttotal = $woocommerce->cart->total;
    	if($my_carttotal == 0){
    		unset($fields['billing']['billing_address_1']);
    		unset($fields['billing']['billing_address_2']);
    		unset($fields['billing']['billing_city']);
    		unset($fields['billing']['billing_postcode']);
    		unset($fields['billing']['billing_country']);
    		unset($fields['billing']['billing_state']);
    		unset($fields['billing']['billing_phone']);
    		return $fields;
    	} else {
    		return $fields;
    	}
    }

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

  2. clicco
    Member
    Posted 2 years ago #

    it works but still makes appear the "undefined index" error with debug activated.

    so sad they made it so difficult to customize the checkout fileds

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.