Automattic\WooCommerce\Internal\Orders

OrderActionsRestController::get_args_for_order_actionsprivateWC 1.0

Get the accepted arguments for the POST request.

Method of the class: OrderActionsRestController{}

No Hooks.

Returns

Array[].

Usage

// private - for code of main (parent) class only
$result = $this->get_args_for_order_actions( $action_slug ): array;
$action_slug(string) (required)
The endpoint slug for the order action.

OrderActionsRestController::get_args_for_order_actions() code WC 9.8.5

private function get_args_for_order_actions( string $action_slug ): array {
	$args = array(
		'email'              => array(
			'description'       => __( 'Email address to send the order details to.', 'woocommerce' ),
			'type'              => 'string',
			'format'            => 'email',
			'context'           => array( 'edit' ),
			'required'          => false,
			'validate_callback' => 'rest_validate_request_arg',
		),
		'force_email_update' => array(
			'description'       => __( 'Whether to update the billing email of the order, even if it already has one.', 'woocommerce' ),
			'type'              => 'boolean',
			'context'           => array( 'edit' ),
			'required'          => false,
			'sanitize_callback' => 'rest_sanitize_boolean',
			'validate_callback' => 'rest_validate_request_arg',
		),
	);

	if ( 'send_email' === $action_slug ) {
		$args['template_id'] = array(
			'description'       => __( 'The ID of the template to use for sending the email.', 'woocommerce' ),
			'type'              => 'string',
			'enum'              => $this->get_template_id_enum(),
			'context'           => array( 'edit' ),
			'required'          => true,
			'validate_callback' => 'rest_validate_request_arg',
		);
	}

	return $args;
}