woocommerce_variation_option_name

woocommerce_variation_option_name

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.9.8.1

apply_filters('woocommerce_variation_option_name') is found 8 times:

  • /includes/admin/meta-boxes/views/html-product-data-variations.php line 55
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    <option value=""><?php echo esc_html( sprintf( __( 'No default %s&hellip;', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option>
    <?php if ( $attribute->is_taxonomy() ) : ?>
        <?php foreach ( $attribute->get_terms() as $option ) : ?>
            <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?>
            <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>
            <?php /* phpcs:enable */ ?>
        <?php endforeach; ?>
    <?php else : ?>
        <?php foreach ( $attribute->get_options() as $option ) : ?>
            <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?>
            <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>
  • /includes/admin/meta-boxes/views/html-product-data-variations.php line 61



    get_options() as $option ) : ?>




  • /includes/admin/meta-boxes/views/html-variation-admin.php line 42
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    </option>
    <?php if ( $attribute->is_taxonomy() ) : ?>
        <?php foreach ( $attribute->get_terms() as $option ) : ?>
            <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?>
            <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>
            <?php /* phpcs:enable */ ?>
        <?php endforeach; ?>
    <?php else : ?>
        <?php foreach ( $attribute->get_options() as $option ) : ?>
            <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?>
            <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>
  • /includes/admin/meta-boxes/views/html-variation-admin.php line 48



    get_options() as $option ) : ?>




  • /includes/wc-template-functions.php line 3457

    );

    foreach ( $terms as $term ) {
    if ( in_array( $term->slug, $options, true ) ) {
    $html .= ‘

    Share this:

  • /includes/wc-template-functions.php line 3464
    3460
    3461
    3462
    3463
    3464
    3465
    3466
    3467
    3468
    3469
        } else {
            foreach ( $options as $option ) {
                // This handles < 2.4.0 bw compatibility where text attributes were not sanitized.
                $selected = sanitize_title( $args&#91;'selected'&#93; ) === $args&#91;'selected'&#93; ? selected( $args&#91;'selected'&#93;, sanitize_title( $option ), false ) : selected( $args&#91;'selected'&#93;, $option, false );
                $html    .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option, null, $attribute, $product ) ) . '</option>';
            }
        }
    }
     
    $html .= '</select>';
  • /includes/wc-template-functions.php line 4096
    4092
    4093
    4094
    4095
    4096
    4097
    4098
    4099
    4100
    4101
    4102
        }
        $label = wc_attribute_label( $taxonomy );
    } else {
        // If this is a custom option slug, get the options name.
        $value = apply_filters( 'woocommerce_variation_option_name', $value, null, $taxonomy, $cart_item['data'] );
        $label = wc_attribute_label( str_replace( 'attribute_', '', $name ), $cart_item['data'] );
    }
     
    // Check the nicename against the title.
    if ( '' === $value || wc_is_attribute_in_product_name( $value, $cart_item['data']->get_name() ) ) {
        continue;
  • /src/StoreApi/Utilities/ProductItemTrait.php line 73
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
         * @param string $taxonomy Taxonomy or product attribute name.
         * @param \WC_Product $product Product data.
         * @return string
         */
        $value = apply_filters( 'woocommerce_variation_option_name', $value, null, $taxonomy, $product );
        $label = wc_attribute_label( str_replace( 'attribute_', '', $key ), $product );
    }
     
    $return[] = [
        'attribute' => $this->prepare_html_response( $label ),
        'value'     => $this->prepare_html_response( $value ),