<?php
if (!defined('ABSPATH')) exit; // Exit if accessed directly 
?>

<form id="iwbvel-variations-possible-combinations-form" class=iwbvel-variations-possible-combinations-rows">
    <?php
    if (!empty($combinations)) :
        $iwbvel_i = 0;
        foreach ($combinations as $iwbvel_combination) :
            if (!empty($iwbvel_combination)) :
    ?>
                <div class="iwbvel-variations-possible-combinations-row">
                    <input type="checkbox" data-name="enable" value="yes" checked="checked">
                    <?php
                    $iwbvel_j = 0;
                    foreach ($iwbvel_combination as $iwbvel_attribute_name => $iwbvel_term_slug) :
                        if ($iwbvel_term_slug == 'null') :
                    ?>
                            <input type="hidden" class="iwbvel-variations-possible-combination-item" data-attribute="<?php echo esc_attr(urlencode($iwbvel_attribute_name)); ?>" data-term-slug="<?php echo esc_attr($iwbvel_term_slug); ?>" data-term-id="">
                            <span>
                                <?php
                                $iwbvel_attribute_label = wc_attribute_label($iwbvel_attribute_name);
                                echo (!empty($iwbvel_attribute_label)) ? esc_html('Any ' . $iwbvel_attribute_label) : esc_html('Any ' . $iwbvel_attribute_name);
                                if (($iwbvel_j) < count($iwbvel_combination)) {
                                    echo " | ";
                                }
                                $iwbvel_j++
                                ?>
                            </span>
                        <?php
                        else :
                            $iwbvel_term = get_term_by('slug', $iwbvel_term_slug, $iwbvel_attribute_name);
                            if (!($iwbvel_term instanceof \WP_Term)) {
                                continue;
                            }
                        ?>
                            <input type="hidden" class="iwbvel-variations-possible-combination-item" data-attribute="<?php echo esc_attr(urlencode($iwbvel_attribute_name)); ?>" data-term-slug="<?php echo esc_attr($iwbvel_term_slug); ?>" data-term-id="<?php echo intval($iwbvel_term->term_id); ?>">
                            <span>
                                <?php
                                echo esc_html($iwbvel_term->name);
                                if (($iwbvel_j + 1) < count($iwbvel_combination)) {
                                    echo " | ";
                                }
                                $iwbvel_j++
                                ?>
                            </span>
                    <?php
                        endif;
                    endforeach;
                    ?>
                    <button type="button" class="iwbvel-button-flat iwbvel-variations-possible-combination-sort-button"><i class="iwbvel-icon-move"></i></button>
                </div>
    <?php
            endif;
            $iwbvel_i++;
        endforeach;
    endif;
    ?>
</form>