Automattic\WooCommerce\Internal\ReceiptRendering
ReceiptRenderingEngine::get_existing_receipt()
Get the file name of an existing receipt file for an order.
A receipt is considered to be available for the order if there's an order meta entry with key RECEIPT_FILE_NAME_META_KEY AND the transient file it points to exists AND it has not expired.
Method of the class: ReceiptRenderingEngine{}
No Hooks.
Return
String|null
. The receipt file name, or null if no receipt is currently available for the order.
Usage
$ReceiptRenderingEngine = new ReceiptRenderingEngine(); $ReceiptRenderingEngine->get_existing_receipt( $order ): ?string;
- $order(WC_Order) (required)
- The order object or order id to get the receipt for.
ReceiptRenderingEngine::get_existing_receipt() ReceiptRenderingEngine::get existing receipt code WC 9.4.2
public function get_existing_receipt( $order ): ?string { if ( ! $order instanceof WC_Order ) { $order = wc_get_order( $order ); if ( false === $order ) { return null; } } $existing_receipt_filename = $order->get_meta( self::RECEIPT_FILE_NAME_META_KEY, true ); if ( '' === $existing_receipt_filename ) { return null; } $file_path = $this->transient_files_engine->get_transient_file_path( $existing_receipt_filename ); if ( is_null( $file_path ) ) { return null; } return $this->transient_files_engine->file_has_expired( $file_path ) ? null : $existing_receipt_filename; }