Move selected logic to function
This commit is contained in:
parent
befbb29106
commit
301e9339a9
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce/Templates
|
||||
* @version 3.4.0
|
||||
* @version 3.4.1
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
@ -33,18 +33,14 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
|
|||
<tbody>
|
||||
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
|
||||
<tr>
|
||||
<td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
|
||||
<td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>"><?php echo wc_attribute_label( $attribute_name ); // WPCS: XSS ok. ?></label></td>
|
||||
<td class="value">
|
||||
<?php
|
||||
$selected = isset( $_REQUEST[ 'attribute_' . $attribute_name ] ) ? wc_clean( urldecode( wp_unslash( $_REQUEST[ 'attribute_' . $attribute_name ] ) ) ) : $product->get_variation_default_attribute( $attribute_name ); // WPCS: input var ok, CSRF ok, sanitization ok.
|
||||
|
||||
wc_dropdown_variation_attribute_options( array(
|
||||
'options' => $options,
|
||||
'attribute' => $attribute_name,
|
||||
'product' => $product,
|
||||
'selected' => $selected,
|
||||
) );
|
||||
|
||||
echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a>' ) ) : '';
|
||||
?>
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue