ID ); } $theorder = $theorder instanceof WC_Order ? $theorder : null; $order_actions = self::get_available_order_actions_for_order( $theorder ); ?> payment_gateways(); WC()->shipping(); WC()->mailer()->customer_invoice( $order ); // Note the event. $order->add_order_note( __( 'Order details manually sent to customer.', 'woocommerce' ), false, true ); do_action( 'woocommerce_after_resend_order_email', $order, 'customer_invoice' ); // Change the post saved message. add_filter( 'redirect_post_location', array( __CLASS__, 'set_email_sent_message' ) ); } elseif ( 'send_order_details_admin' === $action ) { do_action( 'woocommerce_before_resend_order_emails', $order, 'new_order' ); WC()->payment_gateways(); WC()->shipping(); add_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' ); WC()->mailer()->emails['WC_Email_New_Order']->trigger( $order->get_id(), $order, true ); remove_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' ); do_action( 'woocommerce_after_resend_order_email', $order, 'new_order' ); // Change the post saved message. add_filter( 'redirect_post_location', array( __CLASS__, 'set_email_sent_message' ) ); } elseif ( 'regenerate_download_permissions' === $action ) { $data_store = WC_Data_Store::load( 'customer-download' ); $data_store->delete_by_order_id( $post_id ); wc_downloadable_product_permissions( $post_id, true ); } else { if ( ! did_action( 'woocommerce_order_action_' . sanitize_title( $action ) ) ) { do_action( 'woocommerce_order_action_' . sanitize_title( $action ), $order ); } } } } /** * Set the correct message ID. * * @param string $location Location. * @since 2.3.0 * @static * @return string */ public static function set_email_sent_message( $location ) { return add_query_arg( 'message', 11, $location ); } /** * Get the available order actions for a given order. * * @since 5.8.0 * * @param WC_Order|null $order The order object or null if no order is available. * * @return array */ private static function get_available_order_actions_for_order( $order ) { $actions = array( 'send_order_details' => __( 'Email invoice / order details to customer', 'woocommerce' ), 'send_order_details_admin' => __( 'Resend new order notification', 'woocommerce' ), 'regenerate_download_permissions' => __( 'Regenerate download permissions', 'woocommerce' ), ); /** * Filter: woocommerce_order_actions * Allows filtering of the available order actions for an order. * * @since 2.1.0 Filter was added. * @since 5.8.0 The $order param was added. * * @param array $actions The available order actions for the order. * @param WC_Order|null $order The order object or null if no order is available. */ return apply_filters( 'woocommerce_order_actions', $actions, $order ); } }