Advertisement
wpgenie

winning-bage.php mod to show outbidded badge

Sep 1st, 2020 (edited)
3,304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.  /*
  3.  
  4.  Winning badge template modification to show "Outbidded!" badge in loop for users that have participated in auction but have been outbidded.
  5.  
  6.  Template location: plugin_dir\templates\loop\winning-bage.php
  7.  
  8.  Copy this modification to your_child_theme\woocommerce\loop\winning-bage.php
  9.  
  10.  */
  11.  
  12. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  13.  
  14. global $product;
  15.  
  16. if (  method_exists( $product, 'get_type') && $product->get_type() == 'auction' ) :
  17.    
  18.     $user_id  = get_current_user_id();
  19.     $prodid =   $product->get_id();
  20.  
  21.     if ($user_id == $product->get_auction_current_bider() && !$product->get_auction_closed() && !$product->is_sealed()) :
  22.        
  23.         echo apply_filters('woocommerce_simple_auction_winning_bage', '<span class="winning" data-auction_id="'.$prodid.'" data-user_id="'.get_current_user_id().'">'.__( 'Winning!', 'wc_simple_auctions' ).'</span>', $product);
  24.     else:
  25.  
  26.         if ( $product -> is_user_biding($prodid, $user_id) && !$product->get_auction_closed() && !$product->is_sealed() ):
  27.             echo apply_filters('woocommerce_simple_auction_winning_bage', '<span class="winning" style="background: red" data-auction_id="'.$prodid.'" data-user_id="'.get_current_user_id().'">'.__( 'Outbidded!', 'wc_simple_auctions' ).'</span>', $product);   
  28.         endif;
  29.  
  30.     endif;
  31. endif;
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement