Skip to content
Docs
Get RestroPress

Filter

rpress_receipt_attachments

Updated
On this page

Filters the list of file attachments sent with the customer order email.

Runs when the customer receipt is prepared. The default is an empty array. Return absolute file paths to attach to the email, for example a generated invoice. The test receipt passes an order ID of 0 and an empty data array.

Parameters#

ParameterTypeDescription
$attachmentsarrayList of file paths to attach. Empty by default.
$payment_idintID of the order, or 0 for the test receipt.
$payment_dataarrayOrder meta from _rpress_payment_meta, or an empty array for the test receipt.

Return value#

array. The list of attachment file paths.

Example#

function my_receipt_attachments( $attachments, $payment_id, $payment_data ) {
	$file = WP_CONTENT_DIR . '/uploads/invoices/order-' . absint( $payment_id ) . '.pdf';
	if ( $payment_id && file_exists( $file ) ) {
		$attachments[] = $file;
	}
	return $attachments;
}
add_filter( 'rpress_receipt_attachments', 'my_receipt_attachments', 10, 3 );

Source#

Applied in:

  • includes/emails/functions.php (line 53), in rpress_email_purchase_receipt()
  • includes/emails/functions.php (line 82), in rpress_email_test_purchase_receipt()

See also#

Was this page helpful?