Automattic\WooCommerce\Internal\Orders
OrderActionsRestController::send_order_details()
Handle the POST /orders/{id}/actions/send_order_details.
Метод класса: OrderActionsRestController{}
Возвращает
Массив|WP_Error
. Request response or an error.
Использование
$OrderActionsRestController = new OrderActionsRestController(); $OrderActionsRestController->send_order_details( $request );
- $request(WP_REST_Request) (обязательный)
- The received request.
Код OrderActionsRestController::send_order_details() OrderActionsRestController::send order details WC 9.5.1
public function send_order_details( WP_REST_Request $request ) { $order_id = $request->get_param( 'id' ); $order = wc_get_order( $order_id ); if ( ! $order ) { return new WP_Error( 'woocommerce_rest_invalid_order', __( 'Invalid order ID.', 'woocommerce' ), array( 'status' => 404 ) ); } $email = $request->get_param( 'email' ); if ( $email ) { $order->set_billing_email( $email ); } if ( ! is_email( $order->get_billing_email() ) ) { return new WP_Error( 'woocommerce_rest_missing_email', __( 'Order does not have an email address.', 'woocommerce' ), array( 'status' => 400 ) ); } // phpcs:disable WooCommerce.Commenting.CommentHooks.MissingSinceComment /** This action is documented in includes/admin/meta-boxes/class-wc-meta-box-order-actions.php */ do_action( 'woocommerce_before_resend_order_emails', $order, 'customer_invoice' ); WC()->payment_gateways(); WC()->shipping(); WC()->mailer()->customer_invoice( $order ); $user_agent = esc_html( $request->get_header( 'User-Agent' ) ); $note = sprintf( // translators: %1$s is the customer email, %2$s is the user agent that requested the action. esc_html__( 'Order details sent to %1$s, via %2$s.', 'woocommerce' ), esc_html( $order->get_billing_email() ), $user_agent ? $user_agent : 'REST API' ); $order->add_order_note( $note, false, true ); // phpcs:disable WooCommerce.Commenting.CommentHooks.MissingSinceComment /** This action is documented in includes/admin/meta-boxes/class-wc-meta-box-order-actions.php */ do_action( 'woocommerce_after_resend_order_email', $order, 'customer_invoice' ); return array( 'message' => __( 'Order details email sent to customer.', 'woocommerce' ), ); }