rendered_metas['billing_interval'] ?? 1; $billing_interval_type = $subscription_plan->rendered_metas['billing_interval_type'] ?? 'month'; $billing_cycle = $subscription_plan->rendered_metas['billing_cycle'] ?? 0; $post_billing_cycle = $subscription_plan->rendered_metas['post_billing_cycle'] ?? 'closed'; $enable_trial = $subscription_plan->rendered_metas['enable_trial'] ?? false; $trial_days = $subscription_plan->rendered_metas['trial_days'] ?? 0; $enrollment_fee = $subscription_plan->rendered_metas['enrollment_fee'] ?? 0; $featured = $subscription_plan->rendered_metas['featured'] ?? false; $enable_sale_price = $subscription_plan->rendered_metas['enable_sale_price'] ?? false; $schedule_sale_price = $subscription_plan->rendered_metas['schedule_sale_price'] ?? false; $sale_start_date = $subscription_plan->rendered_metas['sale_start_date'] ?? ''; $sale_end_date = $subscription_plan->rendered_metas['sale_end_date'] ?? ''; $price = $subscription_plan->rendered_metas['price'] ?? 0; $sale_price = $subscription_plan->rendered_metas['sale_price'] ?? 0; $interval_label = $billing_interval > 1 ? "{$billing_interval_type}s" : $billing_interval_type; $is_sale_active = false; if ($enable_sale_price) { $is_sale_active = true; if ($schedule_sale_price && !empty($sale_start_date) && !empty($sale_end_date)) { $now = current_time('timestamp'); // WordPress-safe current time $start_ts = strtotime($sale_start_date); $end_ts = strtotime($sale_end_date); // Only active if within range if ($now < $start_ts || $now > $end_ts) { $is_sale_active = false; } } } $info_line = sprintf( /* translators: %1$d: Number of billing intervals %2$s: interval label */ __('Billed every %1$d %2$s', 'acadlix-addon-for-elementor'), $billing_interval, $interval_label ); $info_line2 = ''; if ($billing_cycle > 0) { $info_line .= sprintf( /* translators: %1$d: Number of billing cycles %2$s: add s if more than one */ __(' for %1$d billing%2$s', 'acadlix-addon-for-elementor'), $billing_cycle, $billing_cycle > 1 ? 's' : '' ); if ($post_billing_cycle === 'closed') { $info_line2 = __('Access ends with billing cycle.', 'acadlix-addon-for-elementor'); } elseif ($post_billing_cycle === 'lifetime') { $info_line2 = __('Lifetime access after billing ends.', 'acadlix-addon-for-elementor'); } } else { $info_line .= __(' until cancelled', 'acadlix-addon-for-elementor'); } $subscription_detail = ''; $icon = ''; if (isset($settings['course_subscription_plan_detail_icon']['library']) && 'svg' === $settings['course_subscription_plan_detail_icon']['library']) { $icon = \Elementor\Icons_Manager::render_icon($settings['course_subscription_plan_detail_icon'], array('aria-hidden' => 'true')); } else { $icon = ""; } $subscription_detail .= "
{$icon}
{$info_line}
"; if (!empty($info_line2)) { $subscription_detail .= "
{$icon}
{$info_line2}
"; } if ($enable_trial && $trial_days > 0) { $subscription_detail .= "
{$icon}
" . sprintf( /* translators: %1$d: Number of trial days, %2$s: plural 's' if more than one day */ __('Free %1$d day%2$s trial.', 'acadlix-addon-for-elementor'), $trial_days, $trial_days > 1 ? 's' : '' ) . '
'; } if ($enrollment_fee > 0) { $subscription_detail .= "
{$icon}
" . sprintf( /* translators: %d: Enrollment fee */ __('+ %s enrollment fee at checkout', 'acadlix-addon-for-elementor'), acadlix()->helper()->course()->getCoursePrice($enrollment_fee) ) . '
'; } $checked = $cart && $cart->subscription_plan_id !== null ? ($cart->subscription_plan_id === $subscription_plan->ID ? 'checked' : '') : ($featured ? 'checked' : ''); $plan = ''; $plan .= '
'; $plan .= '
'; $plan .= "post_title . '
'; if ($featured && $show_featured_icon) { $plan .= ''; } $plan .= '
'; $plan .= ''; $plan .= ''; $plan .= '
'; $plan .= '
'; $plan .= '
' . esc_html(acadlix()->helper()->course()->getCoursePrice($is_sale_active ? $sale_price : $price)) . '
'; if ($is_sale_active) { $plan .= '
' . esc_html(acadlix()->helper()->course()->getCoursePrice($price)) . '
'; } $plan .= '
'; if ($show_interval) { $plan .= '
/ ' . ($billing_interval > 1 ? $billing_interval : '') . ' ' . $interval_label . '
'; } $plan .= '
'; if ($show_subscription_plan_detail) { $plan .= '
'; $plan .= $subscription_detail; $plan .= '
'; } $plan .= ''; return $plan; } } if (!function_exists('aelms_get_course_subscription_plans')) { function aelms_get_course_subscription_plans($item, $settings = [], $cart = [], $show = true) { ?> subscription_plans; $plans = '
'; foreach ($subscription_plans as $subscription_plan) { $plans .= aelms_get_course_subscription_plan($subscription_plan, $settings, $cart); } $plans .= '
'; return $plans; } } if (!function_exists('aelms_course_one_time_and_subscription_price')) { function aelms_course_one_time_and_subscription_price($item, $settings = [], $cart = []) { $enable_sale_price = $item->rendered_metas['enable_sale_price'] ?? false; $price = $item->rendered_metas['price'] ?? 0; $sale_price = $item->rendered_metas['sale_price'] ?? 0; $cart_has_subscription_plan = $cart && $cart->subscription_plan_id !== null; $html = ''; $html .= '
'; $html .= '
'; $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; $html .= '
' . esc_html(acadlix()->helper()->course()->getCoursePrice($enable_sale_price ? $sale_price : $price)) . '
'; if ($enable_sale_price) { $html .= '
' . esc_html(acadlix()->helper()->course()->getCoursePrice($price)) . '
'; } $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; $html .= aelms_get_course_subscription_plans($item, $settings, $cart, false); $html .= '
'; $html .= '
'; return $html; } } $post_type = $post->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_course_to_fetch = $settings['course_price_course']; $aelms_cart = []; $aelms_course_id = $post->ID; if (!empty($aelms_course_to_fetch) && \Elementor\Plugin::$instance->editor->is_edit_mode()) { $aelms_course_id = $aelms_course_to_fetch; } if (is_user_logged_in()) { $aelms_userId = get_current_user_id(); $aelms_cart = acadlix()->model()->courseCart()->where([ ['user_id', '=', $aelms_userId], ['item_id', '=', $aelms_course_id], ['type', '=', $type], ])->first(); } elseif (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', $aelms_course_id) ->where('type', $type) ->first(); } $aelms_isSubscriptionActive = acadlix()->helper()->is_subscriptions_addon_active(); if ($aelms_item) { $aelms_show_discount_percent = $settings['course_price_discounted'] === 'yes' ? true : false; $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_payment_type = $aelms_item->rendered_metas['payment_type'] ?? 'one_time'; if ($aelms_isSubscriptionActive && $aelms_payment_type === 'both') { echo wp_kses(aelms_course_one_time_and_subscription_price($aelms_item, $settings, $aelms_cart), aelms_allowed_html()); } elseif ($aelms_isSubscriptionActive && $aelms_payment_type === 'subscription') { echo wp_kses(aelms_get_course_subscription_plans($aelms_item, $settings, $aelms_cart), aelms_allowed_html()); } else { ?>
helper()->course()->getCoursePrice($aelms_enable_sale_price ? $aelms_sale_price : $aelms_price)); ?>
helper()->course()->getCoursePrice($aelms_price)); ?>
$aelms_sale_price) { ?>
%