Example #1
0
function jigoshop_email_data_box($post)
{
    wp_nonce_field('jigoshop_save_data', 'jigoshop_meta_nonce');
    ?>

	<div id="coupon_options" class="panel jigoshop_options_panel">
		<style>
			.jigoshop_options_panel .mid, .jigoshop_options_panel .form-field input.mid{
				width:100%;
				margin-right:10px;
			}
		</style>
		<script>
			jQuery(document).ready(function($) {
				$('#jigoshop_email_actions').change(function() {
					$.ajax({
						type: "POST",
						url: jigoshop_params.ajax_url,
						data: {
							'action':'update_variable_list',
							'jigoshop_email_actions' : $('#jigoshop_email_actions').val()
						},
						success:function(data) {
							$('#avalible_arguments').replaceWith(data);
						},
						error: function(errorThrown){
							console.log(errorThrown);
						}
					});

				});
			});
		</script>
		<div class="options_group">
			<?php 
    $args = array('id' => 'jigoshop_email_subject', 'label' => __('Subject', 'jigoshop'), 'class' => 'mid', 'multiple' => true);
    echo Jigoshop_Forms::input($args);
    $registered_mails = jigoshop_emails::get_mail_list();
    $mails = array();
    if (!empty($registered_mails)) {
        foreach ($registered_mails as $hook => $detalis) {
            $mails[$hook] = $detalis['description'];
        }
    }
    $args = array('id' => 'jigoshop_email_actions', 'label' => __('Actions', 'jigoshop'), 'multiple' => true, 'class' => 'select mid', 'placeholder' => __('No email action', 'jigoshop'), 'options' => $mails, 'selected' => '');
    echo Jigoshop_Forms::select($args);
    ?>
		</div>
	</div>
<?php 
}
Example #2
0
<fieldset>
	<?php 
// DOWNLOADABLE OPTIONS
// File URL
// TODO: Refactor this into a helper
$file_path = get_post_meta($post->ID, 'file_path', true);
$field = array('id' => 'file_path', 'label' => __('File Path', 'jigoshop'));
echo '<p class="form-field"><label for="' . esc_attr($field['id']) . '">' . $field['label'] . ':</label>
				<input type="text" class="file_path" name="' . esc_attr($field['id']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($file_path) . '" placeholder="' . site_url() . '" />
				<input type="button"  class="upload_file_button button" data-postid="' . esc_attr($post->ID) . '" value="' . __('Upload a file', 'jigoshop') . '" />
			</p>';
// Download Limit
$args = array('id' => 'download_limit', 'label' => __('Download Limit', 'jigoshop'), 'type' => 'number', 'desc' => __('Leave blank for unlimited re-downloads', 'jigoshop'));
echo Jigoshop_Forms::input($args);
do_action('additional_downloadable_product_type_options');
?>
</fieldset>
Example #3
0
/**
 * Product data box
 *
 * Displays the product data box, tabbed, with several panels covering price, stock etc
 *
 * @since 		1.0
 */
function jigoshop_product_data_box()
{
    global $post, $wpdb, $thepostid;
    add_action('admin_footer', 'jigoshop_meta_scripts');
    wp_nonce_field('jigoshop_save_data', 'jigoshop_meta_nonce');
    $thepostid = $post->ID;
    // Product Type
    $terms = get_the_terms($thepostid, 'product_type');
    $product_type = $terms ? current($terms)->slug : 'simple';
    $product_type_selector = apply_filters('jigoshop_product_type_selector', array('simple' => __('Simple', 'jigoshop'), 'downloadable' => __('Downloadable', 'jigoshop'), 'grouped' => __('Grouped', 'jigoshop'), 'virtual' => __('Virtual', 'jigoshop'), 'variable' => __('Variable', 'jigoshop'), 'external' => __('External / Affiliate', 'jigoshop')));
    $product_type_select = '<div class="product-type-label">' . __('Product Type', 'jigoshop') . '</div><select id="product-type" name="product-type"><optgroup label="' . __('Product Type', 'jigoshop') . '">';
    foreach ($product_type_selector as $value => $label) {
        $product_type_select .= '<option value="' . $value . '" ' . selected($product_type, $value, false) . '>' . $label . '</option>';
    }
    $product_type_select .= '</optgroup></select><div class="clear"></div>';
    ?>

	<div class="panels">
		<span class="jigoshop_product_data_type"><?php 
    echo $product_type_select;
    ?>
</span>
		<ul class="product_data_tabs tabs" style="display:none;">
			<li class="general_tab active">
				<a href="#general"><?php 
    _e('General', 'jigoshop');
    ?>
</a>
			</li>

			<li class="advanced_tab">
				<a href="#tax"><?php 
    _e('Advanced', 'jigoshop');
    ?>
</a>
			</li>

			<?php 
    if (Jigoshop_Base::get_options()->get('jigoshop_manage_stock') == 'yes') {
        ?>
			<li class="inventory_tab">
				<a href="#inventory"><?php 
        _e('Inventory', 'jigoshop');
        ?>
</a>
			</li>
			<?php 
    }
    ?>

			<li class="attributes_tab">
				<a href="#attributes"><?php 
    _e('Attributes', 'jigoshop');
    ?>
</a>
			</li>

			<li class="grouped_tab">
				<a href="#grouped"><?php 
    _e('Grouping', 'jigoshop');
    ?>
</a>
			</li>

			<li class="file_tab">
				<a href="#files"><?php 
    _e('Download', 'jigoshop');
    ?>
</a>
			</li>

			<?php 
    do_action('jigoshop_product_write_panel_tabs');
    ?>
			<?php 
    do_action('product_write_panel_tabs');
    ?>
		</ul>

		<div id="general" class="panel jigoshop_options_panel">
			<fieldset>
			<?php 
    // Visibility
    $args = array('id' => 'product_visibility', 'label' => __('Visibility', 'jigoshop'), 'options' => array('visible' => __('Catalog & Search', 'jigoshop'), 'catalog' => __('Catalog Only', 'jigoshop'), 'search' => __('Search Only', 'jigoshop'), 'hidden' => __('Hidden', 'jigoshop')), 'selected' => get_post_meta($post->ID, 'visibility', true));
    echo Jigoshop_Forms::select($args);
    // Featured
    $args = array('id' => 'featured', 'label' => __('Featured?', 'jigoshop'), 'desc' => __('Enable this option to feature this product', 'jigoshop'), 'value' => false);
    echo Jigoshop_Forms::checkbox($args);
    ?>
			</fieldset>
			<fieldset>
			<?php 
    // SKU
    if (Jigoshop_Base::get_options()->get('jigoshop_enable_sku') !== 'no') {
        $args = array('id' => 'sku', 'label' => __('SKU', 'jigoshop'), 'placeholder' => $post->ID);
        echo Jigoshop_Forms::input($args);
    }
    //Brand
    if (Jigoshop_Base::get_options()->get('jigoshop_enable_brand') !== 'no') {
        $args = array('id' => 'brand', 'label' => __('Brand', 'jigoshop'));
        echo Jigoshop_Forms::input($args);
    }
    //GTIN
    if (Jigoshop_Base::get_options()->get('jigoshop_enable_gtin ') !== 'no') {
        $args = array('id' => 'gtin', 'label' => __('GTIN ', 'jigoshop'));
        echo Jigoshop_Forms::input($args);
    }
    //MPN
    if (Jigoshop_Base::get_options()->get('jigoshop_enable_mpn') !== 'no') {
        $args = array('id' => 'mpn', 'label' => __('MPN', 'jigoshop'));
        echo Jigoshop_Forms::input($args);
    }
    ?>
			</fieldset>

			<fieldset id="price_fieldset">
			<?php 
    // Regular Price
    $args = array('id' => 'regular_price', 'label' => __('Regular Price', 'jigoshop'), 'after_label' => ' (' . get_jigoshop_currency_symbol() . ')', 'type' => 'number', 'step' => 'any', 'placeholder' => __('Price Not Announced', 'jigoshop'));
    echo Jigoshop_Forms::input($args);
    // Sale Price
    $args = array('id' => 'sale_price', 'label' => __('Sale Price', 'jigoshop'), 'after_label' => ' (' . get_jigoshop_currency_symbol() . __(' or %', 'jigoshop') . ')', 'desc' => '<a href="#" class="sale_schedule">' . __('Schedule', 'jigoshop') . '</a>', 'placeholder' => __('15% or 19.99', 'jigoshop'));
    echo Jigoshop_Forms::input($args);
    // Sale Price date range
    // TODO: Convert this to a helper somehow?
    $field = array('id' => 'sale_price_dates', 'label' => __('On Sale Between', 'jigoshop'));
    $sale_price_dates_from = get_post_meta($thepostid, 'sale_price_dates_from', true);
    $sale_price_dates_to = get_post_meta($thepostid, 'sale_price_dates_to', true);
    echo '<p class="form-field sale_price_dates_fields">' . __('Current time:', 'jigoshop') . ' ' . current_time('Y-m-d H:i') . '</p>';
    echo '	<p class="form-field sale_price_dates_fields">
							<label for="' . esc_attr($field['id']) . '_from">' . $field['label'] . '</label>
							<input type="text" class="short date-pick" name="' . esc_attr($field['id']) . '_from" id="' . esc_attr($field['id']) . '_from" value="';
    if ($sale_price_dates_from) {
        echo date('Y-m-d H:i', $sale_price_dates_from);
    }
    echo '" placeholder="' . __('From', 'jigoshop') . ' (' . date('Y-m-d H:i') . ')" maxlength="16" />
							<input type="text" class="short date-pick" name="' . esc_attr($field['id']) . '_to" id="' . esc_attr($field['id']) . '_to" value="';
    if ($sale_price_dates_to) {
        echo date('Y-m-d H:i', $sale_price_dates_to);
    }
    echo '" placeholder="' . __('To', 'jigoshop') . ' (' . date('Y-m-d H:i') . ')" maxlength="16" />
							<a href="#" class="cancel_sale_schedule">' . __('Cancel', 'jigoshop') . '</a>
						</p>';
    ?>
			<?php 
    do_action('jigoshop_product_pricing_options');
    /* allow extensions like sales flash pro to add pricing options */
    ?>
			</fieldset>

			<fieldset>
			<?php 
    // External products
    $args = array('id' => 'external_url', 'label' => __('Product URL', 'jigoshop'), 'placeholder' => __('The URL of the external product (eg. http://www.google.com)', 'jigoshop'), 'extras' => array());
    echo Jigoshop_Forms::input($args);
    ?>
			</fieldset>
			<?php 
    do_action('jigoshop_product_general_panel');
    ?>
		</div>
		<div id="tax" class="panel jigoshop_options_panel">
			<fieldset id="tax_fieldset">
				<?php 
    // Tax Status
    $status = get_post_meta($post->ID, 'tax_status', true);
    if (empty($status)) {
        $status = Jigoshop_Base::get_options()->get('jigoshop_tax_defaults_status', 'taxable');
    }
    $args = array('id' => 'tax_status', 'label' => __('Tax Status', 'jigoshop'), 'options' => array('taxable' => __('Taxable', 'jigoshop'), 'shipping' => __('Shipping', 'jigoshop'), 'none' => __('None', 'jigoshop')), 'selected' => $status);
    echo Jigoshop_Forms::select($args);
    ?>
				<p class="form_field tax_classes_field">
					<label for="tax_classes"><?php 
    _e('Tax Classes', 'jigoshop');
    ?>
</label>
            <span class="multiselect short">
            <?php 
    $_tax = new jigoshop_tax();
    $tax_classes = $_tax->get_tax_classes();
    $selections = get_post_meta($post->ID, 'tax_classes', true);
    if (!is_array($selections)) {
        $selections = Jigoshop_Base::get_options()->get('jigoshop_tax_defaults_classes', array('*'));
    }
    $checked = checked(in_array('*', $selections), true, false);
    printf('<label %s><input type="checkbox" name="tax_classes[]" value="%s" %s/> %s</label>', !empty($checked) ? 'class="selected"' : '', '*', $checked, __('Standard', 'jigoshop'));
    if ($tax_classes) {
        foreach ($tax_classes as $tax_class) {
            $checked = checked(in_array(sanitize_title($tax_class), $selections), true, false);
            printf('<label %s><input type="checkbox" name="tax_classes[]" value="%s" %s/> %s</label>', !empty($checked) ? 'class="selected"' : '', sanitize_title($tax_class), $checked, __($tax_class, 'jigoshop'));
        }
    }
    ?>
            </span>
            <span class="multiselect-controls">
						<a class="check-all" href="#"><?php 
    _e('Check All', 'jigoshop');
    ?>
</a>&nbsp;|
						<a class="uncheck-all" href="#"><?php 
    _e('Uncheck All', 'jigoshop');
    ?>
</a>
					</span>
				</p>
			</fieldset>

			<?php 
    if (Jigoshop_Base::get_options()->get('jigoshop_enable_weight') !== 'no' || Jigoshop_Base::get_options()->get('jigoshop_enable_dimensions', true) !== 'no') {
        ?>
			<fieldset id="form_fieldset">
			<?php 
        // Weight
        if (Jigoshop_Base::get_options()->get('jigoshop_enable_weight') !== 'no') {
            $args = array('id' => 'weight', 'label' => __('Weight', 'jigoshop'), 'after_label' => ' (' . Jigoshop_Base::get_options()->get('jigoshop_weight_unit') . ')', 'type' => 'number', 'step' => 'any', 'placeholder' => '0.00');
            echo Jigoshop_Forms::input($args);
        }
        // Dimensions
        if (Jigoshop_Base::get_options()->get('jigoshop_enable_dimensions', true) !== 'no') {
            echo '
					<p class="form-field dimensions_field">
						<label for"product_length">' . __('Dimensions', 'jigoshop') . ' (' . Jigoshop_Base::get_options()->get('jigoshop_dimension_unit') . ')' . '</label>
						<input type="number" step="any" name="length" class="short" value="' . get_post_meta($thepostid, 'length', true) . '" placeholder="' . __('Length', 'jigoshop') . '" />
						<input type="number" step="any" name="width" class="short" value="' . get_post_meta($thepostid, 'width', true) . '" placeholder="' . __('Width', 'jigoshop') . '" />
						<input type="number" step="any" name="height" class="short" value="' . get_post_meta($thepostid, 'height', true) . '" placeholder="' . __('Height', 'jigoshop') . '" />
					</p>
					';
        }
        ?>
			</fieldset>
			<?php 
    }
    ?>

			<fieldset>
			<?php 
    // Customizable
    $args = array('id' => 'product_customize', 'label' => __('Can be personalized', 'jigoshop'), 'options' => array('no' => __('No', 'jigoshop'), 'yes' => __('Yes', 'jigoshop')), 'selected' => get_post_meta($post->ID, 'customizable', true));
    echo Jigoshop_Forms::select($args);
    // Customizable length
    $args = array('id' => 'customized_length', 'label' => __('Personalized Characters', 'jigoshop'), 'type' => 'number', 'value' => get_post_meta($post->ID, 'customized_length', true), 'placeholder' => __('Leave blank for unlimited', 'jigoshop'));
    echo Jigoshop_Forms::input($args);
    ?>
			</fieldset>
			<?php 
    do_action('jigoshop_product_tax_panel');
    ?>

		</div>

		<?php 
    if (Jigoshop_Base::get_options()->get('jigoshop_manage_stock') == 'yes') {
        ?>
		<div id="inventory" class="panel jigoshop_options_panel">
			<fieldset>
			<?php 
        // manage stock
        $args = array('id' => 'manage_stock', 'label' => __('Manage Stock?', 'jigoshop'), 'desc' => __('Handle stock for me', 'jigoshop'), 'value' => false);
        echo Jigoshop_Forms::checkbox($args);
        ?>
			</fieldset>
			<fieldset>
			<?php 
        // Stock Status
        // TODO: These values should be true/false
        $args = array('id' => 'stock_status', 'label' => __('Stock Status', 'jigoshop'), 'options' => array('instock' => __('In Stock', 'jigoshop'), 'outofstock' => __('Out of Stock', 'jigoshop')));
        echo Jigoshop_Forms::select($args);
        echo '<div class="stock_fields">';
        // Stock
        // TODO: Missing default value of 0
        $args = array('id' => 'stock', 'label' => __('Stock Quantity', 'jigoshop'), 'type' => 'number');
        echo Jigoshop_Forms::input($args);
        // Backorders
        $args = array('id' => 'backorders', 'label' => __('Allow Backorders?', 'jigoshop'), 'options' => array('no' => __('Do not allow', 'jigoshop'), 'notify' => __('Allow, but notify customer', 'jigoshop'), 'yes' => __('Allow', 'jigoshop')));
        echo Jigoshop_Forms::select($args);
        echo '</div>';
        ?>
			</fieldset>
			<?php 
        do_action('jigoshop_product_inventory_panel');
        ?>
		</div>
		<?php 
    }
    ?>

		<div id="attributes" class="panel">
			<?php 
    do_action('jigoshop_attributes_display');
    ?>
		</div>

		<div id="grouped" class="panel jigoshop_options_panel">
			<?php 
    // Grouped Products
    // TODO: Needs refactoring & a bit of love
    $posts_in = (array) get_objects_in_term(get_term_by('slug', 'grouped', 'product_type')->term_id, 'product_type');
    $posts_in = array_unique($posts_in);
    if ((bool) $posts_in) {
        $args = array('post_type' => 'product', 'post_status' => 'publish', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'asc', 'post_parent' => 0, 'include' => $posts_in);
        $grouped_products = get_posts($args);
        $options = array(null => '&ndash; Pick a Product Group &ndash;');
        if ($grouped_products) {
            foreach ($grouped_products as $product) {
                if ($product->ID == $post->ID) {
                    continue;
                }
                $options[$product->ID] = $product->post_title;
            }
        }
        // Only echo the form if we have grouped products
        $args = array('id' => 'parent_id', 'label' => __('Product Group', 'jigoshop'), 'options' => $options, 'selected' => $post->post_parent);
        echo Jigoshop_Forms::select($args);
    }
    // Ordering
    $args = array('id' => 'menu_order', 'label' => __('Sort Order', 'jigoshop'), 'type' => 'number', 'value' => $post->menu_order);
    echo Jigoshop_Forms::input($args);
    $args = array('id' => 'variation_order', 'label' => __('Variation Order', 'jigoshop'), 'options' => array('asort' => __('By name ascending', 'jigoshop'), 'arsort' => __('By name descending', 'jigoshop'), 'ksort' => __('From first to last key', 'jigoshop'), 'krsort' => __('From last to first key', 'jigoshop'), 'shuffle' => __('Random', 'jigoshop')), 'selected' => get_post_meta($post->ID, 'variation_order', true));
    echo Jigoshop_Forms::select($args);
    ?>
			<?php 
    do_action('jigoshop_product_grouped_panel');
    ?>
		</div>

		<div id="files" class="panel jigoshop_options_panel">
			<fieldset>
			<?php 
    // DOWNLOADABLE OPTIONS
    // File URL
    // TODO: Refactor this into a helper
    $file_path = get_post_meta($post->ID, 'file_path', true);
    $field = array('id' => 'file_path', 'label' => __('File Path', 'jigoshop'));
    echo '<p class="form-field"><label for="' . esc_attr($field['id']) . '">' . $field['label'] . ':</label>
				<input type="text" class="file_path" name="' . esc_attr($field['id']) . '" id="' . esc_attr($field['id']) . '" value="' . esc_attr($file_path) . '" placeholder="' . site_url() . '" />
				<input type="button"  class="upload_file_button button" data-postid="' . esc_attr($post->ID) . '" value="' . __('Upload a file', 'jigoshop') . '" />
			</p>';
    // Download Limit
    $args = array('id' => 'download_limit', 'label' => __('Download Limit', 'jigoshop'), 'type' => 'number', 'desc' => __('Leave blank for unlimited re-downloads', 'jigoshop'));
    echo Jigoshop_Forms::input($args);
    do_action('additional_downloadable_product_type_options');
    ?>
			</fieldset>
			<?php 
    do_action('jigoshop_product_files_panel');
    ?>
		</div>

		<?php 
    do_action('jigoshop_product_write_panels');
    ?>
		<?php 
    do_action('product_write_panels');
    ?>
	</div>
	<?php 
}
 public function display_default_tax_classes()
 {
     $tax = new jigoshop_tax();
     $classes = $tax->get_tax_classes();
     $defaults = Jigoshop_Base::get_options()->get('jigoshop_tax_defaults_classes', array('*'));
     ob_start();
     //We don't want any notices here.
     $old_status = error_reporting(0);
     echo Jigoshop_Forms::checkbox(array('id' => 'jigoshop_tax_defaults_class_standard', 'name' => 'jigoshop_tax_defaults_classes[*]', 'label' => __('Standard', 'jigoshop'), 'value' => in_array('*', $defaults)));
     foreach ($classes as $class) {
         $value = sanitize_title($class);
         echo Jigoshop_Forms::checkbox(array('id' => 'jigoshop_tax_defaults_class_' . $value, 'name' => 'jigoshop_tax_defaults_classes[' . $value . ']', 'label' => __($class, 'jigoshop'), 'value' => in_array($value, $defaults)));
     }
     error_reporting($old_status);
     return ob_get_clean();
 }
    public function order_status_widget()
    {
        ?>
		<form method="GET">
			<?php 
        $args = array('id' => 'order_status', 'name' => 'order_status', 'label' => null, 'after_label' => null, 'class' => 'full-width', 'desc' => false, 'tip' => false, 'multiple' => true, 'placeholder' => '', 'options' => array('pending' => __('Pending', 'jigoshop'), 'on-hold' => __('On-Hold', 'jigoshop'), 'waiting-for-payment' => __('Waiting for payment', 'jigoshop'), 'processing' => __('Processing', 'jigoshop'), 'completed' => __('Completed', 'jigoshop'), 'cancelled' => __('Cancelled', 'jigoshop'), 'refunded' => __('Refunded', 'jigoshop')), 'selected' => $this->order_status);
        echo Jigoshop_Forms::select($args);
        ?>
			<input type="submit" class="submit button" value="<?php 
        _e('Show', 'jigoshop');
        ?>
" />
			<input type="hidden" name="range" value="<?php 
        if (!empty($_GET['range'])) {
            echo esc_attr($_GET['range']);
        }
        ?>
" />
			<input type="hidden" name="start_date" value="<?php 
        if (!empty($_GET['start_date'])) {
            echo esc_attr($_GET['start_date']);
        }
        ?>
" />
			<input type="hidden" name="end_date" value="<?php 
        if (!empty($_GET['end_date'])) {
            echo esc_attr($_GET['end_date']);
        }
        ?>
" />
			<input type="hidden" name="page" value="<?php 
        if (!empty($_GET['page'])) {
            echo esc_attr($_GET['page']);
        }
        ?>
" />
			<input type="hidden" name="tab" value="<?php 
        if (!empty($_GET['tab'])) {
            echo esc_attr($_GET['tab']);
        }
        ?>
" />
			<input type="hidden" name="report" value="sales_by_date" />
		</form>
		<?php 
    }
Example #6
0
/**
 * Coupon data meta box
 *
 * Displays the meta box
 */
function jigoshop_coupon_data_box($post)
{
    global $jigoshop;
    wp_nonce_field('jigoshop_save_data', 'jigoshop_meta_nonce');
    $coupon_code = '';
    $coupon_code .= "<p class='form-field'>";
    $coupon_code .= "<label>" . __('Coupon Code', 'jigoshop') . "</label>";
    $coupon_code .= "<span><strong>" . $post->post_name . "</strong></span>";
    $coupon_code .= '<span class="description">' . __('Will not appear until coupon is saved.  This is the front end code for use on the Cart.', 'jigoshop') . '</span>';
    $coupon_code .= "</p>";
    // disable the permalink slug display
    ?>
		<style type="text/css">#edit-slug-box { display:none }</style>

		<div id="coupon_options" class="panel jigoshop_options_panel">

			<div class="options_group">

			<?php 
    // The coupon code from the title after 'sanitize_title'
    echo $coupon_code;
    // Coupon Types
    $args = array('id' => 'type', 'label' => __('Coupon Type', 'jigoshop'), 'options' => JS_Coupons::get_coupon_types());
    echo Jigoshop_Forms::select($args);
    // Amount
    $args = array('id' => 'amount', 'label' => __('Coupon Amount', 'jigoshop'), 'type' => 'number', 'min' => 0, 'desc' => __('Enter an amount e.g. 9.99.', 'jigoshop'), 'tip' => __('Amount this coupon is worth. If it is a percentange, just include the number without the percentage sign.', 'jigoshop'), 'placeholder' => '0.00');
    echo Jigoshop_Forms::input($args);
    // Date From
    $coupon_date_from = get_post_meta($post->ID, 'date_from', true);
    $args = array('id' => 'date_from', 'label' => __('Date From', 'jigoshop'), 'desc' => __('yyyy-mm-dd', 'jigoshop'), 'tip' => __('Choose between which dates this coupon is enabled.  Leave empty for any date.', 'jigoshop'), 'class' => 'short date-pick', 'placeholder' => __('Any date', 'jigoshop'), 'value' => $coupon_date_from != '' ? date('Y-m-d', $coupon_date_from) : '');
    echo Jigoshop_Forms::input($args);
    // Date To
    $coupon_date_to = get_post_meta($post->ID, 'date_to', true);
    $args = array('id' => 'date_to', 'label' => __('Date To', 'jigoshop'), 'desc' => __('yyyy-mm-dd', 'jigoshop'), 'tip' => __('Choose between which dates this coupon is enabled.  Leave empty for any date.', 'jigoshop'), 'class' => 'short date-pick', 'placeholder' => __('Any date', 'jigoshop'), 'value' => $coupon_date_to != '' ? date('Y-m-d', $coupon_date_to) : '');
    echo Jigoshop_Forms::input($args);
    // Usage limit
    $usage = get_post_meta($post->ID, 'usage', true);
    $args = array('id' => 'usage_limit', 'label' => __('Usage Limit', 'jigoshop'), 'type' => 'number', 'desc' => sprintf(__('Times used: %s', 'jigoshop'), !empty($usage) ? $usage : '0'), 'tip' => __('Control how many times this coupon may be used.', 'jigoshop'), 'placeholder' => '0');
    echo Jigoshop_Forms::input($args);
    // Individual use
    $args = array('id' => 'individual_use', 'label' => __('Individual Use', 'jigoshop'), 'desc' => __('Prevent other coupons from being used while this one is applied to the Cart.', 'jigoshop'), 'value' => false);
    echo Jigoshop_Forms::checkbox($args);
    // Free shipping
    $args = array('id' => 'free_shipping', 'label' => __('Free shipping', 'jigoshop'), 'desc' => __('Show the Free Shipping method on the Checkout with this enabled.', 'jigoshop'), 'value' => false);
    echo Jigoshop_Forms::checkbox($args);
    ?>
			</div><div class="options_group">
		<?php 
    // Order total minimum
    $args = array('id' => 'order_total_min', 'label' => __('Order total min', 'jigoshop'), 'type' => 'number', 'desc' => __('Set the required minimum subtotal for this coupon to be valid on an order.', 'jigoshop'), 'placeholder' => __('No min', 'jigoshop'));
    echo Jigoshop_Forms::input($args);
    // Order total maximum
    $args = array('id' => 'order_total_max', 'label' => __('Order total max', 'jigoshop'), 'type' => 'number', 'desc' => __('Set the required maximum subtotal for this coupon to be valid on an order.', 'jigoshop'), 'placeholder' => __('No max', 'jigoshop'));
    echo Jigoshop_Forms::input($args);
    ?>
			</div><div class="options_group">
		<?php 
    // Include product ID's
    $selected = get_post_meta($post->ID, 'include_products', true);
    $selected = implode(',', (array) $selected);
    $args = array('id' => 'include_products', 'type' => 'hidden', 'class' => 'long', 'label' => __('Include Products', 'jigoshop'), 'desc' => __('Control which products this coupon can apply to.', 'jigoshop'), 'value' => $selected);
    echo Jigoshop_Forms::input($args);
    // Exclude product ID's
    $selected = get_post_meta($post->ID, 'exclude_products', true);
    $selected = implode(',', (array) $selected);
    $args = array('id' => 'exclude_products', 'type' => 'hidden', 'class' => 'long', 'label' => __('Exclude Products', 'jigoshop'), 'desc' => __('Control which products this coupon cannot be applied to.', 'jigoshop'), 'value' => $selected);
    echo Jigoshop_Forms::input($args);
    ?>
			</div><div class="options_group">
		<?php 
    // Include Categories
    $categories = get_terms('product_cat', array('hide_empty' => false));
    $coupon_cats = array();
    foreach ($categories as $category) {
        $coupon_cats[$category->term_id] = $category->name;
    }
    $args = array('id' => 'include_categories', 'label' => __('Include Categories', 'jigoshop'), 'desc' => __('Control which product categories this coupon can apply to.', 'jigoshop'), 'multiple' => true, 'placeholder' => __('Any category', 'jigoshop'), 'options' => $coupon_cats);
    echo Jigoshop_Forms::select($args);
    // Exclude Categories
    $args = array('id' => 'exclude_categories', 'label' => __('Exclude Categories', 'jigoshop'), 'desc' => __('Control which product categories this coupon cannot be applied to.', 'jigoshop'), 'multiple' => true, 'placeholder' => __('No exclusions', 'jigoshop'), 'options' => $coupon_cats);
    echo Jigoshop_Forms::select($args);
    ?>
			</div><div class="options_group">
		<?php 
    // Payment methods
    $payment_methods = array();
    $available_gateways = jigoshop_payment_gateways::get_available_payment_gateways();
    if (!empty($available_gateways)) {
        foreach ($available_gateways as $id => $info) {
            $payment_methods[$id] = $info->title;
        }
    }
    $args = array('id' => 'pay_methods', 'label' => __('Payment Methods', 'jigoshop'), 'desc' => __('Control which payment methods are allowed for this coupon to be effective.', 'jigoshop'), 'multiple' => true, 'placeholder' => __('Any method', 'jigoshop'), 'options' => $payment_methods);
    echo Jigoshop_Forms::select($args);
    // javascript for product includes and excludes -- need to move this
    ?>
			<script type="text/javascript">
			/*<![CDATA[*/
				jQuery(document).ready(function($) {
					$('#date_from').datepicker( {dateFormat: 'yy-mm-dd', gotoCurrent: true} );
					$('#date_to').datepicker( {dateFormat: 'yy-mm-dd', gotoCurrent: true} );

					// allow searching of products to use on a coupon
					$("#include_products").select2({
						minimumInputLength: 3,
						multiple: true,
						closeOnSelect: true,
						placeholder: "<?php 
    _e('Any product', 'jigoshop');
    ?>
",
						ajax: {
							url: "<?php 
    echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php');
    ?>
",
							dataType: 'json',
							quietMillis: 100,
							data: function(term, page) {
								return {
									term:       term,
									action:     'jigoshop_json_search_products_and_variations',
									security:   '<?php 
    echo wp_create_nonce("search-products");
    ?>
'
								};
							},
							results: function( data, page ) {
								return { results: data };
							}
						},
						initSelection: function( element, callback ) {
							var stuff = {
								action:     'jigoshop_json_search_products_and_variations',
								security:   '<?php 
    echo wp_create_nonce("search-products");
    ?>
',
								term:       element.val()
							};
							var data = [];
							$.ajax({
								type: 		'GET',
								url:        "<?php 
    echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php');
    ?>
",
								dataType: 	"json",
								data: 		stuff,
								success: 	function( result ) {
									callback( result );
								}
							});
						}
					});

					// allow searching of products to exclude on a coupon
					$("#exclude_products").select2({
						minimumInputLength: 3,
						multiple: true,
						closeOnSelect: true,
						placeholder: "<?php 
    _e('No exclusions', 'jigoshop');
    ?>
",
						ajax: {
							url: "<?php 
    echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php');
    ?>
",
							dataType: 'json',
							quietMillis: 100,
							data: function(term, page) {
								return {
									term:       term,
									action:     'jigoshop_json_search_products_and_variations',
									security:   '<?php 
    echo wp_create_nonce("search-products");
    ?>
'
								};
							},
							results: function( data, page ) {
								return { results: data };
							}
						},
						initSelection: function( element, callback ) {
							var stuff = {
								action:     'jigoshop_json_search_products_and_variations',
								security:   '<?php 
    echo wp_create_nonce("search-products");
    ?>
',
								term:       element.val()
							};
							$.ajax({
								type: 		'GET',
								url:        "<?php 
    echo !is_ssl() ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php');
    ?>
",
								dataType: 	"json",
								data: 		stuff,
								success: 	function( result ) {
									callback( result );
								}
							});
						}
					});
				});
			/*]]>*/
			</script>
		</div></div>
	<?php 
}
 public static function checkbox($ID, $label, $value = false, $desc = false, $class = 'checkbox')
 {
     $args = array('id' => $ID, 'label' => $label, 'class' => $class, 'desc' => $desc, 'value' => $value);
     return Jigoshop_Forms::checkbox($args);
 }