LLMS_Controller_Orders::error_order( int|WP_Post|LLMS_Order $order )

Called when an order’s status changes to refunded, cancelled, expired, or failed.


Description Description

Also called on product deletion detected while processing a recurring charge.


Top ↑

Parameters Parameters

$order

(int|WP_Post|LLMS_Order) (Required) Instance of an LLMS_Order, WP_Post or WP_Post ID of the order.


Top ↑

Return Return

(void)


Top ↑

Source Source

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

	public function error_order( $order ) {

		$order = is_a( $order, 'LLMS_Order' ) ? $order : llms_get_post( $order );
		if ( ! ( $order && is_a( $order, 'LLMS_Order' ) ) ) {
			return;
		}

		$order->unschedule_recurring_payment();

		/**
		 * Determine if student should be unenrolled on order error.
		 *
		 * @since 4.2.0
		 *
		 * @param bool       $unenroll_on_error_order True if the student should be unenrolled, false otherwise. Default true.
		 * @param LLMS_Order $order                   Order object.
		 */
		if ( ! apply_filters( 'llms_unenroll_on_error_order', true, $order ) ) {
			return;
		}

		switch ( current_filter() ) {

			case 'lifterlms_order_status_trash':
			case 'lifterlms_order_status_cancelled':
			case 'lifterlms_order_status_on-hold':
			case 'lifterlms_order_status_refunded':
			case 'llms_order_recurring_charge_aborted_product_deleted':
				$status = 'cancelled';
				break;

			case 'lifterlms_order_status_expired':
			case 'lifterlms_order_status_failed':
			default:
				$status = 'expired';
				break;

		}

		llms_unenroll_student( $order->get( 'user_id' ), $order->get( 'product_id' ), $status, 'order_' . $order->get( 'id' ) );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.4.0 Unenroll with 'cancelled' status on 'llms_order_recurring_charge_aborted_product_deleted'. The $order param can be also a WP_Post or its ID.
4.2.0 Added llms_unenroll_on_error_order filter hook.
3.10.0 Unknown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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