LLMS_Controller_Orders::transition_status( string $new_status, string $old_status, ojb $post )

Trigger actions when the status of LifterLMS Orders and LifterLMS Transactions change status


Description Description


Parameters Parameters

$new_status

(string) (Required) new status

$old_status

(string) (Required) old status

$post

(ojb) (Required) WP_Post instance


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/controllers/class.llms.controller.orders.php

	public function transition_status( $new_status, $old_status, $post ) {

		// don't do anything if the status hasn't changed
		if ( $new_status === $old_status ) {
			return;
		}

		// we're only concerned with order post statuses here
		if ( 'llms_order' !== $post->post_type && 'llms_transaction' !== $post->post_type ) {
			return;
		}

		$post_type = str_replace( 'llms_', '', $post->post_type );
		$obj = 'order' === $post_type ? new LLMS_Order( $post ) : new LLMS_Transaction( $post );

		// record order status changes as notes
		if ( 'order' === $post_type ) {
			$obj->add_note( sprintf( __( 'Order status changed from %1$s to %2$s', 'lifterlms' ), llms_get_order_status_name( $old_status ), llms_get_order_status_name( $new_status ) ) );
		}

		// remove prefixes from all the things
		$new_status = str_replace( array( 'llms-', 'txn-' ), '', $new_status );
		$old_status = str_replace( array( 'llms-', 'txn-' ), '', $old_status );

		do_action( 'lifterlms_' . $post_type . '_status_' . $old_status . '_to_' . $new_status, $obj, $old_status, $new_status );
		do_action( 'lifterlms_' . $post_type . '_status_' . $new_status, $obj, $old_status, $new_status );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: