| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for countdown timer module on single product page.. |
| 4 |
* |
| 5 |
* @var $args array template args |
| 6 |
* |
| 7 |
* @since 1.4 |
| 8 |
*/ |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; // Exit if accessed directly |
| 12 |
} |
| 13 |
|
| 14 |
if ( empty( $args ) ) { |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
$theme = $args['theme'] ?? 'classic'; |
| 19 |
$align = $args['sale_ending_alignment'] ?? 'left'; |
| 20 |
|
| 21 |
$min_expiration_deadline_days = (int) ( $args['min_expiration_deadline_days'] ?? 0 ); |
| 22 |
$min_expiration_deadline_hours = (int) ( $args['min_expiration_deadline'] ?? 0 ); |
| 23 |
$min_expiration_deadline_minutes = (int) ( $args['min_expiration_deadline_minutes'] ?? 0 ); |
| 24 |
$max_expiration_deadline_days = (int) ( $args['max_expiration_deadline_days'] ?? 0 ); |
| 25 |
$max_expiration_deadline_hours = (int) ( $args['max_expiration_deadline'] ?? 0 ); |
| 26 |
$max_expiration_deadline_minutes = (int) ( $args['max_expiration_deadline_minutes'] ?? 0 ); |
| 27 |
|
| 28 |
// Min Total minutes |
| 29 |
$min_total_seconds = $min_expiration_deadline_days * 24 * 60 * 60; |
| 30 |
$min_total_seconds += $min_expiration_deadline_hours * 60 * 60; |
| 31 |
$min_total_seconds += $min_expiration_deadline_minutes * 60; |
| 32 |
|
| 33 |
// Max total seconds |
| 34 |
$max_total_seconds = $max_expiration_deadline_days * 24 * 60 * 60; |
| 35 |
$max_total_seconds += $max_expiration_deadline_hours * 60 * 60; |
| 36 |
$max_total_seconds += $max_expiration_deadline_minutes * 60; |
| 37 |
|
| 38 |
$cool_off_period = (int) ( $args['cool_off_period'] ?? 0 ) * 60; |
| 39 |
$countdown_type = $args['end_date'] ?? 'sale-dates'; |
| 40 |
|
| 41 |
$sale_start_date = $args['sale_start_date'] ?? ''; |
| 42 |
$sale_end_date = $args['sale_end_date'] ?? ''; |
| 43 |
|
| 44 |
$variations_sale_dates = $args['variations_sale_dates'] ?? array(); |
| 45 |
$sale_ending_text = $args['sale_ending_text'] ?? ''; |
| 46 |
|
| 47 |
$classes = 'merchant-countdown-timer'; |
| 48 |
$classes .= ' merchant-countdown-timer-' . $theme; |
| 49 |
$classes .= ' merchant-countdown-timer--' . $align; |
| 50 |
?> |
| 51 |
<div class="<?php echo esc_attr( $classes ); ?>" |
| 52 |
data-theme="<?php echo esc_attr( $theme ); ?>" |
| 53 |
data-max-expiration="<?php echo esc_attr( $max_total_seconds ); ?>" |
| 54 |
data-min-expiration="<?php echo esc_attr( $min_total_seconds ); ?>" |
| 55 |
data-off-period="<?php echo esc_attr( $cool_off_period ); ?>" |
| 56 |
data-countdown-type="<?php echo esc_attr( $countdown_type ); ?>" |
| 57 |
data-start-date="<?php echo esc_attr( $sale_start_date ); ?>" |
| 58 |
data-end-date="<?php echo esc_attr( $sale_end_date ); ?>" |
| 59 |
<?php if ( ! empty( $variations_sale_dates ) ) : ?> |
| 60 |
data-variations-dates="<?php echo wc_esc_json( wp_json_encode( $variations_sale_dates ) ); ?>" |
| 61 |
<?php endif; ?> |
| 62 |
style="display: none"> |
| 63 |
|
| 64 |
<div class="merchant-countdown-timer-inner"> |
| 65 |
<?php if ( $theme === 'classic' || is_admin() ) : ?> |
| 66 |
<svg fill="currentColor" height="24px" width="24px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 296.228 296.228"> |
| 67 |
<g> |
| 68 |
<path d="m167.364,48.003v-23.003h10.5c6.903,0 12.5-5.597 12.5-12.5s-5.596-12.5-12.5-12.5h-59.5c-6.903,0-12.5,5.597-12.5,12.5s5.597,12.5 12.5,12.5h10.5v23.003c-59.738,9.285-105.604,61.071-105.604,123.37-3.55271e-15,68.845 56.01,124.854 124.854,124.854s124.854-56.01 124.854-124.854c0-62.299-45.866-114.085-105.604-123.37zm-19.25,223.225c-55.06,0-99.854-44.795-99.854-99.854s44.795-99.854 99.854-99.854 99.854,44.795 99.854,99.854-44.794,99.854-99.854,99.854z"/> |
| 69 |
<path d="m160.614,166.18v-58.889c0-6.903-5.597-12.5-12.5-12.5s-12.5,5.597-12.5,12.5v66.1c0,2.033 0.81,3.982 2.25,5.416l34.969,34.822c4.893,4.872 12.806,4.854 17.678-0.037 4.871-4.892 4.854-12.807-0.037-17.678l-29.86-29.734z"/> |
| 70 |
</g> |
| 71 |
</svg> |
| 72 |
<?php endif; ?> |
| 73 |
|
| 74 |
<?php if ( $sale_ending_text ) : ?> |
| 75 |
<span class="merchant-countdown-timer-text"><?php echo esc_html( Merchant_Translator::translate( $sale_ending_text ) ); ?> </span> |
| 76 |
<?php endif; ?> |
| 77 |
|
| 78 |
<div class="merchant-countdown-timer-countdown" id="merchant-countdown-timer"></div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
|