EDD_PRODUCTPURCHASE::edd_product_purchase( $payment_id )

Validation function when the trigger action is hit


Parameters Parameters

$payment_id

(Required)


Source Source

File: src/integrations/edd/triggers/edd-productpurchase.php

	public function edd_product_purchase( $payment_id ) {



		$cart_items = edd_get_payment_meta_cart_details( $payment_id );
		if ( empty( $cart_items ) ) {
			return;
		}

		foreach ( $cart_items as $item ) {
			$post_id = $item['id'];
			$user_id = get_current_user_id();
			$args    = [
				'code'    => $this->trigger_code,
				'meta'    => $this->trigger_meta,
				'post_id' => $post_id,
				'user_id' => $user_id,
			];
			Automator()->maybe_add_trigger_entry( $args );
		}
	}