/** * Process the actions from the 'Actions' tab * * @since 1.0 */ public function process_actions_tab() { global $wc_pre_orders; // security check if (!wp_verify_nonce($_POST['_wpnonce'], 'wc-pre-orders-process-actions')) { wp_die(__('Action failed. Please refresh the page and retry.', WC_Pre_Orders::TEXT_DOMAIN)); } // user check if (!current_user_can('manage_woocommerce')) { wp_die(__('You do not have the correct permissions to do this.', WC_Pre_Orders::TEXT_DOMAIN)); } // get parameters $action = in_array($_POST['wc_pre_orders_action'], array('email', 'change-date', 'complete', 'cancel'), true) ? $_POST['wc_pre_orders_action'] : ''; $product_id = !empty($_POST['wc_pre_orders_action_product']) ? absint($_POST['wc_pre_orders_action_product']) : ''; $send_email = isset($_POST['wc_pre_orders_action_enable_email_notification']) && '1' === $_POST['wc_pre_orders_action_enable_email_notification'] ? true : false; $email_message = !empty($_POST['wc_pre_orders_action_email_message']) ? wp_filter_kses($_POST['wc_pre_orders_action_email_message']) : ''; $new_availability_date = !empty($_POST['wc_pre_orders_action_new_availability_date']) ? $_POST['wc_pre_orders_action_new_availability_date'] : ''; if (!$action || !$product_id) { return; } switch ($action) { // email all pre-ordered customers case 'email': WC_Pre_Orders_Manager::email_all_pre_order_customers($product_id, $email_message); break; // change the release date for all pre-orders // change the release date for all pre-orders case 'change-date': // remove email notification if disabled if (!$send_email) { remove_action('wc_pre_orders_pre_order_date_changed', array($wc_pre_orders, 'send_transactional_email'), 10); } WC_Pre_Orders_Manager::change_release_date_for_all_pre_orders($product_id, $new_availability_date, $email_message); break; // complete all pre-orders // complete all pre-orders case 'complete': // remove email notification if disabled if (!$send_email) { remove_action('wc_pre_order_status_completed', array($wc_pre_orders, 'send_transactional_email'), 10); } WC_Pre_Orders_Manager::complete_all_pre_orders($product_id, $email_message); break; // cancel all pre-orders // cancel all pre-orders case 'cancel': // remove email notification if disabled if (!$send_email) { remove_action('wc_pre_order_status_active_to_cancelled', array($wc_pre_orders, 'send_transactional_email'), 10); } WC_Pre_Orders_Manager::cancel_all_pre_orders($product_id, $email_message); break; default: break; } }