Filter uncanny-automator

wwlc_filter_address1_field_form_label

Filters the label for the Address Line 1 field on the wholesale checkout form.

add_filter( 'wwlc_filter_address1_field_form_label', $callback, 10, 1 );

Description

Filters the default label for the "Address line 1" field in Wholesale Suite forms. Developers can modify this label to customize its appearance, perhaps for internationalization or specific branding. This hook fires when the Address line 1 field's label is being defined.


Usage

add_filter( 'wwlc_filter_address1_field_form_label', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Filters the label for the 'Address line 1' field in a form.
 *
 * This function modifies the default label for the 'Address line 1' field,
 * allowing for dynamic changes based on user roles or other conditions.
 *
 * @param string $label The original label for the 'Address line 1' field.
 * @return string The modified label for the 'Address line 1' field.
 */
add_filter( 'wwlc_filter_address1_field_form_label', 'my_custom_address1_label', 10, 1 );

function my_custom_address1_label( $label ) {
	// Example: If the current user has a specific role, change the label.
	if ( is_user_logged_in() ) {
		$user = wp_get_current_user();
		if ( in_array( 'wholesale_customer', (array) $user->roles ) ) {
			return esc_html__( 'Your Primary Street Address', 'uncanny-automator' );
		}
	}

	// Otherwise, return the original label.
	return $label;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/integrations/wholesale-suite/helpers/wholesale-suite-helpers.php:124

'label'    => apply_filters( 'wwlc_filter_country_field_form_label', esc_html__( 'Country', 'uncanny-automator' ) ),
				'type'     => 'select',
				'required' => ( get_option( 'wwlc_fields_require_address_field' ) == 'yes' ) ? true : false,
				'active'   => ( get_option( 'wwlc_fields_activate_address_field' ) == 'yes' ) ? true : false,
				'options'  => $countryList,
			),
			'wwlc_address'      => array(
				'label'       => apply_filters( 'wwlc_filter_address1_field_form_label', esc_html__( 'Address line 1', 'uncanny-automator' ) ),
				'type'        => 'text',
				'required'    => ( get_option( 'wwlc_fields_require_address_field' ) == 'yes' ) ? true : false,
				'active'      => ( get_option( 'wwlc_fields_activate_address_field' ) == 'yes' ) ? true : false,
				'placeholder' => apply_filters( 'wwlc_filter_address1_field_form_placeholder', get_option( 'wwlc_fields_address_placeholder', '' ) ),
			),
			'wwlc_address_2'    => array(
				'label'       => apply_filters( 'wwlc_filter_address2_field_form_label', esc_html__( 'Address line 2', 'uncanny-automator' ) ),


Scroll to Top