Filter uncanny-automator

wwlc_filter_city_field_form_label

Filters the label text for the city field on the wholesale order form to allow for customization.

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

Description

Filters the default "City" label for form fields within the Wholesale Suite integration. Developers can customize this label to better suit their site's needs or localization efforts. This hook fires during form rendering, offering flexibility in presentation.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Example of how to modify the label for the City field in the wholesale registration form.
 *
 * This filter allows you to change the default text displayed as the label for the "City" input field.
 * For instance, you might want to make it more specific, like "Your City" or "Billing City".
 *
 * @param string $label The current label for the City field. Defaults to 'City'.
 * @return string The modified label for the City field.
 */
add_filter( 'wwlc_filter_city_field_form_label', function( $label ) {
    // Example: Append " (Required)" if the city field is marked as required.
    // Note: The actual logic for determining if the field is required might be more complex in a real scenario.
    $is_required = ( get_option( 'wwlc_fields_require_address_field' ) == 'yes' ); // Simplified check for demonstration

    if ( $is_required ) {
        $label .= ' (Required)';
    }

    // You could also prepend, change entirely, or conditionally change based on other factors.
    // For example:
    // if ( is_user_logged_in() ) {
    //     $label = esc_html__( 'Your Current City', 'your-text-domain' );
    // }

    return $label;
}, 10, 1 );

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:138

'label'       => apply_filters( 'wwlc_filter_address2_field_form_label', esc_html__( 'Address line 2', 'uncanny-automator' ) ),
				'type'        => 'text',
				'required'    => false,
				'active'      => ( get_option( 'wwlc_fields_activate_address_field' ) == 'yes' ) ? true : false,
				'placeholder' => apply_filters( 'wwlc_filter_address2_field_form_placeholder', get_option( 'wwlc_fields_address2_placeholder', '' ) ),
			),
			'wwlc_city'         => array(
				'label'       => apply_filters( 'wwlc_filter_city_field_form_label', esc_html__( 'City', '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_city_field_form_placeholder', get_option( 'wwlc_fields_city_placeholder', '' ) ),
			),
			'wwlc_state'        => array(
				'label'       => apply_filters( 'wwlc_filter_state_field_form_label', esc_html__( 'State', 'uncanny-automator' ) ),


Scroll to Top