/** * Form to show 'Auto generate Bulk Coupons' with other fields */ public function admin_generate_bulk_coupons_and_export() { if (!$this->is_wc_gte_21()) { echo '<p>' . __('This feature is available for WooCommerce 2.1 or later', self::$text_domain) . '</p>'; return; } global $woocommerce, $woocommerce_smart_coupon; if (!class_exists('WC_Meta_Box_Coupon_Data')) { require_once $this->global_wc()->plugin_path() . '/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php'; } $upload_url = wp_upload_dir(); $upload_path = $upload_url['path']; $assets_path = str_replace(array('http:', 'https:'), '', $this->global_wc()->plugin_url()) . '/assets/'; if (isset($_POST['generate_and_import']) && !empty($_POST['smart_coupons_generate_action']) && $_POST['smart_coupons_generate_action'] == 'sc_export_and_import') { $this->export_coupon($_POST, '', ''); } ?> <script type="text/javascript"> jQuery(function(){ jQuery('input#generate_and_import').on('click', function(){ if( jQuery('input#no_of_coupons_to_generate').val() == "" ){ jQuery("div#message").removeClass("updated fade").addClass("error fade"); jQuery('div#message p').html( "<?php _e('Please enter a valid value for Number of Coupons to Generate', self::$text_domain); ?> "); return false; } else { jQuery("div#message").removeClass("error fade").addClass("updated fade").hide(); return true; } }); }); </script> <div id="message"><p></p></div> <div class="tool-box"> <h3 class="title"><?php _e('Generate Coupons', self::$text_domain); ?> | <small><a href="<?php echo trailingslashit(admin_url()) . 'admin.php?import=woocommerce_smart_coupon_csv'; ?> "><?php echo __('Import Coupons', self::$text_domain); ?> </a></small></h3> <p class="description"><?php _e('You can bulk generate coupons using options below.', self::$text_domain); ?> </p> <style type="text/css"> #smart-coupon-action-panel p label { width: 18em; } #smart-coupon-action-panel { width: 100% !important; } </style> <form id="generate_coupons" action="<?php echo admin_url('admin.php?import=woocommerce_smart_coupon_csv&step=2'); ?> " method="post"> <?php wp_nonce_field('import-woocommerce-coupon'); ?> <div id="poststuff"> <div id="woocommerce-coupon-data" class="postbox " > <h3><span><?php echo __('Action', self::$text_domain); ?> </span></h3> <div class="inside"> <div class="panel-wrap"> <div id="smart-coupon-action-panel" class="panel woocommerce_options_panel"> <p class="form-field"> <label><?php echo __('Generate coupons &', self::$text_domain); ?> </label> <input type="radio" name="smart_coupons_generate_action" value="add_to_store" id="add_to_store" checked="checked"/> <strong><?php echo __('Add to store', self::$text_domain); ?> </strong> <span class="description"><?php _e('Adds generated coupons to store.', self::$text_domain); ?> </span> </p> <p class="form-field"> <label><?php echo ' '; ?> </label> <input type="radio" name="smart_coupons_generate_action" value="sc_export_and_import" id="sc_export_and_import" /> <strong><?php echo __('Export to CSV', self::$text_domain); ?> </strong> <span class="description"><?php _e('Downloads a .CSV file, which can be used for importing', self::$text_domain); ?> </span> </p> <p class="form-field"> <label><?php echo ' '; ?> </label> <input type="radio" name="smart_coupons_generate_action" value="woo_sc_is_email_imported_coupons" id="woo_sc_is_email_imported_coupons" /> <strong><?php echo __('Email to customer', self::$text_domain); ?> </strong> <span class="description"><?php _e('Send generated coupon codes to respective customer via email as well', self::$text_domain); ?> </span> </p> <p class="form-field"> <label for="no_of_coupons_to_generate"><?php _e('Number of Coupons to Generate ', self::$text_domain); ?> *</label> <input type="number" name="no_of_coupons_to_generate" id="no_of_coupons_to_generate" placeholder="<?php _e('10', self::$text_domain); ?> " class="short" min="1" /> </p> </div> </div> </div> </div> <div id="woocommerce-coupon-data" class="postbox " > <h3><span><?php echo __('Coupon Data', self::$text_domain); ?> </span></h3> <div class="inside"> <?php WC_Meta_Box_Coupon_Data::output(array()); ?> </div> </div> </div> <p class="submit"><input id="generate_and_import" name="generate_and_import" type="submit" class="button button-primary" value="<?php _e('Apply', self::$text_domain); ?> " /></p> </form> </div> <?php }
?> '> <div class='wc-coupon-generator-coupon-data' id='poststuff'> <div id="postbox-container-2" class="postbox-container"> <div id="normal-sortables" class="meta-box-sortables ui-sortable"> <div id="woocommerce-coupon-data" class="postbox "> <h3 class="hndle ui-sortable-handle"><span><?php _e('Coupon Data', 'woocommerce'); ?> </span></h3> <div class="inside"><?php $temp_coupon = wp_insert_post(array('post_type' => 'shop_coupon', 'post_status' => 'draft', 'post_title' => 'temp_generator_coupon')); global $thepostid; $thepostid = $temp_coupon; WC_Meta_Box_Coupon_Data::output((object) array('ID' => null)); wp_delete_post($temp_coupon, true); ?> </div> </div> </div> </div> <div class='clear'></div> <a href="javascript:void(0);" class="continue-button-wrap" onclick="document.getElementById('wc-coupon-generator').submit();"> <span class="continue-button"><?php _e('Continue to the next step', 'woocommerce-coupon-generator'); ?> </span> </a>