wpgenie

add outbid badge to auction

May 28th, 2015 (edited)
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. // check also https://pastebin.com/EcmuuzHM
  2.  
  3. add_action('woocommerce_before_shop_loop_item_title', 'add_outbid_bage', 60);
  4.  
  5. function add_outbid_bage(){
  6.     global $product,$wpdb;
  7.     if ( is_user_logged_in() ) {
  8.         $auction_relisted = '';
  9.         if($product->auction_relisted){
  10.             $auction_relisted = ' AND date > "'. $product->auction_relisted.'"' ;
  11.         }
  12.        
  13.         $user_id  = get_current_user_id();
  14.         $postids = array();
  15.        
  16.         $userauction     = $wpdb->get_results("SELECT DISTINCT auction_id FROM ".$wpdb->prefix."simple_auction_log WHERE userid = $user_id AND auction_id = ".$product->id." ".$auction_relisted ,ARRAY_N );
  17.         if(isset($userauction) && !empty($userauction)){
  18.             foreach ($userauction as $auction) {
  19.                 $postids []= $auction[0];
  20.  
  21.             }
  22.         }
  23.        
  24.         if ( $product->product_type == 'auction'  && ( $user_id != $product->auction_current_bider && !$product-> auction_closed) && (in_array($product->id, $postids))) :
  25.             echo '<span class="outbid "></span>';
  26.         endif;
  27.     }
  28. }
Add Comment
Please, Sign In to add comment