Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


how to show/hide billing details when delivery shipping

2 Answers

You will need to know things

  1. Override woocommerce checkout page.
  2. Working with if-else statements.

Alternatively, you can try this plugin https://wordpress.org/plugins/woohide-hide-billing-fields/

What class to use in functions.php

find code but not working for some reason

add_filter('woocommerce_checkout_fields', 'xa_remove_billing_checkout_fields');

function xa_remove_billing_checkout_fields($fields) { $shipping_method ='free_shipping:1'; // Set the desired shipping method to hide the checkout field(s). global $woocommerce; $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); $chosen_shipping = $chosen_methods[0];

if ($chosen_shipping == $shipping_method) {
    unset($fields['billing']['billing_address_1']); // Add/change filed name to be hide
return $fields;


I need to first understand what are the two shipping methods. I understand the 2nd shipping method is delivery. Then, what is the first shipping method? Local pickup?

And can you share the url of the checkout page?

first is mail second is omniva post