/** * Handles request to join the waitlist if user is not logged in * * Checks which waitlists need to be updated and processes the request, returning appropriate notifications upon completion * * @param $product * * @return admin notices for success/failure * @internal param val $mixed $product if multiple products need updating this will be an array, else the product object requiring updating * @access public * @since 1.3 */ public function handle_waitlist_when_new_user($product) { if (is_array($product)) { $changed_products = $product; $product = $this->Product; } if (!isset($_REQUEST['wcwl_email']) || !is_email($_REQUEST['wcwl_email'])) { return WooCommerce_Waitlist_Plugin::add_notice(apply_filters('wcwl_join_waitlist_invalid_email_message_text', $this->join_waitlist_invalid_email_message_text), 'error'); } elseif ($product->is_type('grouped') && empty($_REQUEST['wcwl_changed'])) { return WooCommerce_Waitlist_Plugin::add_notice(apply_filters('wcwl_toggle_waitlist_no_product_message_text', $this->toggle_waitlist_no_product_message_text), 'error'); } else { if (email_exists($_REQUEST['wcwl_email'])) { $current_user = get_user_by('email', $_REQUEST['wcwl_email']); } else { $current_user = get_user_by('id', $product->Waitlist->create_new_customer_from_email($_REQUEST['wcwl_email'])); } if ($product->is_type('grouped')) { $changed_products = isset($changed_products) ? $changed_products : array(); foreach ($changed_products as $changed_product) { $changed_product->Waitlist->register_user($current_user); } if (count($changed_products) > 1) { return WooCommerce_Waitlist_Plugin::add_notice(apply_filters('wcwl_grouped_multiple_products_joined_message_text', $this->grouped_multiple_products_joined_message_text)); } return WooCommerce_Waitlist_Plugin::add_notice(apply_filters('wcwl_grouped_single_product_joined_message_text', $this->grouped_single_product_joined_message_text)); } if (!$product->Waitlist->register_user($current_user)) { return WooCommerce_Waitlist_Plugin::add_notice(apply_filters('wcwl_leave_waitlist_message_text', $this->leave_waitlist_message_text)); } return WooCommerce_Waitlist_Plugin::add_notice(apply_filters('wcwl_join_waitlist_success_message_text', $this->join_waitlist_success_message_text)); } }
* * @author Neil Pie * @package WooCommerce_Waitlist/Templates/Emails/Plain * @version 1.2 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly do_action('woocommerce_email_header', $email_heading); ?> <p><?php echo _x("Hi There,", 'Email salutation', 'woocommerce-waitlist'); ?> </p> <p><?php echo sprintf(__('%1$s is now back in stock at %2$s.', 'woocommerce-waitlist'), $product_title, get_bloginfo('name')) . " "; echo __('You have been sent this email because your email address was registered on a waitlist for this product.', 'woocommerce-waitlist'); ?> </p> <p><?php echo sprintf(__('If you would like to purchase %1$s please visit the following link: <a href="%2$s">%3$s</a>', 'woocommerce-waitlist'), $product_title, $product_link, $product_link); ?> </p> <?php if (WooCommerce_Waitlist_Plugin::persistent_waitlists_are_disabled()) { echo '<p>', __('You have now been removed from the waitlist for this product.', 'woocommerce-waitlist'), '</p>'; } do_action('woocommerce_email_footer');
/** * Triggers instock notification email to each user on the waitlist for a product, then deletes the waitlist * * @param int $post_id * @access public * @return void */ public function waitlist_mailout($post_id) { if (!empty($this->waitlist)) { if ('yes' == get_option('woocommerce_waitlist_archive_on')) { $this->archive_waitlist_before_mailouts($post_id); } global $woocommerce; $woocommerce->mailer(); foreach ($this->waitlist as $user_id) { $user = get_user_by('id', $user_id); if (!WooCommerce_Waitlist_Plugin::automatic_mailouts_are_disabled()) { do_action('woocommerce_waitlist_mailout_send_email', $user_id, $post_id); } if (WooCommerce_Waitlist_Plugin::persistent_waitlists_are_disabled()) { $this->unregister_user($user); } } } }
/** * Get the user object, check which products they are on the waitlist for and unregister them from each one when deleted * * @static * @param int $user_id id of the user that is being deleted * @access public * @return void * @since 1.3 */ public static function unregister_user_when_deleted($user_id) { $posts = WooCommerce_Waitlist_Plugin::return_all_products(); $user = get_user_by('id', $user_id); $products = array(); if ($posts->have_posts()) { while ($posts->have_posts()) { $posts->the_post(); $post_id = get_the_ID(); $products[$post_id] = get_product($post_id); $products[$post_id]->waitlist = new Pie_WCWL_Waitlist($products[$post_id]); $products[$post_id]->waitlist->unregister_user($user); } } }