Merge pull request #21153 from jamesckemp/patch-12
`woocommerce_variation_option_name` Parameters
This commit is contained in:
commit
f4ed56a894
|
@ -33,11 +33,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<option value=""><?php echo esc_html( sprintf( __( 'No default %s…', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option>
|
||||
<?php if ( $attribute->is_taxonomy() ) : ?>
|
||||
<?php foreach ( $attribute->get_terms() as $option ) : ?>
|
||||
<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>
|
||||
<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 endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?php foreach ( $attribute->get_options() as $option ) : ?>
|
||||
<option <?php selected( $selected_value, $option ); ?> value="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ); ?></option>
|
||||
<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>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
|
|
@ -35,11 +35,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
</option>
|
||||
<?php if ( $attribute->is_taxonomy() ) : ?>
|
||||
<?php foreach ( $attribute->get_terms() as $option ) : ?>
|
||||
<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>
|
||||
<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 endforeach; ?>
|
||||
<?php else : ?>
|
||||
<?php foreach ( $attribute->get_options() as $option ) : ?>
|
||||
<option <?php selected( $selected_value, $option ); ?> value="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ); ?></option>
|
||||
<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>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
|
|
@ -2908,14 +2908,14 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
|
|||
|
||||
foreach ( $terms as $term ) {
|
||||
if ( in_array( $term->slug, $options, true ) ) {
|
||||
$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 ) ) . '</option>';
|
||||
$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>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ( $options as $option ) {
|
||||
// This handles < 2.4.0 bw compatibility where text attributes were not sanitized.
|
||||
$selected = sanitize_title( $args['selected'] ) === $args['selected'] ? selected( $args['selected'], sanitize_title( $option ), false ) : selected( $args['selected'], $option, false );
|
||||
$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . '</option>';
|
||||
$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option, null, $attribute, $product ) ) . '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3406,7 +3406,7 @@ function wc_get_formatted_cart_item_data( $cart_item, $flat = false ) {
|
|||
$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 );
|
||||
$value = apply_filters( 'woocommerce_variation_option_name', $value, null, $taxonomy, $cart_item['data'] );
|
||||
$label = wc_attribute_label( str_replace( 'attribute_', '', $name ), $cart_item['data'] );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue