$available_variation ) { if ( ! empty( $available_variation['is_in_stock'] ) ) { $available_variations_new[] = $available_variation; } } $variations_json = wp_json_encode( $available_variations_new ) ; } else { $variations_json = wp_json_encode( $available_variations ); } $attribute_keys = array_keys( $attributes ); $variations_attr = function_exists( 'wc_esc_json' ) ? wc_esc_json( $variations_json ) : _wp_specialchars( $variations_json, ENT_QUOTES, 'UTF-8', true ); // start Woodmart code. $is_builder = Builder::get_instance()->has_custom_layout( 'single_product' ); $is_quick_shop = wp_doing_ajax() && isset( $_REQUEST['action'] ) && 'woodmart_quick_shop' === $_REQUEST['action'] && woodmart_get_opt( 'quick_shop_variable' ); // phpcs:ignore $is_quick_shop2 = isset( $wd_swatches_limits ); $is_quick_view = woodmart_loop_prop( 'is_quick_view' ); $swatches_use_variation_images = woodmart_get_opt( 'swatches_use_variation_images' ); $grid_swatches_attribute = woodmart_grid_swatches_attribute(); $form_classes = ''; $wd_reset_classes = ''; $swatch_limit = false; $is_single_product = true; $more_limit_swathes = (int) apply_filters( 'woodmart_show_more_limit_swatches_count', 1 ); if ( $is_quick_shop2 ) { if ( ! empty( $wd_swatches_limits ) ) { $swatch_limit = (int) $wd_swatches_limits; } $is_single_product = false; $form_classes .= ' wd-quick-shop-2'; $form_classes .= ' wd-clear-' . woodmart_get_opt( 'quick_shop_clear_action', 'none' ); } elseif ( ! $is_quick_shop && woodmart_get_opt( 'single_product_swatches_limit' ) ) { $swatch_limit = (int) woodmart_get_opt( 'single_product_swatches_limit_count', 10 ); } if ( $is_quick_shop ) { $form_classes .= ' wd-reset-bottom-lg wd-reset-bottom-md wd-label-top-lg wd-label-top-md'; } if ( woodmart_get_opt( 'swatches_labels_name' ) ) { $form_classes .= ' wd-swatches-name'; } if ( ! $is_quick_shop && ! $is_quick_shop2 ) { if ( woodmart_get_opt( 'single_product_variations_price' ) ) { woodmart_enqueue_js_script( 'variations-price' ); $form_classes .= ' wd-price-outside'; } } if ( $is_builder ) { if ( ! empty( Builder_Data::get_instance()->get_data( 'form_classes' ) ) ) { $form_classes .= Builder_Data::get_instance()->get_data( 'form_classes' ); } } else { if ( 'default' === woodmart_get_opt( 'product_design' ) && ! $is_quick_shop ) { $form_classes .= ' wd-reset-side-lg'; } } if ( ! $is_quick_shop && ! $is_builder && ! $is_quick_shop2 ) { if ( 'default' === woodmart_get_opt( 'product_design' ) ) { $form_classes .= ' wd-reset-bottom-md wd-label-top-md'; if ( woodmart_get_opt( 'swatches_labels_name' ) ) { $form_classes .= ' wd-label-top-lg'; } } elseif ( 'alt' === woodmart_get_opt( 'product_design' ) ) { $form_classes .= ' wd-reset-bottom-lg wd-reset-bottom-md wd-label-top-lg wd-label-top-md'; } } if ( $is_quick_view ) { $form_classes = ' wd-reset-side-lg wd-reset-bottom-md wd-label-top-md'; if ( 'default' === woodmart_get_opt( 'product_design' ) && woodmart_get_opt( 'swatches_labels_name' ) ) { $form_classes .= ' wd-label-top-lg'; } } woodmart_enqueue_js_library( 'tooltips' ); woodmart_enqueue_js_script( 'btns-tooltips' ); if ( ! isset( $wd_swatches_limits ) ) { woodmart_enqueue_js_script( 'swatches-variations' ); } // end Woodmart code. woodmart_enqueue_inline_style( 'woo-mod-variation-form' ); woodmart_enqueue_inline_style( 'woo-mod-swatches-base' ); if ( is_product() || $is_quick_view ) { woodmart_enqueue_inline_style( 'woo-mod-variation-form-single' ); } do_action( 'woocommerce_before_add_to_cart_form' ); ?>

$options ) : ?> get_id(), $attribute_name, $options, $available_variations, $swatches_use_variation_images ); $active_variations = woodmart_get_active_variations( $attribute_name, $available_variations ); $swatch_size = woodmart_wc_get_attribute_term( $attribute_name, 'swatch_size' ); $swatch_dis_style = woodmart_wc_get_attribute_term( $attribute_name, 'swatch_dis_style' ); $swatch_style = woodmart_wc_get_attribute_term( $attribute_name, 'swatch_style' ); $swatch_shape = woodmart_wc_get_attribute_term( $attribute_name, 'swatch_shape' ); $swatch_change_image = woodmart_wc_get_attribute_term( $attribute_name, 'change_image' ); $wrapper_class = woodmart_get_old_classes( ' swatches-on-single' ); if ( taxonomy_exists( $attribute_name ) ) { if ( ! $swatch_style ) { $swatch_style = '1'; } if ( ! $swatch_dis_style ) { $swatch_dis_style = '1'; } if ( ! $swatch_size ) { $swatch_size = 'default'; } if ( ! $swatch_shape ) { $swatch_shape = 'round'; } woodmart_enqueue_inline_style( 'woo-mod-swatches-style-' . $swatch_style ); woodmart_enqueue_inline_style( 'woo-mod-swatches-dis-' . $swatch_dis_style ); if ( $is_single_product ) { $wrapper_class .= ' wd-swatches-single'; } else { $wrapper_class .= ' wd-swatches-grid'; } $wrapper_class .= ' wd-bg-style-' . $swatch_style; $wrapper_class .= ' wd-text-style-' . $swatch_style; $wrapper_class .= ' wd-dis-style-' . $swatch_dis_style; $wrapper_class .= ' wd-size-' . $swatch_size; $wrapper_class .= ' wd-shape-' . $swatch_shape; if ( $swatch_limit && is_array( $options ) && ( array_key_first( $attributes ) === $attribute_name || $is_single_product ) && count( $options ) > $swatch_limit + $more_limit_swathes ) { $wrapper_class .= ' wd-swatches-limited'; } } // end Woodmart code. ?>
get_id(), $attribute_name, array( 'fields' => 'all' ) ); $options_fliped = array_flip( $options ); foreach ( $terms as $term ) { if ( ! in_array( $term->slug, $options ) ) { continue; } $key = $options_fliped[ $term->slug ]; $style = ''; $image = ''; $class = 'wd-swatch'; $class .= woodmart_get_old_classes( ' swatch-on-single woodmart-swatch' ); if ( ! empty( $swatches[ $key ]['color'] ) ) { $class .= ' wd-bg'; $class .= woodmart_get_old_classes( ' swatch-with-bg' ); if ( ! woodmart_get_opt( 'swatches_labels_name' ) ) { $class .= ' wd-tooltip'; } $style = 'background-color:' . $swatches[ $key ]['color']; } elseif ( $swatches_use_variation_images && $grid_swatches_attribute === $attribute_name && isset( $swatches[ $key ]['image_src'] ) ) { $image = wp_get_attachment_image( get_post_thumbnail_id( $swatches[ $key ]['variation_id'] ), 'woocommerce_thumbnail' ); if ( ! empty( $image ) ) { $class .= ' wd-bg'; $class .= woodmart_get_old_classes( ' swatch-with-bg' ); if ( ! woodmart_get_opt( 'swatches_labels_name' ) ) { $class .= ' wd-tooltip'; } } } elseif ( ! empty( $swatches[ $key ]['image'] ) && ( ! is_array( $swatches[ $key ]['image'] ) || ( is_array( $swatches[ $key ]['image'] ) && $swatches[ $key ]['image']['id'] ) ) ) { if ( is_array( $swatches[ $key ]['image'] ) ) { $image = wp_get_attachment_image( $swatches[ $key ]['image']['id'], 'woocommerce_thumbnail' ); } elseif ( $swatches[ $key ]['image'] ) { $image = '' . esc_attr__( 'Swatch image', 'woodmart' ) . ''; } $class .= ' wd-bg'; $class .= woodmart_get_old_classes( ' swatch-with-bg' ); if ( ! woodmart_get_opt( 'swatches_labels_name' ) ) { $class .= ' wd-tooltip'; } } else { $class .= ' wd-text'; $class .= woodmart_get_old_classes( ' text-only' ); } if ( in_array( $swatch_size, array( 'default', 'large', 'xlarge' ), true ) ) { $class .= woodmart_get_old_classes( ' swatch-size-' . $swatch_size ); } if ( $selected_value === $term->slug ) { $class .= ' wd-active'; } if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && $active_variations ) { if ( in_array( $term->slug, $active_variations ) ) { $class .= ' wd-enabled'; } else { $class .= ' wd-disabled'; } } $title = woodmart_get_opt( 'swatches_labels_name' ) ? ' title="' . $term->name . '"' : ''; if ( $swatch_limit && count( $options ) > $swatch_limit + $more_limit_swathes && ( array_key_first( $attributes ) === $attribute_name || $is_single_product ) ) { if ( $_i >= $swatch_limit ) { $class .= ' wd-hidden'; } if ( $_i === $swatch_limit ) { woodmart_enqueue_inline_style( 'woo-opt-limit-swatches' ); woodmart_enqueue_js_script( 'swatches-limit' ); ?>
data-value="slug ); ?>" data-title="name ); ?>" slug ), false ); ?>> name ), true ); ?>
slug, $active_variations ) ) { $class .= ' wd-enabled'; } else { $class .= ' wd-disabled'; } } if ( $swatch_limit && array_key_first( $attributes ) === $attribute_name && count( $options ) > $swatch_limit + $more_limit_swathes ) { if ( $_i >= $swatch_limit ) { $class .= ' wd-hidden'; } if ( $_i === $swatch_limit ) { woodmart_enqueue_inline_style( 'woo-opt-limit-swatches' ); woodmart_enqueue_js_script( 'swatches-limit' ); echo '
+' . ( count( $options ) - (int) $swatch_limit ) . '
'; } } $title = woodmart_get_opt( 'swatches_labels_name' ) ? 'title="' . $term->name . '"' : ''; echo '
' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . '
'; $_i++; } } } ?>
$is_quick_shop2 ? '' : false, 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'class' => 'on' === $swatch_change_image ? 'wd-changes-variation-image' : '', ) ); echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '' ) ) : ''; ?>