Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 435 Vote(s) - 3.34 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make checkout fields required in Woocommerce checkout

#1
For some reason, all the fields in Billing Address are marked as optional - customers are leaving the billing address fields blank and then their payments are being rejected (by Square, who is our payment processor).

I cannot find anywhere to make these fields required, and cannot figure out why they would be marked as optional in any case.

Can someone point me in the right direction?

UPDATE

I've even tried the following:

add_filter('woocommerce_billing_fields', 'force_billing_fields', 1000, 1);
function force_billing_fields($fields) {
$fields['billing_first_name']['required'] = true;
$fields['billing_last_name']['required'] = true;
$fields['billing_address_1']['required'] = true;
$fields['billing_city']['required'] = true;
$fields['billing_postcode']['required'] = true;
$fields['billing_country']['required'] = true;
$fields['billing_state']['required'] = true;
$fields['billing_email']['required'] = true;
$fields['billing_phone']['required'] = true;

return $fields;
}

And they're still marked as optional, except the billing phone and country are now marked as required. But the rest are still optional.
Reply

#2
What you can do if you don't find the guilty as explained on my comment is to use the following *(using here a highest hook priority if some other code is already using those hooks)*:

add_filter( 'woocommerce_default_address_fields', 'customising_checkout_fields', 1000, 1 );
function customising_checkout_fields( $address_fields ) {
$address_fields['first_name']['required'] = true;
$address_fields['last_name']['required'] = true;
$address_fields['company']['required'] = true;
$address_fields['country']['required'] = true;
$address_fields['city']['required'] = true;
$address_fields['state']['required'] = true;
$address_fields['postcode']['required'] = true;

return $address_fields;
}

Code goes in function.php file of your active child theme (or active theme). tested and works.

For billing phone and email you can try

add_filter('woocommerce_billing_fields', 'custom_billing_fields', 1000, 1);
function custom_billing_fields( $fields ) {
$fields['billing_email']['required'] = true;
$fields['billing_phone']['required'] = true;

return $fields;
}

or

add_filter('woocommerce_checkout_fields', 'custom_billing_fields', 1000, 1);
function custom_billing_fields( $fields ) {
$fields['billing']['billing_email']['required'] = true;
$fields['billing']['billing_phone']['required'] = true;

return $fields;
}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through