Advertisement
wpgenie

auction bid increase by percentage

Nov 15th, 2017
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.78 KB | None | 0 0
  1. add_action('woocommerce_simple_auctions_bid_value','custom_woocommerce_simple_auctions_bid_value',10,2);
  2. function custom_woocommerce_simple_auctions_bid_value ( $bid_value, $product ){
  3.    
  4.     $auction_bid_increment = ($product->get_auction_bid_increment()) ?(float)$product->get_curent_bid() * ((float)$product->get_auction_bid_increment()/100) : 1;
  5.  
  6.     if((int)$product->get_auction_bid_count() == '0'   ){
  7.             return $product->get_curent_bid();
  8.         } else  {
  9.             if($product->get_auction_type() == 'reverse' ){
  10.                 return round( wc_format_decimal($product->get_curent_bid()) - wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
  11.             }else{
  12.                 return round(  wc_format_decimal($product->get_curent_bid()) + wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
  13.             }
  14.         }
  15. }
  16. add_action('woocommerce_simple_auctions_proxy_curent_bid_value','custom_woocommerce_simple_auctions_proxy_curent_bid_value',10,3);
  17. function custom_woocommerce_simple_auctions_proxy_curent_bid_value($curent_bid ,$product_data,$bid){
  18.  
  19.     if ( ! ( $product_data->get_auction_reserved_price() && $product_data->is_reserve_met() === FALSE ) ){
  20.         $auction_bid_increment = ($product_data->get_auction_bid_increment()) ?(float)$product_data->get_curent_bid() * ((float)$product_data->get_auction_bid_increment()/100) : 1;
  21.         if ($product_data->get_auction_type() == 'normal') {
  22.             if ($product_data->get_auction_max_bid()){
  23.                 $temp_bid = round( wc_format_decimal($product_data->get_auction_max_bid()) + wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
  24.                 $curent_bid = ($bid < $temp_bid) ? $bid : $temp_bid ;
  25.             } else {
  26.                 $curent_bid = ($bid < $product_data->bid_value()) ? $bid : $product_data->bid_value();     
  27.             }
  28.         }else{
  29.             if ($product_data->get_auction_max_bid()){
  30.                 $temp_bid = round( wc_format_decimal($product_data->get_auction_max_bid()) - wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
  31.                 $curent_bid = ($bid > $temp_bid) ? $bid : $temp_bid ;
  32.             } else {
  33.                 $curent_bid = ($bid < $product_data->bid_value()) ? $bid : $product_data->bid_value();     
  34.             }              
  35.         }  
  36.     }
  37.     return $curent_bid;
  38. }
  39. add_action('woocommerce_simple_auctions_proxy_bid_value','custom_woocommerce_simple_auctions_proxy_bid_value',10,3);
  40. function custom_woocommerce_simple_auctions_proxy_bid_value($curent_bid ,$product_data,$bid){
  41.     $auction_bid_increment = ($product_data->get_auction_bid_increment()) ?(float)$bid * ((float)$product_data->get_auction_bid_increment()/100) : 1;
  42.     if ($product_data->get_auction_type() == 'normal') {
  43.         return round( wc_format_decimal($bid) + wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
  44.     } else{
  45.         return round( wc_format_decimal($bid) - wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
  46.     }  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement