woocommerce_variation_option_name filter-hookWC 2.5.0

Filters the variation option name.

Filters the variation option name for custom option slugs.

Usage

add_filter( 'woocommerce_variation_option_name', 'wp_kama_woocommerce_variation_option_name_filter', 10, 4 );

/**
 * Function for `woocommerce_variation_option_name` filter-hook.
 * 
 * @param string      $value    The name to display.
 * @param null        $unused   Unused because this is not a variation taxonomy.
 * @param string      $taxonomy Taxonomy or product attribute name.
 * @param \WC_Product $product  Product data.
 *
 * @return string
 */
function wp_kama_woocommerce_variation_option_name_filter( $value, $unused, $taxonomy, $product ){

	// filter...
	return $value;
}
$value(string)
The name to display.
$unused(null)
Unused because this is not a variation taxonomy.
$taxonomy(string)
Taxonomy or product attribute name.
$product(\WC_Product)
Product data.

Changelog

Since 2.5.0 Introduced.

Where the hook is called

In file: /src/StoreApi/Utilities/ProductItemTrait.php
woocommerce_variation_option_name
woocommerce/src/StoreApi/Utilities/ProductItemTrait.php 73
$value = apply_filters( 'woocommerce_variation_option_name', $value, null, $taxonomy, $product );
woocommerce/includes/admin/meta-boxes/views/html-variation-admin.php 42
<option <?php selected( $selected_value, $option->slug ); ?> value="<?php echo esc_attr( $option->slug ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option->name, $option, $attribute->get_name(), $product_object ) ); ?></option>
woocommerce/includes/admin/meta-boxes/views/html-variation-admin.php 48
<option <?php selected( $selected_value, $option ); ?> value="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option, null, $attribute->get_name(), $product_object ) ); ?></option>
woocommerce/includes/admin/meta-boxes/views/html-product-data-variations.php 53
<option <?php selected( $selected_value, $option->slug ); ?> value="<?php echo esc_attr( $option->slug ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option->name, $option, $attribute->get_name(), $product_object ) ); ?></option>
woocommerce/includes/admin/meta-boxes/views/html-product-data-variations.php 59
<option <?php selected( $selected_value, $option ); ?> value="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option, null, $attribute->get_name(), $product_object ) ); ?></option>
woocommerce/includes/wc-template-functions.php 3245
$html .= '<option value="' . esc_attr( $term->slug ) . '" ' . selected( sanitize_title( $args['selected'] ), $term->slug, false ) . '>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name, $term, $attribute, $product ) ) . '</option>';
woocommerce/includes/wc-template-functions.php 3252
$html    .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option, null, $attribute, $product ) ) . '</option>';
woocommerce/includes/wc-template-functions.php 3870
$value = apply_filters( 'woocommerce_variation_option_name', $value, null, $taxonomy, $cart_item['data'] );

Where the hook is used in WooCommerce

Usage not found.