LLMS_Transaction::record_refund( array $refund, string $note = '' )

Records a refund against the transaction.


Description Description

This method performs no validations and assumes that the refund has already been verified against the refund method and current transaction restrictions.

If the refund data isn’t validated, try using LLMS_Transaction::process_refund() instead.


Top ↑

Parameters Parameters

$refund

(array) (Required) Refund arguments.

  • 'amount'
    (float) The refund amount.
  • 'id'
    (string) The generated refund ID.
  • 'method'
    (string) The refund processing method ID.
  • 'date'
    (string) The refund date in MySQL date format. If not supplied, the current time is used.

$note

(string) (Optional) User-submitted refund note to add to the order alongside the refund.

Default value: ''


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/models/model.llms.transaction.php

	public function record_refund( $refund, $note = '' ) {

		$refund = wp_parse_args(
			$refund,
			array(
				'amount' => 0.00,
				'id'     => '',
				'method' => '',
				'date'   => llms_current_time( 'mysql' ),
			)
		);

		// Record the note.
		$this->record_refund_note( $note, $refund['amount'], $refund['id'], $refund['method'] );

		// Update the refunded amount.
		$refund_amount = $this->get( 'refund_amount' );
		$new_amount    = ! $refund_amount ? $refund['amount'] : $refund_amount + $refund['amount'];
		$this->set( 'refund_amount', $new_amount );

		// Record refund metadata.
		$refund_data = $this->get_refunds();

		/**
		 * Filters the stored refund data before saving it.
		 *
		 * @since Unknown
		 *
		 * @param array            $refund {
		 *     An associative array of refund data.
		 *
		 *     @type float  $amount The refund amount.
		 *     @type string $date   The refund date in MySQL date format: `Y-m-d H:i:s`.
		 *     @type string $id     The refund ID.
		 *     @type string $method The refund method ID.
		 * }
		 * @param LLMS_Transaction $transaction The transaction object.
		 * @param float            $amount      The refund amount.
		 * @param string           $method      The refund method ID
		 */
		$refund_data[ $refund['id'] ] = apply_filters( 'llms_transaction_refund_data', $refund, $this, $refund['amount'], $refund['method'] );
		$this->set( 'refund_data', $refund_data );

		// Update status.
		$this->set( 'status', 'llms-txn-refunded' );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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