post_type; $aelms_allowed_post_type = [ acadlix()->cpt()->course()->get_post_type(), ]; if (acadlix()->helper()->is_course_bundle_addon_active()) { $aelms_allowed_post_type[] = acadlix()->cpt()->course_bundle()->get_post_type(); } $type = 'course'; if (in_array($post_type, $aelms_allowed_post_type)) { if ($post_type == acadlix()->cpt()->course()->get_post_type()) { $aelms_item = acadlix()->model()->course()->ofCourse()->find($post->ID); $type = 'course'; } else if ($post_type == acadlix()->cpt()->course_bundle()->get_post_type()) { $aelms_item = acadlix()->model()->courseBundle()->ofCourseBundle()->find($post->ID); $type = 'course-bundle'; } $aelms_courses_url = get_permalink(acadlix()->helper()->acadlix_get_option('acadlix_all_courses_page_id')); $aelms_checkout_url = get_permalink(acadlix()->helper()->acadlix_get_option('acadlix_checkout_page_id')); $aelms_dashboard_url = get_permalink(acadlix()->helper()->acadlix_get_option('acadlix_dashboard_page_id')); $aelms_payment_type = $aelms_item->rendered_metas['payment_type'] ?? 'one_time'; $aelms_cart = []; $aelms_is_course_purchased = false; if (is_user_logged_in()) { $aelms_userId = get_current_user_id(); $aelms_is_course_purchased = $aelms_item->isPurchasedBy($aelms_userId); $aelms_cart = acadlix()->model()->courseCart()->where([ ['user_id', '=', $aelms_userId], ['item_id', '=', $post->ID], ['type', '=', $type], ])->first(); } else { if (isset($_COOKIE['acadlix_cart_token'])) { $aelms_cart = acadlix() ->model() ->courseCart() ->where('cart_token', sanitize_text_field(wp_unslash($_COOKIE['acadlix_cart_token']))) ->where('item_id', $post->ID) ->where('type', $type) ->first(); } } if ($aelms_item) { $aelms_enable_sale_price = $aelms_item->rendered_metas['enable_sale_price'] ?? false; $aelms_price = $aelms_item->rendered_metas['price'] ?? 0; $aelms_sale_price = $aelms_item->rendered_metas['sale_price'] ?? 0; $aelms_start_date = $aelms_item->rendered_metas['start_date'] ?? null; $aelms_end_date = $aelms_item->rendered_metas['end_date'] ?? null; if ($aelms_item->post_status != 'publish') { return ''; } ?>
rendered_metas['button_url'] ?? '#'; ?> helper()->course()->checkRegistrationDate($aelms_start_date, $aelms_end_date); if ($aelms_check_registration_date['status']) { if ($aelms_item->isFree()) { if ($aelms_is_course_purchased) { aelms_goToCourseButton($aelms_dashboard_url, $aelms_course_title); } elseif ($aelms_cart) { if (in_array($aelms_payment_type, ['subscription', 'both'])) { aelms_buyNowButton($aelms_item, $aelms_payment_type, $aelms_buy_now, $aelms_subscribe_now, $aelms_breakpoint, $type); } else { aelms_goToCheckoutButton($aelms_checkout_url, $aelms_checkout_title); } } else { if (in_array($aelms_payment_type, ['subscription', 'both'])) { aelms_buyNowButton($aelms_item, $aelms_payment_type, $aelms_buy_now, $aelms_subscribe_now, $aelms_breakpoint, $type); } else { aelms_startNowButton($aelms_item, $aelms_start_title, $type); } } } else { if ($aelms_is_course_purchased) { aelms_goToCourseButton($aelms_dashboard_url, $aelms_course_title); } elseif ($aelms_cart) { if (in_array($aelms_payment_type, ['subscription', 'both'])) { aelms_buyNowButton($aelms_item, $aelms_payment_type, $aelms_buy_now, $aelms_subscribe_now, $aelms_breakpoint, $type); } else { aelms_goToCheckoutButton($aelms_checkout_url, $aelms_checkout_title); } } else { aelms_buyNowButton($aelms_item, $aelms_payment_type, $aelms_buy_now, $aelms_subscribe_now, $aelms_breakpoint, $type); } } } else { ?>
[]]); ?>