/**
  * Include script on the post/edit product pages
  *
  * @script( include_in: "admin" )
  */
 public function add_product_scripts()
 {
     $screen = get_current_screen();
     if ($screen->id != 'product') {
         return;
     }
     $ml_product = null;
     if (!empty($_GET['post'])) {
         $ml_product = new ML_Product(intval($_GET['post']));
         if ($ml_product->is_published()) {
             return;
         }
     }
     $textdomain = ML()->textdomain;
     wp_enqueue_script('jquery-option-tree-script', WooCommerce_MercadoLivre::get_plugin_url('/assets/js/jquery.option.tree.js'), array('jquery'));
     wp_enqueue_script('ml-categories-script', WooCommerce_MercadoLivre::get_plugin_url('/assets/js/ml.categories.tree.js'), array('jquery-option-tree-script'), '1.4.1');
     $array_fields = array('url' => add_query_arg(array('action' => 'get_ml_subcategories', 'security' => wp_create_nonce('ml-product-action')), admin_url('admin-ajax.php')), 'check_variation_url' => add_query_arg(array('action' => 'check_variation', 'security' => wp_create_nonce('ml-product-action')), admin_url('admin-ajax.php')), 'get_shipping_modes_url' => add_query_arg(array('action' => 'get_ml_shipping_modes', 'security' => wp_create_nonce('ml-shipping-action')), admin_url('admin-ajax.php')), 'image_url' => WooCommerce_MercadoLivre::get_plugin_url('/assets/img/ajax-loader.gif'), 'first_level_label' => __('Category', $textdomain), 'level_label' => __('Subcategory', $textdomain), 'pre_selected' => isset($ml_product->category_id) ? wp_list_pluck(ML_Category::get_category_path($ml_product->category_id), 'id') : null);
     wp_localize_script('ml-categories-script', 'obj', $array_fields);
 }
 /**
  * Add an html line variation 
  *
  * @ajax( action: "add_variation_line" , only_logged: true )
  */
 public function add_variation()
 {
     check_ajax_referer('ml-variation-line-action', 'security');
     if (!isset($_GET['product_id'], $_GET['category'])) {
         die;
     }
     ob_start();
     $variations = ML_Category::get_category_variations($_GET['category']);
     $ml_product = new ML_Product(intval($_GET['product_id']));
     include 'views/html-variation-line.php';
     wp_send_json(ob_get_clean());
 }
    woocommerce_wp_checkbox(array('id' => 'ml_publish', 'label' => $ml_product->is_published() ? __('Update at ML', $textdomain) : __('Post at ML', $textdomain), 'description' => __('Check if this product should be published at ML', $textdomain), 'desc_tip' => true, 'value' => isset($_POST['ml_publish']) || $ml_product->is_published() ? 'yes' : 'no'));
    ?>
		</div>
	<?php 
}
?>
	<div class="options_group ml_required_fields">
		<p class="form-field ml_category_id_field">
			<label for="ml_category_id"><?php 
_e('Category', $textdomain);
?>
</label>
			<?php 
if ($ml_product->is_published()) {
    printf('<a href="%s" target="_blank">%s</a>', $ml_product->permalink, implode(' > ', wp_list_pluck(ML_Category::get_category_path($ml_product->category_id), 'name')));
    $variations = ML_Category::get_category_variations($ml_product->category_id);
    if (!empty($variations)) {
        include_once 'html-variations.php';
    }
} else {
    woocommerce_wp_hidden_input(array('id' => 'ml_category_id', 'value' => $ml_product->category_id));
}
?>
		</p>
	</div>
	<div class="options_group">
		<?php 
if (!empty(ML()->ml_official_stores)) {
    woocommerce_wp_select(array('id' => 'ml_official_store_id', 'label' => __('Official Store', $textdomain), 'description' => __('Determines which official store the product will be posted', $textdomain), 'desc_tip' => true, 'options' => ML()->ml_official_stores, 'value' => isset($_POST['ml_official_store_id']) ? $_POST['ml_official_store_id'] : $ml_product->official_store_id, 'custom_attributes' => $ml_product->is_published() ? array('disabled' => 'disabled') : array()));
}
//Modifiable with conditions