wpgenie

mask auction bidder name in auction history tab

Apr 18th, 2018 (edited)
1,436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.90 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Mask Auction Bidder Name in Auction History Tab - solution with custom template (obsolete)
  4.  *
  5.  * please use this code snippet instead https://pastebin.com/r5P47mHL
  6.  *
  7.  */
  8.  
  9. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  10.  
  11. global $woocommerce, $post, $product;
  12.  
  13. $heading = esc_html( apply_filters('woocommerce_auction_history_heading', __( 'Auction History', 'wc_simple_auctions' ) ) );
  14. $datetimeformat = get_option('date_format').' '.get_option('time_format');
  15.  
  16. ?>
  17.  
  18. <h2><?php echo $heading; ?></h2>
  19.  
  20. <?php if(($product->is_closed() === TRUE ) and ($product->is_started() === TRUE )) : ?>
  21.    
  22.     <p><?php _e('Auction has finished', 'wc_simple_auctions') ?></p>
  23.     <?php if ($product->get_auction_fail_reason() == '1'){
  24.          _e('Auction failed because there were no bids', 'wc_simple_auctions');
  25.     } elseif($product->get_auction_fail_reason() == '2'){
  26.         _e('Auction failed because item did not make it to reserve price', 'wc_simple_auctions');
  27.     }
  28.    
  29.     if($product->get_auction_closed() == '3'){?>
  30.         <p><?php _e('Product sold for buy now price', 'wc_simple_auctions') ?>: <span><?php echo wc_price($product->get_regular_price()) ?></span></p>
  31.     <?php }elseif($product->get_auction_current_bider()){ ?>
  32.         <p><?php _e('Highest bidder was', 'wc_simple_auctions') ?>: <span><?php echo get_userdata($product->get_auction_current_bider())->display_name ?></span></p>
  33.     <?php } ?>
  34.                        
  35. <?php endif; ?>
  36.        
  37. <table id="auction-history-table-<?php echo $product->get_id(); ?>" class="auction-history-table">
  38.     <?php
  39.        
  40.         $auction_history = apply_filters('woocommerce__auction_history_data', $product->auction_history());
  41.                
  42.         if ( !empty($auction_history) ): ?>
  43.  
  44.         <thead>
  45.             <tr>
  46.                 <th><?php _e('Date', 'wc_simple_auctions') ?></th>
  47.                 <th><?php _e('Bid', 'wc_simple_auctions') ?></th>
  48.                 <th><?php _e('User', 'wc_simple_auctions') ?></th>
  49.                 <th><?php _e('Auto', 'wc_simple_auctions') ?></th>
  50.             </tr>
  51.         </thead>
  52.         <tbody>
  53.         <?php if ($product->is_sealed()){
  54.            
  55.                 echo "<tr>";
  56.                    echo "<td colspan='4'  class='sealed'>".__('This auction is sealed. Upon auction finish auction history and winner will be available to the public.', 'wc_simple_auctions')."</td>";
  57.                 echo "</tr>";
  58.  
  59.         } else {
  60.             foreach ($auction_history as $history_value) {
  61.                 echo "<tr>";
  62.                 echo "<td class='date'>".mysql2date($datetimeformat ,$history_value->date)."</td>";
  63.                 echo "<td class='bid'>".wc_price($history_value->bid)."</td>";
  64.                 echo "<td class='username'>".preg_replace("/(?!^).(?!$)/", "*", get_userdata($history_value->userid)->display_name)."</td>";
  65.                 if ($history_value->proxy == 1)
  66.                     echo " <td class='proxy'>".__('Auto', 'wc_simple_auctions')."</td>";
  67.                 else
  68.                     echo " <td class='proxy'></td>";
  69.                 echo "</tr>";
  70.             }
  71.         }?>
  72.         </tbody>
  73.  
  74.     <?php endif;?>
  75.        
  76.     <tr class="start">
  77.         <?php
  78.         if ($product->is_started() === TRUE ){
  79.             echo '<td class="date">'.mysql2date($datetimeformat ,$product->get_auction_start_time()).'</td>';
  80.             echo '<td colspan="3" class="started">';
  81.             echo apply_filters('auction_history_started_text', __( 'Auction started', 'wc_simple_auctions' ), $product);
  82.             echo '</td>';
  83.  
  84.         } else {
  85.                 echo '<td  class="date">'.mysql2date($datetimeformat ,$product->get_auction_start_time()).'</td>';
  86.                 echo '<td colspan="3"  class="starting">';
  87.                 echo apply_filters('auction_history_starting_text', __( 'Auction starting', 'wc_simple_auctions' ), $product);
  88.                 echo '</td>' ;
  89.         }
  90.         ?>
  91.     </tr>
  92. </table>
Add Comment
Please, Sign In to add comment