LLMS_Controller_Orders::complete_order( LLMS_Order $order, string $old_status )

Perform actions on a successful order completion.


Parameters Parameters

$order

(LLMS_Order) (Required) Instance of an LLMS_Order.

$old_status

(string) (Required) Previous order status (eg: 'pending').


Top ↑

Return Return

(void)


Top ↑

Source Source

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

	public function complete_order( $order, $old_status ) {

		// Clear expiration date when moving from a pending-cancel order.
		if ( 'pending-cancel' === $old_status ) {
			$order->set( 'date_access_expires', '' );
		}

		// Record access start time & maybe schedule expiration.
		$order->start_access();

		$order_id   = $order->get( 'id' );
		$product_id = $order->get( 'product_id' );
		$user_id    = $order->get( 'user_id' );

		unset( llms()->session->llms_coupon );

		/**
		 * Action fired on order complete.
		 *
		 * Prior to the students being enrolled.
		 *
		 * @since 1.0.0
		 *
		 * @param integer $order_id The WP_Post ID of the order.
		 */
		do_action( 'lifterlms_order_complete', $order_id ); // @todo used by AffiliateWP only, can remove after updating AffiliateWP.

		// Enroll student.
		llms_enroll_student( $user_id, $product_id, 'order_' . $order_id );

		// Trigger purchase action, used by engagements.

		/**
		 * Action fired on product purchased.
		 *
		 * After the student has been enrolled.
		 *
		 * @since Unknown
		 *
		 * @param integer $user_id    The WP_User ID of the buyer.
		 * @param integer $product_id The WP_Post ID of the purchased product (course/membership).
		 */
		do_action( 'lifterlms_product_purchased', $user_id, $product_id );

		/**
		 * Action fired on access plan purchased.
		 *
		 * After the student has been enrolled.
		 *
		 * @since Unknown
		 *
		 * @param integer $user_id    The WP_User ID of the buyer.
		 * @param integer $product_id The WP_Post ID of the purchased access plan.
		 */
		do_action( 'lifterlms_access_plan_purchased', $user_id, $order->get( 'plan_id' ) );

		// Maybe schedule a payment.
		$order->maybe_schedule_payment();

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.19.0 Unknown.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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