/** * 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); } } } }
/** * Initialise the plugin and load the required objects for the use context * * @static * @access public * @return void * @since 1.0.0 */ public static function init() { self::$path = plugin_dir_path(__FILE__); if (is_admin()) { self::$Pie_WCWL_Admin_UI = new Pie_WCWL_Admin_UI(); } else { self::$Pie_WCWL_Frontend_UI = new Pie_WCWL_Frontend_UI(); } register_activation_hook('woocommerce-waitlist/woocommerce-waitlist.php', array(__CLASS__, 'create_empty_waitlists_on_published_products_with_no_existing_waitlist')); add_action('import_end', array(__CLASS__, 'create_empty_waitlists_on_published_products_with_no_existing_waitlist')); add_action('plugins_loaded', array(__CLASS__, 'localization')); add_action('admin_init', array(__CLASS__, 'version_check')); add_action('plugins_loaded', array(__CLASS__, 'email_loader')); add_action('shutdown', array(__CLASS__, 'update_variable_product_waitlist_counts'), 20); add_action('woocommerce_reduce_order_stock', array(__CLASS__, 'check_order_for_waitlisted_items')); add_action('delete_user', array(__CLASS__, 'unregister_user_when_deleted')); if (!WooCommerce_Waitlist_Plugin::automatic_mailouts_are_disabled()) { // Hook up mailouts when any stock changes take place add_action('woocommerce_product_set_stock_status', array(__CLASS__, 'perform_api_mailout_stock_status'), 10, 2); add_action('woocommerce_product_set_stock', array(__CLASS__, 'perform_api_mailout_stock'), 10, 1); add_action('woocommerce_variation_set_stock_status', array(__CLASS__, 'perform_api_mailout_stock_status'), 10, 2); add_action('woocommerce_variation_set_stock', array(__CLASS__, 'perform_api_mailout_stock'), 10, 1); } }