$options ) : $loop++; ?> get_id(), $attribute_name, $options, $available_variations, $swatches_use_variation_images); $active_variations = woodmart_get_active_variations( $attribute_name, $available_variations ); ?>
get_id(), $attribute_name, array( 'fields' => 'all' ) ); $swatch_size = woodmart_wc_get_attribute_term( $attribute_name, 'swatch_size' ); $_i = 0; $options_fliped = array_flip( $options ); foreach ( $terms as $term ) { if ( ! in_array( $term->slug, $options ) ) { continue; } $key = $options_fliped[$term->slug]; $style = ''; $class = 'wd-swatch swatch-on-single '; $class .= woodmart_get_old_classes( ' woodmart-swatch ' ); if( ! empty( $swatches[$key]['color'] )) { $class .= 'swatch-with-bg'; if ( ! woodmart_get_opt( 'swatches_labels_name' ) ) { $class .= ' wd-tooltip'; } $style = 'background-color:' . $swatches[$key]['color']; } else if( $swatches_use_variation_images && $grid_swatches_attribute == $attribute_name && isset( $swatches[$key]['image_src'] ) ) { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $swatches[$key]['variation_id'] ), 'woocommerce_thumbnail'); if ( !empty( $thumb ) ) { $style = 'background-image: url(' . $thumb[0] . ')'; $class .= ' swatch-with-bg'; if ( ! woodmart_get_opt( 'swatches_labels_name' ) ) { $class .= ' wd-tooltip'; } } } else if( ! empty( $swatches[$key]['image'] )) { $class .= 'swatch-with-bg'; $style = 'background-image: url(' . $swatches[$key]['image'] . ')'; if ( ! woodmart_get_opt( 'swatches_labels_name' ) ) { $class .= ' wd-tooltip'; } } else if( ! empty( $swatches[$key]['not_dropdown'] ) ) { $class .= ' text-only'; } $class .= ' swatch-size-' . $swatch_size; if ( $selected_value == $term->slug ) { $class .= ' active-swatch'; } if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && $active_variations ) { if ( in_array( $term->slug, $active_variations ) ) { $class .= ' swatch-enabled'; } else { $class .= ' swatch-disabled'; } } $title = woodmart_get_opt( 'swatches_labels_name' ) ? 'title="' . $term->name . '"' : ''; echo '
slug ), false ) . ' style="' . esc_attr( $style ) .'">' . apply_filters( 'woocommerce_variation_option_name', $term->name ) . '
'; $_i++; } } else { foreach ( $options as $option ) { $class = ''; if ( $selected_value == $option ) { $class .= ' active-swatch'; } if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && $active_variations ) { if ( in_array( $term->slug, $active_variations ) ) { $class .= ' swatch-enabled'; } else { $class .= ' swatch-disabled'; } } $title = woodmart_get_opt( 'swatches_labels_name' ) ? 'title="' . $term->name . '"' : ''; echo '
' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . '
'; } } } ?>
$options, 'attribute' => $attribute_name, 'product' => $product, ) ); echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '' . esc_html__( 'Clear', 'woocommerce' ) . '' ) ) : ''; ?>