Created
December 20, 2023 12:47
-
-
Save autocircled/77eb178da89508f9bd4c8911c12eb7d5 to your computer and use it in GitHub Desktop.
Checkout page customize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make postal code optional | |
add_filter( 'woocommerce_default_address_fields', 'customize_extra_fields', 1000, 1 ); | |
function customize_extra_fields( $address_fields ) { | |
$address_fields['postcode']['required'] = false; //Postcode | |
return $address_fields; | |
} | |
// Hide checkout fields | |
function reorder_billing_fields($fields) { | |
$billing_order = [ | |
'billing_first_name', | |
'billing_last_name', | |
'billing_email', | |
// 'billing_company', | |
'billing_country', | |
'billing_address_1', | |
// 'billing_address_2', | |
// 'billing_city', | |
// 'billing_state', | |
'billing_postcode', | |
'billing_phone' | |
]; | |
foreach ($billing_order as $field) { | |
if('billing_phone' == $fields['billing'][$field]){ | |
} | |
$ordered_fields[$field] = $fields['billing'][$field]; | |
} | |
$ordered_fields['billing_phone']['required'] = false; | |
$fields['billing'] = $ordered_fields; | |
return $fields; | |
} | |
add_filter('woocommerce_checkout_fields', 'reorder_billing_fields'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment