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').
Return Return
(void)
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(); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.19.0 | Unknown. |
1.0.0 | Introduced. |