subscribe-with-trial.php
2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* View: Pricing Subscribe with Trial.
*
* @since 4.6.0
* @version 4.6.0
*
* @var Product $product Product model.
* @var WP_User $user User.
*
* @package LearnDash\Core
*/
/** NOTICE: This code is currently under development and may not be stable.
* Its functionality, behavior, and interfaces may change at any time without notice.
* Please refrain from using it in production or other critical systems.
* By using this code, you assume all risks and liabilities associated with its use.
* Thank you for your understanding and cooperation.
**/
use LearnDash\Core\Models\Product;
// TODO: Refactor.
// TODO: What about 2 root elements?
$pricing = $product->get_pricing( $user );
// This filter is documented in themes/ld30/templates/components/infobar/group.php.
$free_label = apply_filters( 'learndash_no_price_price_label', __( 'Free', 'learndash' ) );
?>
<span class="ld-pricing__main-price">
<?php if ( $pricing->trial_price > 0 ) : ?>
<span class="ld-pricing__amount">
<?php echo esc_html( $product->get_display_trial_price() ); ?>
</span>
<?php else : ?>
<span class="ld-pricing__note">
<?php echo esc_html( $free_label ); ?>
</span>
<?php endif; ?>
<span class="ld-pricing__duration">
<?php
echo sprintf(
// Translators: placeholders: %1$s Number of times the trial period repeats, %2$s Frequency of recurring payments: days, weeks, months, years.
esc_html__( ' for %1$s %2$s', 'learndash' ),
esc_html( (string) $pricing->trial_duration_value ),
esc_html( learndash_get_grammatical_number_label_for_interval( $pricing->trial_duration_value, $pricing->trial_duration_length, true ) )
);
?>
</span>
</span>
<span class="ld-pricing__secondary-price">
<?php
echo sprintf(
// Translators: placeholders: %1$s Subscription price, %2$s Interval of recurring payments (number), %3$s Frequency of recurring payments: day, week, month or year.
esc_html_x( 'Then %1$s / %2$s %3$s', 'Recurring duration message', 'learndash' ),
esc_html( $product->get_display_price() ),
esc_html( 1 === $pricing->duration_value ? '' : (string) $pricing->duration_value ),
esc_html( learndash_get_grammatical_number_label_for_interval( $pricing->duration_value, $pricing->duration_length, true ) )
);
if ( $pricing->recurring_times > 0 ) {
echo sprintf(
// translators: placeholders: %1$s Number of times the recurring payment repeats, %2$s Frequency of recurring payments: day, week, month, year.
esc_html__( ' for %1$s %2$s', 'learndash' ),
absint( $pricing->duration_value * $pricing->recurring_times ), // Get correct total time by multiplying interval by number of repeats.
esc_html( learndash_get_grammatical_number_label_for_interval( $pricing->recurring_times, $pricing->duration_length, true ) )
);
}
?>
</span>