EDD::edd_complete_purchase( int $payment_id, EDD_Payment $payment, EDD_Customer $customer )

Runs **when** a purchase is marked as “complete”.


Description

And immediately enrol customer as student.


Parameters

$payment_id

(int) (Required) Payment ID.

$payment

(EDD_Payment) (Required) EDD_Payment object containing all payment data.

$customer

(EDD_Customer) (Required) EDD_Customer object containing all customer data.


Source

File: classes/EDD.php

	public function edd_complete_purchase( $payment_id, $payment, $customer ) {
		$enable_earning = (bool) dozent_get_option( 'enable_dozent_earning' );

		$cart_details = $payment->cart_details;

		if ( is_array( $cart_details ) ) {
			foreach ( $cart_details as $cart_index => $download ) {
				$course_ids = dozent_get_attached_course_ids_to_product( $download['id'] );

				if ( dozent_count( $course_ids ) ) {
					foreach ( $course_ids as $course_id ) {
						dozent_enrol_course( $course_id, $customer->user_id, $payment_id );
					}

					//Add Earning Data
					if ( $enable_earning ) {
						$this->add_earning_data( $course_ids, $download['id'], $payment_id );
					}
				}

			}
		}
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.