Filter uncanny-automator

wwlc_filter_state_field_form_placeholder

Filters the placeholder text for the state field in WooCommerce wholesale registration forms.

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

Description

This filter hook allows developers to modify the placeholder text for the state field in the Wholesale Suite registration form. Use it to customize the default placeholder or dynamically set it based on specific conditions. The default placeholder is retrieved from the WordPress option `wwlc_fields_state_placeholder`.


Usage

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

Return Value

The filtered value.


Examples

/**
 * Modify the placeholder text for the state field in the wholesale checkout form.
 *
 * This filter allows you to dynamically change the placeholder text for the
 * 'State' input field on the wholesale checkout form.
 *
 * @param string $placeholder The current placeholder text for the state field.
 * @return string The modified placeholder text.
 */
add_filter( 'wwlc_filter_state_field_form_placeholder', 'my_custom_wholesale_state_placeholder', 10, 1 );

function my_custom_wholesale_state_placeholder( $placeholder ) {
	// If the current placeholder is empty, set a default.
	// Otherwise, append some text to the existing placeholder.
	if ( empty( $placeholder ) ) {
		return 'Enter your state or province';
	} else {
		// Example: Append a hint if a placeholder is already set by another plugin or setting.
		// Be careful not to make it too long or confusing.
		return $placeholder . ' (e.g., CA, NY)';
	}
}

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

'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' ) ),
				'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_state_field_form_placeholder', get_option( 'wwlc_fields_state_placeholder', '' ) ),
			),
			'wwlc_postcode'     => array(
				'label'       => apply_filters( 'wwlc_filter_postcode_field_form_label', esc_html__( 'Postcode', '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_postcode_field_form_placeholder', get_option( 'wwlc_fields_postcode_placeholder', '' ) ),


Scroll to Top