I’m currently using the Salient theme with WooCommerce, and I would like to make the Phone field under the Shipping Address section of the checkout form mandatory. At the moment, the field is labeled as "Phone (optional)", and customers can proceed without entering it. I’ve tried the following approaches in my functions.php, but none of them have worked:
Unfortunately, these snippets don’t make the field required at checkout. Could you please guide me on the correct way to make the shipping phone field required, ideally via functions.php or using any available option in Salient?
Dear Salient Theme Support,
I’m currently using the Salient theme with WooCommerce, and I would like to make the Phone field under the Shipping Address section of the checkout form mandatory.
At the moment, the field is labeled as "Phone (optional)", and customers can proceed without entering it.
I’ve tried the following approaches in my functions.php, but none of them have worked:
1.
add_filter( 'woocommerce_checkout_fields', 'salient_require_shipping_phone' ); function salient_require_shipping_phone( $fields ) { $fields['shipping']['shipping_phone']['required'] = true; return $fields; }
2.
add_filter( 'woocommerce_shipping_fields', 'make_shipping_phone_required' ); function make_shipping_phone_required( $fields ) { $fields['shipping_phone']['required'] = true; return $fields; }
3.
add_filter('woocommerce_checkout_get_value', 'ts_populate_shipping_phone', 10, 2);
function ts_populate_shipping_phone($value, $input) { if ( 'shipping_phone' === $input ) { $value = WC()->customer->get_shipping_phone(); } return $value;
}
Unfortunately, these snippets don’t make the field required at checkout.
Could you please guide me on the correct way to make the shipping phone field required, ideally via functions.php or using any available option in Salient?
Your support is much appreciated.
Best regards,
Hey parisorn ,
Thanks for reaching out! .
Could you confirm if you are using the Block Checkout or the Legacy Shortcode: https://themenectar.com/docs/salient/using-legacy-woocommerce-cart-checkout/ ? .
Best,
Salient Support Team
No, we are using block checkout
Be sure to use the Legacy one for the filters to work .
Thanks
Salient Support Team
We use Legacy one then what is next we should do to get what we requests
Try using this filter and check:
Best,
Salient Support Team