<?php

use TourOperatorPro\Factory;
use TourOperatorPro\Html\TourOperatorProHtmlFrontend;
use TourOperatorPro\Language\Text;
use TourOperatorPro\Utilities\Utility;
defined('_TOUROPERATOR_EXEC') or die;
extract($displayData);

TourOperatorProHtmlFrontend::load_jquery_library('select2');



$id_by_name = "element_field_". $name;
$data = $displayData['field']->getForm()->getData();
$args = array();
$products = wc_get_products($args);
?>
    <div id="<?php echo (esc_attr($id_by_name)) ?>" class="<?php echo (esc_attr($class)); ?> field-opensourcelinkid">
        <div class="wrapper-field-opensourcelinkid">
            <select name="<?php echo (esc_attr($name)); ?>" required="<?php echo (esc_attr($required)) ?>"
                    class="open-source-link">
                <option value=""><?php esc_html_e('Select product','touroperatorpro') ?></option>
				<?php foreach ($products as $product) { ?>
                    <option <?php echo ($product->get_id() == $value ? ' selected ' : null) ?>
                            value="<?php echo (esc_attr($product->get_id())); ?>"><?php esc_html_e($product->get_name()); ?></option>
				<?php } ?>
            </select>
        </div>
    </div>
<?php
$doc = Factory::getDocument();
$doc->addScriptApplySelector('.field-opensourcelinkid','field_opensourcelinkid',array(
        "step"=>  (int)$step,
        "tool_check"=>  json_encode(array_reverse($toolChecked)),
    )
    ,'admin_woopanel/app/layouts/WooBooking/form/field/opensourcelinkid/opensourcelinkid.jquery.js');