Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Meta_Box_Order_Transactions::save_transaction( int $post_id )

Save method, records manual transactions


Parameters Parameters

$post_id

(int) (Required) Post ID of the Order.


Top ↑

Return Return

(null)


Top ↑

Source Source

File: includes/admin/post-types/meta-boxes/class.llms.meta.box.order.transactions.php

	private function save_transaction( $post_id ) {

		// phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce is verified in the save() method of this class.

		if ( empty( $_POST['llms_txn_amount'] ) ) {
			return $this->add_error( __( 'Refund Error: Missing or invalid payment amount', 'lifterlms' ) );
		}

		$order = new LLMS_Order( $post_id );

		$txn = $order->record_transaction(
			array(
				'amount'             => llms_filter_input_sanitize_string( INPUT_POST, 'llms_txn_amount' ),
				'source_description' => llms_filter_input_sanitize_string( INPUT_POST, 'llms_txn_source' ),
				'transaction_id'     => llms_filter_input_sanitize_string( INPUT_POST, 'llms_txn_id' ),
				'status'             => 'llms-txn-succeeded',
				'payment_gateway'    => 'manual',
				'payment_type'       => 'single',
			)
		);

		if ( ! empty( $_POST['llms_txn_note'] ) ) {
			$order->add_note( llms_filter_input_sanitize_string( INPUT_POST, 'llms_txn_note' ), true );
		}

		if ( is_wp_error( $txn ) ) {
			$this->add_error( sprintf( _x( 'Refund Error: %s', 'admin error message', 'lifterlms' ), $refund->get_error_message() ) );
		}

		// phpcs:enable WordPress.Security.NonceVerification.Missing

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.9.0 Stop using deprecated FILTER_SANITIZE_STRING.
3.35.0 Verify nonces and sanitize $_POST data.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.