Filter uncanny-automator

wwlc_filter_address2_field_form_label

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

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

Description

This filter hook allows developers to modify the label text for the 'Address Line 2' field within the Wholesale Lead Capture form. Use it to customize or translate this label dynamically.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Example of how to modify the "Address line 2" field label in the Wholesale Lead Capture form.
 *
 * This function intercepts the default label for the "Address line 2" field
 * and applies a custom translation or modification if needed.
 *
 * @param string $label The default label for the "Address line 2" field.
 * @return string The modified or original label for the "Address line 2" field.
 */
add_filter( 'wwlc_filter_address2_field_form_label', 'my_custom_address2_field_label', 10, 1 );

function my_custom_address2_field_label( $label ) {
    // For example, let's say we want to prepend 'Optional: ' to the label if it's not already there.
    // In a real scenario, you might use a different translation domain or context.
    if ( strpos( $label, esc_html__( 'Optional:', 'uncanny-automator' ) ) === false ) {
        // Ensure translations are handled correctly.
        $custom_label = sprintf(
            '%s %s',
            esc_html__( 'Optional:', 'uncanny-automator' ),
            $label
        );
        return $custom_label;
    }

    // If it already has 'Optional:', 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:131

'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' ) ),
				'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' ) ),


Scroll to Top