Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'woocommerce_after_shop_loop_item_title' , 'lottery_custom_info',80 );
- function lottery_custom_info(){
- global $product;
- if ( ! is_object( $product)) $product = wc_get_product( get_the_ID() );
- if ( $product && $product->get_type() == 'lottery' ) {
- $max_tickets = $product->get_max_tickets();
- $lottery_participants_count = !empty($product->get_lottery_participants_count()) ? $product->get_lottery_participants_count() : '0';
- ?>
- <span class="lottery-timer">
- <i class="fas fa-clock"></i><div class="lottery-time-countdown-compact" data-time="<?php echo $product->get_seconds_remaining() ?>" data-lotteryid="<?php echo $product->get_id() ?>" data-format="<?php echo get_option( 'simple_lottery_countdown_format' ) ?>"></div>
- </span>
- <span class="remaining-tickets">
- <i class="fas fa-ticket-alt"></i><?php echo ($max_tickets - $lottery_participants_count); ?> <?php _e( 'Remaining', 'wc_lottery_custom' )?>
- </span>
- <span class="max-pp-tickets">
- <i class="fas fa-user"></i><?php _e( 'max', 'wc_lottery_custom' )?> <?php echo ($product->get_max_tickets_per_user()); ?> <?php _e( 'pp', 'wc_lottery_custom' )?>
- </span>
- <?php }
- }
- add_action('wp_footer', 'custom_footer_script');
- function custom_footer_script(){ ?>
- <script>
- jQuery(document).ready(function($){
- $(".lottery-time-countdown-compact").each(function(index) {
- var time = $(this).data('time');
- var format = $(this).data('format');
- if (format == '') {
- format = 'yowdHMS';
- }
- $(this).wc_lotery_countdown({
- until: $.wc_lotery_countdown.UTCDate(-(new Date().getTimezoneOffset()), new Date(time * 1000)),
- // format: format,
- compact: true,
- significant: 1,
- layout: '{d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}'
- });
- });
- })
- </script>
- <?php }
Advertisement
Add Comment
Please, Sign In to add comment