wpgenie

remove finished auctions from related products

Oct 8th, 2020
1,525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. /*
  2.  
  3. Remove finished auctions from related products.
  4.  
  5. this code should be placed in child theme functions.php file
  6.  
  7. */
  8. add_filter( 'woocommerce_product_related_posts_query', 'custom_remove_finished_auctions_from_related_products' );
  9. function custom_remove_finished_auctions_from_related_products( $query ) {
  10.     $finished_auctions = wsa_get_finished_auctions_id();
  11.     if (  count( $finished_auctions ) ) {
  12.             $query['where'] .= ' AND p.ID NOT IN ( ' . implode( ',', array_map( 'absint', $finished_auctions ) ) . ' )';
  13.     }
  14.     return $query;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment