From d3fb3c420ecab266ccf460eb7737de5dd9768b05 Mon Sep 17 00:00:00 2001 From: Govind Kumar Date: Sun, 8 Nov 2020 14:21:13 +0530 Subject: [PATCH] Made compatible with newest version of Woocommerce, Re-build UI/UX, Added more filters/actions to allow modifications --- README.md | 2 - gulpfile.js | 30 +- inc/classes/class-wsn-email.php | 4 +- inc/classes/class-wsn-initialize.php | 110 +-- inc/classes/class-wsn-options.php | 1025 ++++++++++---------------- inc/classes/class-wsn-product.php | 202 +++-- inc/classes/class-wsn-shortcode.php | 18 +- instock-init.php | 5 +- package.json | 6 +- readme.txt | 11 +- src/admin/main.js | 235 ++++-- src/admin/main.scss | 63 +- src/css/wsn-style.css | 238 ------ src/front/main.js | 38 + src/front/main.scss | 28 + src/helpers/colors.scss | 0 src/js/wsn-admin.js | 179 ----- src/js/wsn-metabox.js | 54 -- src/js/wsn-script.js | 9 - webpack.config.js | 8 - 20 files changed, 856 insertions(+), 1409 deletions(-) delete mode 100644 src/css/wsn-style.css delete mode 100644 src/helpers/colors.scss delete mode 100644 src/js/wsn-admin.js delete mode 100644 src/js/wsn-metabox.js delete mode 100644 src/js/wsn-script.js diff --git a/README.md b/README.md index 52d1ecc..b431a64 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,5 @@ Customers come and go on your online store when they found that the product they Get the plugin from the [WordPress.org](https://wordpress.org/plugins/woo-in-stock-notifier/) -[Click Here](http://blog.govindkumar.me/introducing-woo-in-stock-notifier-plugin/) to know more about the plugin. - ## Contribution Please raise issue or sent Pull Request if you find any bugs in plugin. diff --git a/gulpfile.js b/gulpfile.js index 002019f..65a09f3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,8 +9,8 @@ const webpack = require( 'webpack' ); const webpackStream = require( 'webpack-stream' ); const - sourceFiles = 'src/admin/', - sourceJsFiles = sourceFiles + '**/*.js', + sourceFiles = 'src/', + sourceJsFiles = sourceFiles + '**/**/*.js', outputDir = 'build'; function watchFiles() { @@ -28,13 +28,13 @@ function watchAllFiles() { gulp.task( 'plugin-pot', function() { return gulp.src( '**/*.php' ) .pipe( wpPot( { - domain: 'the-hub-client', + domain: 'in-stock-notifier', } ) ) - .pipe( gulp.dest( 'i18n/languages/the-hub-client.pot' ) ); + .pipe( gulp.dest( 'i18n/languages/in-stock-notifier.pot' ) ); } ); gulp.task( 'plugin-zip-cleanup', function( done ) { - del.sync( [ 'build/the-hub-client' ] ); + del.sync( [ 'zip/woo-in-stock-notifier' ] ); done(); } ); @@ -47,25 +47,13 @@ gulp.task( 'plugin-zip-copy', function() { '!.gitattributes', '!.gitignore', '!.gitmodules', - '!composer.json', - '!composer.lock', '!package.json', '!package-lock.json', '!webpack.config.js', - '!webpack.config.admin.js', '!gulpfile.js', - '!.stylelintrc', '!.eslintrc.js.js', - '!Gulpfile.js', '!README.md', - '!.vscode/*', - '!.vscode', - '!tests/**', - '!tests', - '!build/**', - '!build', - '!bitbucket-pipelines.yml', - '!phpcs.ruleset.xml', + '!zip/**', ]; return gulp.src( glob ) @@ -79,17 +67,17 @@ gulp.task( 'plugin-zip', gulp.series( 'plugin-zip-cleanup', 'plugin-zip-copy', f .pipe( gulp.dest( 'zip/' ) ); }, 'plugin-zip-cleanup' ) ); -gulp.task( 'set-production-env', function( done ) { +gulp.task( 'production-env', function( done ) { process.env.NODE_ENV = 'production'; done(); } ); gulp.task( 'watch', series( watchFiles, gulp.parallel( watchAllFiles ) ) ); -gulp.task( 'build', gulp.series( [ 'set-production-env' ], gulp.parallel( watchFiles ) ) ); +gulp.task( 'build', gulp.series( [ 'production-env' ], gulp.parallel( watchFiles ) ) ); gulp.task( 'default', gulp.series( [ 'build' ] ) ); gulp.task( 'release', gulp.series( - [ 'set-production-env' ], + [ 'production-env' ], [ 'build' ], [ 'plugin-pot' ], [ 'plugin-zip' ], diff --git a/inc/classes/class-wsn-email.php b/inc/classes/class-wsn-email.php index e28b29b..e852cea 100644 --- a/inc/classes/class-wsn-email.php +++ b/inc/classes/class-wsn-email.php @@ -95,10 +95,10 @@ public function trigger( $users, $product_id ) { ); // build header - $header = $this->get_headers() . 'BCC: ' . implode( ',', $users ) . "\r\n"; + $header = $this->get_headers() . "\r\n"; // send email - $response = $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $header, $this->get_attachments() ); + $response = $this->send( implode( ',', $users ), $this->get_subject(), $this->get_content(), $header, $this->get_attachments() ); // Return true in wsn_email_send_response. if ( $response ) { diff --git a/inc/classes/class-wsn-initialize.php b/inc/classes/class-wsn-initialize.php index 9eb1272..1d125ac 100644 --- a/inc/classes/class-wsn-initialize.php +++ b/inc/classes/class-wsn-initialize.php @@ -49,7 +49,7 @@ class WSN_Initialize { public function __construct() { // Add plugin setting menu in back end . - add_action( 'admin_menu', array( __CLASS__, 'instockalert_option_args' ) ); + add_action( 'admin_menu', array( __CLASS__, 'in_stock_submenu' ) ); // Add the waitlist user clumn in manage product page. add_filter( 'manage_edit-product_columns', array( $this, 'instockalert_add_column' ) ); @@ -309,10 +309,10 @@ public function wsn_enqueue_assets() { wp_enqueue_script( 'jquery' ); // Add the plugin style file. - wp_enqueue_style( 'wsn_style', WSN_ASSEST_PATH . '/css/wsn-style.css' ); + wp_enqueue_style( 'wsn_styles', WSN_ASSEST_PATH . 'css/front.min.css' ); // Add plugin js script. - wp_enqueue_script( 'wsn_scripts', WSN_ASSEST_PATH . '/js/wsn-script.js' ); + wp_enqueue_script( 'wsn_scripts', WSN_ASSEST_PATH . 'js/front.min.js' ); } /** @@ -337,18 +337,18 @@ public function wsn_register_settings() { /** * Add the waitlist setting sub menu inside the woo commerce */ - public static function instockalert_option_args() { + public static function in_stock_submenu() { // Add sub menu in woo commerce menu. add_submenu_page( 'woocommerce', - 'In-Stock Notifier', - 'In-Stock Notifier', + __( 'In-Stock Notifier', 'in-stock-notifier' ), + __( 'In-Stock Notifier', 'in-stock-notifier' ), 'manage_options', 'in-stock-notifier-option', array( __CLASS__, 'wsn_waitlist_option_page' ), - 'dashicons-list-view', - 59 ); + 59 + ); } /** @@ -358,62 +358,62 @@ public static function instockalert_option_args() { */ public static function wsn_waitlist_option_page() { ?> -
+
-

-
-
+

+
+ - - - - - - - - - - - - - - - - - - - - - - - -
/>
-
-
/> -
/> + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - - + + + + -
/>
+
+
/> +
/> -
/> -
/> +
+
-
-
+ +
true ) ) ); - } - } elseif ( '_restore' === $action_type ) { - - if ( wsn_register_user( $user_email, $product_id ) ) { + // Get the user's email. + $user_email = sanitize_email( wp_unslash( $_REQUEST['user_id'] ) ); + switch ( $action_type ) { + case '_remove' : + // Remove user from the archive. if ( wsn_remove_form_archive( $user_email, $product_id ) ) { wp_die( wp_json_encode( array( 'remove' => true ) ) ); } - } + break; + case '_restore': + // Restore user email archive + if ( wsn_register_user( $user_email, $product_id ) && wsn_remove_form_archive( $user_email, $product_id ) ) { + wp_die( wp_json_encode( array( 'remove' => true ) ) ); + } + break; } + wp_die(); } @@ -156,7 +139,7 @@ public function kia_ajax_email_action( $actions ) { */ public function wsn_waitlist_send_mail_ajax() { - if ( ! isset( $_REQUEST['product'] ) && ! isset( $_REQUEST['type'] ) || ! isset( $_REQUEST['email'] ) ) { + if ( ! isset( $_REQUEST['product'] ) && ! isset( $_REQUEST['type'] ) ) { wp_die(); } @@ -166,9 +149,15 @@ public function wsn_waitlist_send_mail_ajax() { // Get the type. $type = sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ); + if ( 'all' !== $type && ! isset( $_REQUEST['email'] ) ) { + wp_die(); + } + // Is we need to empty the list after email sent? $do_empty = get_option( 'remove_after_email' ); + $is_archived = false; + // Load woo commerce mailer class. WC()->mailer(); @@ -191,34 +180,43 @@ public function wsn_waitlist_send_mail_ajax() { // Get the value of the archive setting field. $is_archived = get_option( 'archive' ); - // Getting the email of user. - $user_email = sanitize_email( wp_unslash( $_REQUEST['email'] ) ); - if ( $is_archived ) { + foreach ( $users as $user_email ) { + // remove user from the list after archive + wsn_leave_user( $user_email, $product_id ); - // Store email into archived after email sent. - wsn_store_email_into_archive( $user_email, $product_id ); + // Store email into archived after email sent. + if ( ! empty( $user_email ) ) { + wsn_store_email_into_archive( $user_email, $product_id ); + } + } } } $response = apply_filters( 'wsn_email_send_response', false ); - // Check response. - if ( $response ) { - if ( 'all' === $type ) { - $msg = ' ' . esc_attr__( 'Message successfully sent to all user', 'in-stock-notifier' ); - } else { - $msg = ''; - } - $send = true; - } else { - $msg = ''; - $send = false; + switch ( $type ) { + case 'all': + ob_start(); + if ( $response ) { + $this->render_notice( __( 'Email sent!' ), __( 'Email successfully sent to all users.' ), 'dashicons-yes' ); + } else { + $this->render_notice( __( 'Failed!' ), __( 'Failed to send email to all users.' ), 'dashicons-no' ); + } + $msg = ob_get_clean(); + exit; + default: + if ( $response ) { + $msg = ''; + } else { + $msg = ''; + } } - if ( $do_empty && $send ) { + $send = (bool) $response; + if ( $do_empty && $send ) { if ( 'all' === $type ) { // Remove all user from waitlist. @@ -231,28 +229,15 @@ public function wsn_waitlist_send_mail_ajax() { } // Pass param to js. echo wp_json_encode( array( - 'msg' => $msg, - 'remove' => $do_empty, - 'send' => $send, - 'id' => $product_id, + 'msg' => $msg, + 'remove' => (int) $do_empty, + 'archived' => (int) $is_archived, + 'send' => $send, + 'id' => $product_id, ) ); wp_die(); } - /** - * Adding the js file in wp admin. - * - * @access public - */ - public function enqueue_scripts() { - - // Add wsn-metabox.js in backend. - wp_enqueue_script( 'wsn-waitlist-metabox', WSN_ASSEST_PATH . 'js/wsn-metabox.js', array( 'jquery' ) ); - - // Localize ajax script in backend. - wp_localize_script( 'wsn_waitlist_meta', 'wsn_waitlist_meta', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); - } - /** * Remove user from the waitlist. * @@ -279,6 +264,8 @@ public function remove_user_ajax() { } } } + + wp_die(); } /** @@ -295,10 +282,10 @@ public function button_to_send_mail( $email, $id, $type = 'single' ) { ob_start(); ?> - " data-user_email="" + data-product_id="" + title=""> @@ -353,6 +340,10 @@ public function add_new_user_ajax() { $em = $this->button_to_send_mail( $email, $pid ); if ( wsn_register_user( $email, $pid ) ) { + + // remove user from the archive list + wsn_remove_form_archive( $email, $pid ); + wp_die( wp_json_encode( array( 'email' => $email, 'status' => 'success', @@ -366,13 +357,6 @@ public function add_new_user_ajax() { } } - /** - * Add admin js to backend. - */ - public function add_admin_script() { - wp_enqueue_script( 'wsn_scripts', wsn_ASSETS_URL . '/js/wsn-admin.js' ); - } - /** * Load wc email action . * @@ -393,23 +377,26 @@ public function list_users_for_product( $pid, $product ) { // get the list of users $waitlist = wsn_get_waitlist( $pid ); ?> -
- +
ID ); - - // Get the product type. - $product_type = $wsn_product->product_type; - - // Get the parent id. - $parent_id = $wsn_product->get_id(); - - $waitlist = wsn_get_waitlist( $pid ); + $total_waitlist_user = count( get_post_meta( $pid, WSN_USERS_META_KEY, true ) ); ?> -
-
-
-
-
-
-
Add new user
-
- -
-
- - + +
+
+
+
+
    "> +
  • " + data-type="users" + > -
  • -
  • "> +
  • +
  • " + data-type="archived" + > -
  • -
-
- -
-
" class="wsn-tabs__content wsn-tabs__content--current"> -
-
-
Users waitlist
- -
- -
- -
-
-
-
-
-
-
-
- +
+ +
+
+
+
" + class="wsn-tabs__content wsn-tabs__content--current"> +
+
+
+
+ +
+
+
+
"> +
+
+
+
+
+ $data ) { + // get the total user waitlist $total_waitlist_user = count( get_post_meta( $pid, WSN_USERS_META_KEY, true ) ); ?> -
-
+
+
-
-
-
-
+
+
+
+
button_to_send_mail( $data, $pid ); ?> -
-
- -
-
-
-
- +
+ +
+
+
+
+ render_notice( + __( 'No users' ), + apply_filters( 'wsn_waitlist_no_users', __( 'Currently there are no users waiting for this product.
Click on "Add new user" to add new user manually.', 'in-stock-notifier' ) ), + 'dashicons-warning', + ! empty( $waitlist ) + ); ?> -
-
-
-
-
-
" class="wsn-tabs__content"> -
-
-
Archived Wait List
- -
- -
- -
-
-
-
-
-
-
-
+
+
+
+
+
+
" class="wsn-tabs__content wsn-archived-list" + data-productid=""> +
+
+
Archived Wait List
+
+ +
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
- button_to_send_mail( $data, $pid ); ?> -
-
- - - -
-
-
-
+
+
+
+
+ +
+
+ +
+
+
+
render_notice( + __( 'No archived users' ), + apply_filters( 'wsn_waitlist_no_archived_users', __( 'User will be added to archived list once the email is sent.
To enable this feature go to "WooCommerce > In-Stock Notifier".', 'in-stock-notifier' ) ), + 'dashicons-warning', + ! empty( $archived_users ) + ); ?> -
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
* @access public */ public function wsn_product_tab_callback() { - global $post; - $new_user_nonce = wp_create_nonce( 'add_new_user_js' ); - - // Get product by id. + /** @var \WC_Product $wsn_product */ $wsn_product = wc_get_product( $post->ID ); // Get the product type. $product_type = $wsn_product->product_type; - // Get the parent id. - $parent_id = $wsn_product->get_id(); - $pid = intval( $wsn_product->get_id() ); - $waitlist = wsn_get_waitlist( $pid ); + // Product isn't live yet + if ( 'auto-draft' === $post->post_status ) { + $this->render_notice( __( 'Not published' ), __( 'Product is not published yet.' ) ); + + return; + } switch ( $product_type ) { case 'simple': - $this->waitlist_box( $pid, $wsn_product ); + if ( $wsn_product->is_in_stock() ) { + $this->render_notice( __( 'In-stock' ), __( 'Product is already available for sale.' ), 'dashicons-smiley' ); + } else { + $this->waitlist_box( $pid, $wsn_product ); + } break; case 'variable'; // Get all variations. $variations = $wsn_product->get_available_variations(); for ( $i = 0; $i < count( $variations ); $i ++ ) { + $pid = intval( $variations[ $i ]['variation_id'] ); - $pid = intval( $variations[ $i ]['variation_id'] ); + /** @var \WC_Product $variation_product */ $variation_product = wc_get_product( $pid ); ?> -
-
-

-
- get_formatted_name() ); ?> -

- -
-
-
- waitlist_box( $pid, $variation_product ); ?> -
-
-
-
-
+
+
+

+
+ get_formatted_name() ); ?> +

+ +
+
+
+ is_in_stock() ) { + $this->render_notice( __( 'In-stock' ), __( 'Product is already available for sale.' ), 'dashicons-smiley' ); + } else { + $this->waitlist_box( $pid, $variation_product ); + } + ?> +
+
+
+
+
- - - - - - ID ); - - // Get the product type. - $product_type = $wsn_product->product_type; - - // Get the parent id. - $parent_id = $wsn_product->get_id(); - - // If the product type is variable. - if ( 'variable' === $product_type ) { - - // Get all variations. - $variations = $wsn_product->get_available_variations(); - - for ( $i = 0; $i < count( $variations ); $i ++ ) { - - $pid = intval( $variations[ $i ]['variation_id'] ); - $variation_product = wc_get_product( $pid ); - ?> -
-

-
- get_formatted_name() ); ?> -

- -
-
-
- -
- is_in_stock() ) { - ?> - - - - - - -
- -
- - - - - - - - - - - -
- - - - -
- button_to_send_mail( $data, $product_id ); - ?> - - - - -
- -
- - - - - button_to_send_mail( $data, $product_id, 'all' ); ?> -     - -
-
- -
-
- -
- - -
-
-
- -
-
-
-
get_id() ); - - $this->waitlist_box( $pid, $wsn_product ); - - return; - ?> - -
-
- - is_in_stock() ) { ?> - -
- -
- - -
- -
- - - - - - - - - - - - - -
- - - - - -
- - - button_to_send_mail( $data, $pid ); ?> - - -
- -
- - - - - - - button_to_send_mail( $data, intval( $pid ), 'all' ); ?> -     - - - - -
-
-
- - - -
-
- -
- - -
-
-
post_status ) { - echo esc_attr__( 'Product is not published yet.', 'in-stock-notifier' ); - } else { - echo esc_attr__( 'Product is already available for sale ', 'in-stock-notifier' ); - } - ?>
-
- -
ID; @@ -123,9 +132,9 @@ public function output_form( $html, $availability, $product = false ) { } // @Todo add front-end functionality for the variable product. - if ( ! is_user_logged_in() && ! get_option( 'unregistered_can_join' ) || $product->is_in_stock() || 'variation' === $product->product_type ) { - return $html; - } + if ( ! is_user_logged_in() && ! get_option( 'unregistered_can_join' ) || $product->is_in_stock() ) { + return $html; + } return $this->form_data( $product, $html ); } @@ -143,7 +152,7 @@ public function form_data( $product, $html ) { // Check if product is in stock. if ( ! isset( $product ) || $product->is_in_stock() ) { - return; + return $html; } // Product type. @@ -164,119 +173,100 @@ public function form_data( $product, $html ) { $url = add_query_arg( WSN_USERS_META_KEY . '-action', 'register', $url ); $url = add_query_arg( 'var_id', $product_id, $url ); - ob_start(); - - ?> -
allowed_product_types, true ) ) { + ?> +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ + // Logged user data. + $user = wp_get_current_user(); - - - + // Logged user email. + $email = $user->user_email; -
- -
+ // Get waitlist of product. + $waitlist = wsn_get_waitlist( $product_id ); -
-
- - - - +
+
+
+
+
+ +
+
+ - -
- user_email; - - // Get waitlist of product. - if ( $waitlist = wsn_get_waitlist( $product_id ) ) { - - // Check user email if exists in waitlist. - if ( wsn_check_register( $email, $waitlist ) ) { - - ?> - - - - -
- - -
- - - -
- -
- +
- - - - - -
-
- -
- - + - +
+ -
- ID ) ) { - echo esc_html__( 'Oops! In-valid user id.', 'in-stock-notifier' ); + echo esc_html__( 'Please login to view products list.', 'in-stock-notifier' ); return false; } @@ -96,12 +96,24 @@ public function wsn_display_waitlist( $atts ) { if ( in_array( $user->user_email, $product_waitlist_email, true ) ) { - $product = new \WC_Product( $row->post_id ); + $product_id = $row->post_id; + + if ( 'product_variation' === get_post_type( $product_id ) ) { + /** @var \WC_Product_Variation $variation product */ + $variation = new \WC_Product_Variation( $product_id ); + $product_name = $variation->get_title() . ' - ' .implode( " / ", $variation->get_variation_attributes() ); + $product_url = $variation->get_permalink(); + } else { + /** @var \WC_Product $product product */ + $product = new \WC_Product( $row->post_id ); + $product_url = $product->get_permalink(); + $product_name = $product->get_formatted_name(); + } ?> - get_formatted_name() ); ?> + In-Stock Notifier’ you will get When the email is sent to the sent to the user, this plugin allows you to move that email address to archive(in case you don’t want to lose the current wait list). You can restore or remove the email address from the archive list. == Changelog == += 1.0.2 = +* Made compatible with newest version of Woocommerce +* Re-build UI/UX +* Added more filters/actions to allow modifications + = 1.0.1 = * Email was not sending to the user. * Could not add user to the waitlist. diff --git a/src/admin/main.js b/src/admin/main.js index 0683340..591ddca 100644 --- a/src/admin/main.js +++ b/src/admin/main.js @@ -4,48 +4,33 @@ * @version 1.0.0 */ jQuery( document ).ready( function( $ ) { - const total = 0; - - $( 'a#show_archived' ).on( 'click', function( e ) { - e.preventDefault(); - - const current = $( this ), - product_id = current.data( 'product_id' ); - - $.ajax( { - url: _wsn_waitlist.ajax_url, - dataType: 'json', - data: { action: 'archive_function', product: product_id, type: '_show' }, - success( data ) { - if ( data != '' ) { - current.parents().find( '.waitlist_data#' + product_id ).hide(); - const archive_row = current.parents().find( '.archived_data_panel#' + product_id ).fadeIn( 500 ).find( '._archive_userlist' ); - archive_row.append( 'EmailRestore Remove' ); - $.each( data, function( key, data ) { - archive_row.append( '' + data + ' ' ); - } ); - archive_row.append( '' ); - } - }, - } ); - } ); - $( 'ul.wsn-tabs-nav li.wsn-tabs-nav-item' ).click( function() { const tabId = $( this ).attr( 'data-tab' ); + const tabType = $( this ).attr( 'data-type' ); $( this ).closest( '.wsn-tabs' ).find( '.wsn-tabs-nav-item' ).removeClass( 'wsn-tabs-nav-item--current' ); $( this ).closest( '.wsn-tabs' ).find( '.wsn-tabs__content' ).removeClass( 'wsn-tabs__content--current' ); $( this ).addClass( 'wsn-tabs-nav-item--current' ); $( '#' + tabId ).addClass( 'wsn-tabs__content--current ' ); + + const actions = $( this ).closest( '.wsn-tabs' ).find( '.wsn-tabs__action' ); + + if ( 'archived' === tabType ) { + actions.addClass( 'wsn-hidden' ); + } else { + actions.removeClass( 'wsn-hidden' ); + } } ); - $( '.archived_data_panel' ).on( 'click', 'a.removeArchivedUser', function( e ) { + $( '.wsn-archived-list' ).on( 'click', 'a.removeArchivedUser', function( e ) { e.preventDefault(); - const current_obj = $( this ), - user_email = current_obj.data( 'uid' ), - product_id = current_obj.data( 'pid' ); + const currentEl = $( this ), + user_email = currentEl.data( 'uid' ), + product_id = currentEl.data( 'pid' ), + row = currentEl.closest( '.wsn-tab-table-item' ), + table = currentEl.closest( '.wsn-tab-table' ); const data = { action: 'archive_function', @@ -53,17 +38,30 @@ jQuery( document ).ready( function( $ ) { user_id: user_email, type: '_remove', }; + jQuery.post( ajaxurl, data, function() { - current_obj.parent().closest( 'tr' ).fadeOut( 400 ); + if ( ! data ) { + return; + } + + row.fadeOut( 1000, function() { + row.remove(); + + if ( table.find( '.wsn-tab-table-body .wsn-tab-table-item' ).length <= 0 ) { + table.find( '.wsn-notice' ).removeClass( 'wsn-hidden' ); + } + } ); } ); } ); - $( '.archived_data_panel' ).on( 'click', 'a.restoreEmail', function( e ) { + $( '.wsn-archived-list' ).on( 'click', 'a.restoreEmail', function( e ) { e.preventDefault(); - const current_obj = $( this ), - user_email = current_obj.data( 'uid' ), - product_id = current_obj.data( 'pid' ); + const currentEl = $( this ), + user_email = currentEl.data( 'uid' ), + product_id = currentEl.data( 'pid' ), + row = currentEl.closest( '.wsn-tab-table-item' ), + table = currentEl.closest( '.wsn-tab-table' ); const data = { action: 'archive_function', @@ -71,47 +69,66 @@ jQuery( document ).ready( function( $ ) { user_id: user_email, type: '_restore', }; + jQuery.post( ajaxurl, data, function( data ) { - current_obj.parent().closest( 'tr' ).fadeOut( 1000 ); + if ( ! data ) { + return; + } + + row.fadeOut( 1000, function() { + row.remove(); + + if ( table.find( '.wsn-tab-table-body .wsn-tab-table-item' ).length <= 0 ) { + table.find( '.wsn-notice' ).removeClass( 'wsn-hidden' ); + } + } ); } ); } ); $( 'a.close_archived' ).click( function( e ) { e.preventDefault(); - const current_obj = $( this ), - product_id = current_obj.attr( 'id' ); + const currentEl = $( this ), + product_id = currentEl.attr( 'id' ); $( '#form' + product_id ).hide(); - current_obj.parents().find( '.waitlist_data#' + product_id ).show(); - current_obj.parents().find( '.archived_data_panel#' + product_id ).find( '._archive_userlist' ).html( '' ); - current_obj.parents().find( '.archived_data_panel#' + product_id ).hide(); + currentEl.parents().find( '.waitlist_data#' + product_id ).show(); + currentEl.parents().find( '.archived_data_panel#' + product_id ).find( '._archive_userlist' ).html( '' ); + currentEl.parents().find( '.archived_data_panel#' + product_id ).hide(); } ); - $( '.wsn-users-list' ).on( 'click', 'a.removeUser', function( e ) { + $( '.wsn-tab-table' ).on( 'click', 'a.removeUser', function( e ) { e.preventDefault(); - const current_obj = $( this ); + const currentEl = $( this ); - const product_id = current_obj.data( 'product_id' ), - email = current_obj.data( 'email' ), - uid = current_obj.data( 'uid' ), - total = current_obj.data( 'total' ), - nonce = current_obj.data( 'wp_nonce' ), - action = current_obj.data( 'action' ); + const productId = currentEl.data( 'product_id' ), + email = currentEl.data( 'email' ), + uid = currentEl.data( 'uid' ), + total = currentEl.data( 'total' ), + nonce = currentEl.data( 'wp_nonce' ), + action = currentEl.data( 'action' ), + row = $( '#row-' + uid + '-' + productId ), + table = row.closest( '.wsn-tab-table' ); const data = { action: 'removeUser', security: nonce, - p_id: product_id, + p_id: productId, wsn_email: email, inc: total, wp_action: action, }; jQuery.post( ajaxurl, data, function() { - $( '#row-' + uid + '-' + product_id ).fadeOut( 1000 ); + row.fadeOut( 1000, function() { + row.remove(); + + if ( table.find( '.wsn-tab-table-body .wsn-tab-table-item' ).length <= 0 ) { + table.find( '.wsn-notice' ).removeClass( 'wsn-hidden' ); + } + } ); } ); } ); @@ -138,21 +155,31 @@ jQuery( document ).ready( function( $ ) { $( 'button#wsn_add_btn' ).on( 'click', function( e ) { e.preventDefault(); - const current_obj = $( this ); + const currentEl = $( this ); - let form_id = current_obj.data( 'product_id' ), - email = current_obj.parent().find( '.usrEmail#' + form_id ).val(), - total = current_obj.data( 'total' ), + // get the product id + const formID = currentEl.data( 'product_id' ); + + // get email field + const emailField = currentEl.closest( '.wsn-form' ).find( '#user-email-field-' + formID ); + + // get the close button + const closeButton = currentEl.closest( '.wsn-form' ).find( '#wsn_hide_add_new_user' ); + + let + email = emailField.val(), + total = currentEl.data( 'total' ), uid = total + 1, - nonce = current_obj.data( 'nonce' ); + nonce = currentEl.data( 'nonce' ), + form = $( '#wsn-tab-table-' + formID ); - current_obj.parent().find( '.usrEmail#' + form_id ).val( '' ); - current_obj.parent().find( '.wsn-empty' ).hide(); + // remove email + emailField.val( '' ); const data = { action: 'addNewUser', security: nonce, - p_id: form_id, + p_id: formID, inc: uid, email, }; @@ -166,7 +193,7 @@ jQuery( document ).ready( function( $ ) { if ( ! email_pattern.test( email ) ) { alert( 'Please enter valid email address' ); - current_obj.parent().find( '.usrEmail#' + form_id ).focus(); + emailField.focus(); return false; } @@ -174,15 +201,35 @@ jQuery( document ).ready( function( $ ) { jQuery.post( ajaxurl, data, function( data ) { const outputData = JSON.parse( data ); - if ( outputData.status == 'success' ) { - total += 1; - current_obj.data( 'total', total ); - current_obj.parents().find( '.no_user#' + form_id ).hide(); - $( 'table#waitlists' + form_id ).append( '' + outputData.email + '' + outputData.emailLink + '' + outputData.removeLink + '' ); - $( 'table#waitlists' + form_id + ' tr:last' ).animate( { backgroundColor: 'rgb(247, 255, 176)' }, 'slow' ).animate( { backgroundColor: '#fff' }, 'slow' ); - current_obj.parent().find( '.usrEmail#' + form_id ).focus(); - } else if ( outputData.status == 'exists' ) { - alert( email + ' is already exist! ' ); + switch ( outputData.status ) { + case 'success': + total += 1; + currentEl.data( 'total', total ); + currentEl.parents().find( '.no_user#' + formID ).hide(); + + const tableList = $( '#wsn-tab-table-' + formID + ' > .wsn-tab-table-body' ); + + tableList.append( + '
\n' + + '
' + outputData.email + '
\n' + + '
\n' + + '
\n' + + '
' + outputData.emailLink + '
\n' + + '
' + outputData.removeLink + '
\n' + + '
\n' + + '
\n' + + '
' + ); + + form.find( '.wsn-notice' ).addClass( 'wsn-hidden' ); + closeButton.click(); + + $( '#wsn-tab-table-' + formID + ' .wsn-tab-table-item:last' ).animate( { backgroundColor: 'rgb(247, 255, 176)' }, 'slow' ).animate( { backgroundColor: '#fff' }, 'slow' ); + break; + case 'exists': + alert( email + ' is already exist! ' ); + emailField.focus(); + break; } } ); } ); @@ -191,14 +238,14 @@ jQuery( document ).ready( function( $ ) { e.preventDefault(); const - current_obj = $( this ), - product_id = current_obj.data( 'product_id' ), - user_email = current_obj.data( 'user_email' ), - actionType = current_obj.data( 'type' ), - wrapper = ( actionType == 'all' ) ? current_obj.parent( '.wsn-tab-table' ) : current_obj.parents( '.wsn-tab-table-item-col-action' ); + currentEl = $( this ), + product_id = currentEl.data( 'product_id' ), + user_email = currentEl.data( 'user_email' ), + actionType = currentEl.data( 'type' ), + wrapper = ( actionType == 'all' ) ? currentEl.parent( '.wsn-tab-table' ) : currentEl.parents( '.wsn-tab-table-item-col-action' ); if ( actionType == 'all' ) { - $( document ).find( '#waitlists' + product_id + '' ).find( 'tr.old' ).addClass( 'unclickable' ); + $( document ).find( '#waitlists-' + product_id + '' ).find( 'tr.old' ).addClass( 'unclickable' ); } wrapper.block( { @@ -220,11 +267,39 @@ jQuery( document ).ready( function( $ ) { type: actionType, }, success( res ) { - if ( res.send ) { - wrapper.html( res.msg ); - } else { - wrapper.html( res.msg ); - } + wrapper.html( res.msg ); + wrapper.unblock(); + }, + } ); + } ); + + $( '.wsn-tabs' ).on( 'click', 'a.wsn-send-email-all-users', function( e ) { + e.preventDefault(); + + const + currentEl = $( this ), + product_id = currentEl.data( 'product_id' ), + wrapper = $( document ).find( '#wsn-tab-table-' + product_id ); + + wrapper.block( { + message: null, + overlayCSS: { + background: '#fff no-repeat center', + opacity: 0.5, + cursor: 'none', + }, + } ); + + $.ajax( { + url: _wsn_waitlist.ajax_url, + dataType: 'json', + data: { + action: 'wsn_waitlist_send_mail', + product: product_id, + type: 'all', + }, + success( res ) { + wrapper.html( res.msg ); wrapper.unblock(); }, } ); diff --git a/src/admin/main.scss b/src/admin/main.scss index 0a77539..596fb02 100644 --- a/src/admin/main.scss +++ b/src/admin/main.scss @@ -128,6 +128,15 @@ .wsn-tab-table-body { margin: 0 -15px; + + &__no-result { + align-items: center; + border-top: solid 1px #eee; + color: #aaa; + display: flex; + justify-content: center; + padding: 30px; + } } .wsn-tab-table-item { @@ -177,7 +186,7 @@ } .wsn-splash { - background: #fff; + background: #f8f8f8; display: none; &__body { @@ -201,6 +210,13 @@ margin: 0; } + h5 { + color: #333; + font-size: 31px; + line-height: 31px; + margin: 0; + } + &-field { align-items: center; display: flex; @@ -215,7 +231,7 @@ padding: 5px 10px; margin: 15px 0; width: 50%; - background: transparent; + background: #fff; } } @@ -226,4 +242,47 @@ .wsn-product-variation-head { border-top: solid 1px #eee; +} + +.wsn-hidden { + display: none; +} + +.wsn-notice { + border-top: solid 1px #eee; + + &__main h5 { + color: #666; + font-size: 19px; + margin: 0; + padding: 10px 0; + } + + &__inner { + max-width: 500px; + margin: 0 auto; + text-align: center; + padding: 50px 0; + } + + &__icon { + text-align: center; + + i { + color: #aaa; + font-size: 40px; + line-height: 40px; + height: 40px; + width: 40px; + } + } +} + +.wsn-notice-desc { + color: #aaa; +} + +.wsn-unclickable { + opacity: 0.5; + pointer-events: none; } \ No newline at end of file diff --git a/src/css/wsn-style.css b/src/css/wsn-style.css deleted file mode 100644 index de23b7d..0000000 --- a/src/css/wsn-style.css +++ /dev/null @@ -1,238 +0,0 @@ -/** -* Wocommerce In-Stock Notifier CSS -* @author Govind Kumar -* @version 1.0.0 -*/ - -.wc-metaboxes-wrapper .wc-metabox table { - width: 70%; -} - -#wsn_callback .dashicons { - font-size: 18px; -} - - -.wsn-users-list a, ._archive_userlist a { - color: #5D5D5D; - text-decoration: none; -} - -a.close_archived { - text-decoration: none; -} - -.wsn-users-list a:hover, ._archive_userlist a:hover { - color: #0073aa; -} - -.wsn-users-list table { - border-collapse: collapse; - width: 100%; -} - -.wsn-users-list td, .wsn-users-list th { - text-align: left; - padding: 5px 0px 5px 0px !important; -} - -.wsn-users-list th { - background-color: #4CAF50; - color: white; -} - -.wsn-users-list a { - color: #555564; -} - -.wsn_waitlist_form { - display: inline-block; - margin-bottom: 12px; -} - -.wsn_title { - font-weight: 100; -} - -.wsn_button { - float: none !important; -} - -.wsn_form { - padding: 18px 0; -} - -.wsn_product_container { - position: relative; -} - -.archived_data_panel { - left: 0; - bottom: 0; - top: 0; - display: none; - right: 0; - background: white; - z-index: 999; -} - -#show_archived { - float: right; -} - -.close_archived { - float: right; -} - -.add_user_btn { - margin-left: 12px !important; -} - -.waitlist_data a { - padding-right: 5px; - text-decoration: none; -} - -.unclickable { - pointer-events: none; - opacity: 0.5; -} - -#poststuff #wsn_product .inside, #wsn_product .inside { - padding: 0; - margin: 0; -} - -#wsn_product .inside .wsn-action-col { - text-align: center; -} - -#wsn_product .inside .wsn-email-col { - text-align: center; - -} - -#wsn_product .wsn-empty { - padding: 16px 0px; -} - -#wsn_product .wrap { - margin: 0px; -} - -#wsn_product .wsn-users-list { - border-top: none; - padding: 0px; - border-bottom: solid 1px #EFEFEF; - margin-bottom: 9px; -} - -.postbox .inside .woocommerce_options_panel { - min-height: auto !important; -} - -.no_product { - padding: 12px; -} - -.archive_table th { - text-align: left; -} - -.wc-metaboxes-wrapper .wc-metabox table { - padding: 4px !important; - border-top: 0px !important; -} - -.add_new_user_form { - border-bottom: solid 1px #ddd; - padding-bottom: 12px !important; -} - -.add_new_user_form .usrEmail { - width: 35%; -} - -.add_new_user_form #wsn_add_btn { - margin-left: 12px; -} - -._archive_userlist th { - text-align: left; -} - -._archive_userlist #r_archived { - text-align: center; -} - -._archive_userlist #restore_archived { - text-align: center; -} - -#archive_table_head { - font-weight: bold; -} - -.archived_head_text { - padding: 10px 5px; - font-size: 15px; - border-bottom: solid 1px #EFEFEF; -} - -.wsn-user-email-col { - width: 70%; -} - -td.index_col { - width: 5%; -} - -.wsn-container { - margin: 0 auto; - width: 100%; -} - -/*.wsn-tabs {*/ -/* padding: 20px;*/ -/*}*/ - -/*ul.wsn-tabs__nav {*/ -/* border-bottom: solid 1px #ddd;*/ -/* margin: 0px;*/ -/* padding: 0px;*/ -/* list-style: none;*/ -/*}*/ - -/*ul.wsn-tabs__nav li.wsn-tabs__nav-item {*/ -/* background: none;*/ -/* color: #222;*/ -/* display: inline-block;*/ -/* padding: 10px 15px;*/ -/* cursor: pointer;*/ -/* margin: 0;*/ -/* border: solid 1px transparent;*/ -/*}*/ - -/*ul.wsn-tabs__nav li.wsn-tabs__nav-item--current {*/ -/* border: solid 1px #ddd;*/ -/* border-bottom: dashed 1px white;*/ -/* border-radius: 5px 5px 0 0;*/ -/* color: #222;*/ -/* position: relative;*/ -/*}*/ - -/*.wsn-tabs__body {*/ -/* border: solid 1px #ddd;*/ -/* border-radius: 0 0 5px 5px;*/ -/* border-top: none;*/ -/* margin-top: -1px;*/ -/*}*/ - -/*.wsn-tabs__content {*/ -/* display: none;*/ -/* padding: 15px;*/ -/*}*/ - -/*.wsn-tabs__content.wsn-tabs__content--current {*/ -/* display: inherit;*/ -/*}*/ \ No newline at end of file diff --git a/src/front/main.js b/src/front/main.js index e69de29..b9b8ec0 100644 --- a/src/front/main.js +++ b/src/front/main.js @@ -0,0 +1,38 @@ +/** + * Woo-commerce In-Stock Notifier JavaScript + * @author Govind Kumar + * @version 1.0.0 + */ +jQuery( document ).ready( function( $ ) { + $( '.product' ).on( 'keyup', '.wsn-waitlist-email-field', function( e ) { + // get the email + const email = $( this ).val(); + + // get the form + const form = $( this ).closest( '.wsn-form' ); + const submitBtn = form.find( '.wsn-submit-form' ); + + if ( validateEmail( email ) ) { + submitBtn.removeClass( 'wsn-submit-form--disabled' ); + } else { + submitBtn.addClass( 'wsn-submit-form--disabled' ); + } + } ); + + $( '.product' ).on( 'click', '.wsn-submit-form', function( e ) { + e.preventDefault(); + + // get the form + const + form = $( this ).closest( '.wsn-form' ), + emailField = form.find( '.wsn-waitlist-email-field' ), + url = $( this ).attr( 'href' ); + + window.location = url + '&wsn_email=' + emailField.val(); + } ); +} ); + +function validateEmail( email ) { + const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return re.test( email ); +} diff --git a/src/front/main.scss b/src/front/main.scss index e69de29..fa32afd 100644 --- a/src/front/main.scss +++ b/src/front/main.scss @@ -0,0 +1,28 @@ +.wsn-form { + &__content { + padding: 10px 0; + } + + &__footer { + margin-bottom: 15px; + } +} + +.wsn-form-field { + padding: 5px 0; +} + +.wsn-input-field { + min-width: 100%; +} + +.wsn-form-message-item { + padding: 5px 0; +} + +.wsn-submit-form { + &--disabled { + pointer-events: none; + opacity: .2; + } +} \ No newline at end of file diff --git a/src/helpers/colors.scss b/src/helpers/colors.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/js/wsn-admin.js b/src/js/wsn-admin.js deleted file mode 100644 index f3a2aa6..0000000 --- a/src/js/wsn-admin.js +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Woo-commerce In-Stock Notifier JavaScript - * @author Govind Kumar - * @version 1.0.0 - */ - -jQuery( document ).ready( function( $ ) { - const total = 0; - - jQuery( 'a#show_archived' ).on( 'click', function( e ) { - e.preventDefault(); - - const current = jQuery( this ), - product_id = current.data( 'product_id' ); - - $.ajax( { - url: _wsn_waitlist.ajax_url, - dataType: 'json', - data: { action: 'archive_function', product: product_id, type: '_show' }, - success( data ) { - if ( data != '' ) { - current.parents().find( '.waitlist_data#' + product_id ).hide(); - const archive_row = current.parents().find( '.archived_data_panel#' + product_id ).fadeIn( 500 ).find( '._archive_userlist' ); - archive_row.append( 'EmailRestore Remove' ); - $.each( data, function( key, data ) { - archive_row.append( '' + data + ' ' ); - } ); - archive_row.append( '' ); - } - }, - } ); - } ); - - jQuery( 'ul.wsn-tabs__nav li.wsn-tabs__nav-item' ).click( function() { - const tab_id = $( this ).attr( 'data-tab' ); - - $( 'ul.wsn-tabs__nav li' ).removeClass( 'wsn-tabs__nav-item--current' ); - $( '.wsn-tabs__content' ).removeClass( 'wsn-tabs__content--current' ); - - $( this ).addClass( 'wsn-tabs__nav-item--current' ); - $( '#' + tab_id ).addClass( 'wsn-tabs__content--current ' ); - } ); - - jQuery( '.archived_data_panel' ).on( 'click', 'a.removeArchivedUser', function( e ) { - e.preventDefault(); - - const current_obj = $( this ), - user_email = current_obj.data( 'uid' ), - product_id = current_obj.data( 'pid' ); - - const data = { - action: 'archive_function', - product: product_id, - user_id: user_email, - type: '_remove', - }; - jQuery.post( ajaxurl, data, function() { - current_obj.parent().closest( 'tr' ).fadeOut( 400 ); - } ); - } ); - - jQuery( '.archived_data_panel' ).on( 'click', 'a.restoreEmail', function( e ) { - e.preventDefault(); - - const current_obj = $( this ), - user_email = current_obj.data( 'uid' ), - product_id = current_obj.data( 'pid' ); - - const data = { - action: 'archive_function', - product: product_id, - user_id: user_email, - type: '_restore', - }; - jQuery.post( ajaxurl, data, function( data ) { - current_obj.parent().closest( 'tr' ).fadeOut( 1000 ); - } ); - } ); - - jQuery( 'a.close_archived' ).click( function( e ) { - e.preventDefault(); - - const current_obj = $( this ), - product_id = current_obj.attr( 'id' ); - - jQuery( '#form' + product_id ).hide(); - - current_obj.parents().find( '.waitlist_data#' + product_id ).show(); - current_obj.parents().find( '.archived_data_panel#' + product_id ).find( '._archive_userlist' ).html( '' ); - current_obj.parents().find( '.archived_data_panel#' + product_id ).hide(); - } ); - - jQuery( '.wsn-users-list' ).on( 'click', 'a.removeUser', function( e ) { - e.preventDefault(); - - const current_obj = $( this ); - - const product_id = current_obj.data( 'product_id' ), - email = current_obj.data( 'email' ), - uid = current_obj.data( 'uid' ), - total = current_obj.data( 'total' ), - nonce = current_obj.data( 'wp_nonce' ), - action = current_obj.data( 'action' ); - - const data = { - action: 'removeUser', - security: nonce, - p_id: product_id, - wsn_email: email, - inc: total, - wp_action: action, - }; - - jQuery.post( ajaxurl, data, function() { - jQuery( '#row-' + uid + '-' + product_id ).fadeOut( 1000 ); - } ); - } ); - - jQuery( 'a#wsn_add_new_user' ).on( 'click', function( e ) { - e.preventDefault(); - - const formid = jQuery( this ).data( 'product_id' ); - - jQuery( '#form' + formid ).toggle(); - jQuery( this ).parent().find( '.usrEmail#' + formid ).focus(); - } ); - - jQuery( 'button#wsn_add_btn' ).on( 'click', function( e ) { - e.preventDefault(); - - const current_obj = $( this ); - - let form_id = current_obj.data( 'product_id' ), - email = current_obj.parent().find( '.usrEmail#' + form_id ).val(), - total = current_obj.data( 'total' ), - uid = total + 1, - nonce = current_obj.data( 'nonce' ); - - current_obj.parent().find( '.usrEmail#' + form_id ).val( '' ); - current_obj.parent().find( '.wsn-empty' ).hide(); - - const data = { - action: 'addNewUser', - security: nonce, - p_id: form_id, - inc: uid, - email, - }; - - if ( ! email ) { - alert( 'Please enter email address.' ); - return false; - } - - const email_pattern = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; - - if ( ! email_pattern.test( email ) ) { - alert( 'Please enter valid email address' ); - current_obj.parent().find( '.usrEmail#' + form_id ).focus(); - - return false; - } - - jQuery.post( ajaxurl, data, function( data ) { - const outputData = JSON.parse( data ); - - if ( outputData.status == 'success' ) { - total += 1; - current_obj.data( 'total', total ); - current_obj.parents().find( '.no_user#' + form_id ).hide(); - $( 'table#waitlists' + form_id ).append( '' + outputData.email + '' + outputData.emailLink + '' + outputData.removeLink + '' ); - $( 'table#waitlists' + form_id + ' tr:last' ).animate( { backgroundColor: 'rgb(247, 255, 176)' }, 'slow' ).animate( { backgroundColor: '#fff' }, 'slow' ); - current_obj.parent().find( '.usrEmail#' + form_id ).focus(); - } else if ( outputData.status == 'exists' ) { - alert( email + ' is already exist! ' ); - } - } ); - } ); -} ); diff --git a/src/js/wsn-metabox.js b/src/js/wsn-metabox.js deleted file mode 100644 index 4b57948..0000000 --- a/src/js/wsn-metabox.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* Wocommerce In-Stock Notifier JavaScript -* @author Govind Kumar -* @version 1.0.0 -*/ - -jQuery( document ).ready( function ( $ ) { - "use strict"; - - $( '.waitlist_data' ).on( 'click', 'a.wsn_waitlist_send_mail_btn', function ( e ) { - e.preventDefault( ); - - var current_obj = $( this ), - product_id = current_obj.data( 'product_id' ), - user_email = current_obj.data( 'user_email' ), - actionType = current_obj.data( 'type'), - wrapper = ( actionType == 'all' ) ? current_obj.parent( 'span' ) : current_obj.parents( 'td' ); - - if ( actionType == 'all' ) { - $( document ).find( '#waitlists' + product_id + '' ).find( 'tr.old' ).addClass( 'unclickable' ); - } - - wrapper.block( { - message: null, - overlayCSS: { - background: '#fff no-repeat center', - opacity: 0.5, - cursor: 'none' - } - } ); - - $.ajax( { - url: _wsn_waitlist.ajax_url, - dataType: 'json', - data: { - action: 'wsn_waitlist_send_mail', - product: product_id, - email: user_email, - type: actionType - }, - success: function ( res ) { - - if ( res.send ) { - wrapper.html( res.msg ); - } - else { - wrapper.html( res.msg ); - } - wrapper.unblock( ); - - } - } ); - } ); -} ); \ No newline at end of file diff --git a/src/js/wsn-script.js b/src/js/wsn-script.js deleted file mode 100644 index e52c01e..0000000 --- a/src/js/wsn-script.js +++ /dev/null @@ -1,9 +0,0 @@ -/** -* Wocommerce In-Stock Notifier JavaScript -* @author Govind Kumar -* @version 1.0.0 -*/ - -jQuery( document ).ready( function( $ ) { - 'use strict'; -} ); diff --git a/webpack.config.js b/webpack.config.js index c105440..6cdf028 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -38,14 +38,6 @@ module.exports = { sourceMapContents: false, }, }, - { - loader: 'sass-resources-loader', - options: { - resources: [ - './src/helpers/colors.scss', - ], - }, - }, ], }, {