Author: bibhu 385 views

The  rpress_purchase_form_required_fields filter is used to change the fields required for purchase in checkout field.

Modifying the Required Checkout Fields

During checkout, there are several required fields based on the options displayed in checkout. The standard fields that are required are email and the first name. If it is from not registering an account, then username and password are also required. By default, the last name field is not required, but it can be easily made that way. You can also set the first name to not be required.

This code snippet illustrates how to make the last name field required:

For example,

function pw_rpress_purchase_form_required_fields( $required_fields ) {
$required_fields[‘rpress_last’] = array(
‘error_id’ => ‘invalid_last_name’,
‘error_message’ => __( ‘Please enter your last name.’, ‘restropress’ )
return $required_fields;
add_filter( ‘rpress_purchase_form_required_fields’, ‘pw_rpress_purchase_form_required_fields’ );