Skip to content

Commit

Permalink
Merge pull request #1526 from themeum/harun-v3
Browse files Browse the repository at this point in the history
Fix - doing enrolment on membership plan purchased
  • Loading branch information
shewa12 authored Jan 15, 2025
2 parents 1eb5c8f + c6987a8 commit 15a0955
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 8 additions & 4 deletions classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -9979,13 +9979,15 @@ public function get_local_time_from_unix( $time, $date_format = null ) {
* Execute bulk action for enrollment list ex: complete | cancel
*
* @since 2.0.3
* @since 3.2.0 $trigger_hook param added.
*
* @param string $status hold status for updating.
* @param array $enrollment_ids ids that need to update.
* @param bool $trigger_hook optional - trigger hook or not.
*
* @return bool
*/
public function update_enrollments( string $status, array $enrollment_ids ): bool {
public function update_enrollments( string $status, array $enrollment_ids, bool $trigger_hook = true ): bool {
global $wpdb;
$enrollment_ids_in = QueryHelper::prepare_in_clause( $enrollment_ids );
$status = 'complete' === $status ? 'completed' : $status;
Expand All @@ -10001,9 +10003,11 @@ public function update_enrollments( string $status, array $enrollment_ids ): boo
)
);

// Run action hook.
foreach ( $enrollment_ids as $id ) {
do_action( 'tutor_enrollment/after/' . $status, $id );
if ( $trigger_hook ) {
// Run action hook.
foreach ( $enrollment_ids as $id ) {
do_action( 'tutor_enrollment/after/' . $status, $id );
}
}

return true;
Expand Down
10 changes: 10 additions & 0 deletions ecommerce/HooksHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,16 @@ public function manage_earnings_and_enrollments( string $order_status, int $orde
$object_id = $item->id; // It could be course/bundle/plan id.
if ( $this->order_model::TYPE_SINGLE_ORDER !== $order->order_type ) {
$object_id = apply_filters( 'tutor_subscription_course_by_plan', $item->id, $order );

/**
* Do not process enrollment for membership plan.
*
* @since 3.2.0
*/
$plan_info = apply_filters( 'tutor_checkout_plan_info', new \stdClass(), $object_id );
if ( $plan_info && $plan_info->is_membership_plan ) {
continue;
}
}

$has_enrollment = tutor_utils()->is_enrolled( $object_id, $student_id, false );
Expand Down

0 comments on commit 15a0955

Please sign in to comment.