meta( $order, '_flw_payment_txn_ref' ); $txn = (string) $order->get_transaction_id(); if ( (string) $order->get_id() === $txn ) { $data['transaction_reference'] = ''; } $data = $this->set( $data, 'transaction_reference', $tx_ref ); // The plugin writes this note on success: "... (Payment Reference: FLW-..., Transaction Reference: ...)". $flw_ref = ''; if ( function_exists( 'wc_get_order_notes' ) ) { foreach ( wc_get_order_notes( array( 'order_id' => $order->get_id() ) ) as $note ) { if ( preg_match( '/Payment Reference:\s*([A-Za-z0-9_\-]+)/', wp_strip_all_tags( $note->content ), $m ) ) { $flw_ref = $m[1]; break; } } } $data = $this->set( $data, 'gateway_reference', $flw_ref ); $settings = get_option( 'woocommerce_' . $order->get_payment_method() . '_settings', array() ); if ( is_array( $settings ) && isset( $settings['go_live'] ) ) { $data = $this->extra( $data, __( 'Gateway mode now (not stored per order)', 'acrislip-order-receipts' ), 'yes' === $settings['go_live'] ? 'live' : 'test' ); } return $data; } }