Advertisement
wpgenie

custom_get_increase_bid_value

Oct 16th, 2019 (edited)
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. function custom_get_increase_bid_value( $metadata, $object_id, $meta_key, $single ) {
  2.  
  3.     if ( isset( $meta_key ) && '_auction_bid_increment' === $meta_key ) {
  4.         $product = wc_get_product( $object_id );
  5.  
  6.         if( (! $product) || $product->get_type() != 'auction' ){
  7.             return $metadata;
  8.         }
  9.  
  10.         $bid_value = $product->get_curent_bid();
  11.  
  12.             switch ( $bid_value ) {
  13.                 case $bid_value <= 25:
  14.                     $auction_bid_increment = 2;
  15.                     break;
  16.                 case ( $bid_value > 25 && $bid_value <= 80 ):
  17.                     $auction_bid_increment = 5;
  18.                     break;
  19.                 case ( $bid_value > 80 && $bid_value <= 230 ):
  20.                     $auction_bid_increment = 10;
  21.                     break;
  22.                 case ( $bid_value > 230 && $bid_value <= 750 ):
  23.                     $auction_bid_increment = 20;
  24.                     break;
  25.                 case ( $bid_value > 750 && $bid_value <= 2000 ):
  26.                     $auction_bid_increment = 40;
  27.                     break;
  28.                 case ( $bid_value > 20000 && $bid_value <= 6000 ):
  29.                     $auction_bid_increment = 80;
  30.                     break;
  31.                 case ( $bid_value > 6000 && $bid_value <= 20000 ):
  32.                     $auction_bid_increment = 200;
  33.                     break;
  34.                 case ( $bid_value > 20000 && $bid_value <= 50000 ):
  35.                     $auction_bid_increment = 500;
  36.                     break;
  37.                 case ( $bid_value > 50000 ):
  38.                     $auction_bid_increment = 10000;
  39.                     break;
  40.             }
  41.  
  42.         return $auction_bid_increment;
  43.  
  44.     }
  45.  
  46.     // Return original if the check does not pass
  47.     return $metadata;
  48.  
  49. }
  50.  
  51. add_filter( 'get_post_metadata', 'custom_get_increase_bid_value', 100, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement