Advertisement
wpgenie

Template Name: Auctions Not Paid Template

Apr 9th, 2021 (edited)
1,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <?php /* Template Name: Auctions Not Paid Template */ ?>
  2.  
  3.  
  4.  
  5. <?php
  6.  
  7. /* visit us - https://wpgenie.org */
  8.  
  9. /* WP page template that shows all auctions that are not paid for with info about winning bid, winning user and pay now button */
  10.  
  11.  
  12.  
  13. defined( 'ABSPATH' ) || exit;
  14.  
  15. get_header( 'shop' );
  16.  
  17. do_action( 'woocommerce_before_main_content' );
  18.  
  19. ?>
  20. <header class="woocommerce-products-header">
  21.     <h1 class="woocommerce-products-header__title page-title">Auctions Not Paid For</h1>   
  22.     <?php
  23.         do_action( 'woocommerce_archive_description' );
  24.     ?>
  25. </header>
  26. <?php
  27.  
  28.  
  29.     // Return sucessfully finished auctions IDs but not paid for yet.
  30.     $args = array(
  31.     'post_type'   => 'product',
  32.     'show_past_auctions' => TRUE,
  33.     'tax_query' => array(array('taxonomy' => 'product_type' , 'field' => 'slug', 'terms' => 'auction')),
  34.     'meta_query' => array(
  35.         'relation' => 'AND',
  36.             array(
  37.                 'key' => '_auction_closed',
  38.                 'value' => '2',
  39.                 'operator' => '=',             
  40.             ),  
  41.        
  42.         ),
  43.     'auction_arhive' => TRUE,
  44.     'show_past_auctions' => TRUE
  45.  
  46.     );    
  47.     $the_query  = new WP_Query( $args );
  48.  
  49.     if ( $the_query->have_posts() ) {
  50.  
  51.         do_action( 'woocommerce_before_shop_loop' );
  52.  
  53.         woocommerce_product_loop_start();
  54.        
  55.         while ( $the_query->have_posts() ) {
  56.  
  57.             $the_query->the_post();                
  58.             $auction = wc_get_product($post->ID);
  59.             do_action( 'woocommerce_shop_loop' );
  60.  
  61.         ?>
  62.         <li <?php wc_product_class( '', $product ); ?>>
  63.             <?php
  64.             $user = get_userdata($auction->get_auction_current_bider());
  65.             echo "Winner is: ". $user->first_name;
  66.  
  67.             do_action( 'woocommerce_before_shop_loop_item' );
  68.  
  69.             do_action( 'woocommerce_before_shop_loop_item_title' );
  70.  
  71.             do_action( 'woocommerce_shop_loop_item_title' );
  72.  
  73.             do_action( 'woocommerce_after_shop_loop_item_title' );
  74.  
  75.             do_action( 'woocommerce_after_shop_loop_item' );
  76.             ?>
  77.         </li>
  78.         <?php
  79.             // wc_get_template_part( 'content', 'product' );
  80.            
  81.            
  82.         }
  83.        
  84.  
  85.         woocommerce_product_loop_end();
  86.  
  87.         do_action( 'woocommerce_after_shop_loop' );
  88.     } else {
  89.  
  90.         do_action( 'woocommerce_no_products_found' );
  91.     }
  92.  
  93. do_action( 'woocommerce_after_main_content' );
  94.  
  95. do_action( 'woocommerce_sidebar' );
  96.  
  97. get_footer( 'shop' );
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement