wpgenie icon

auction bid increase by percentage

wpgenie | PRO | 11/15/17 08:06:06 AM UTC | 0 ⭐ | 1394 👁️ | Never ⏰ | []
PHP |

2.78 KB

|

None

|

0 👍

/

0 👎

add_action('woocommerce_simple_auctions_bid_value','custom_woocommerce_simple_auctions_bid_value',10,2);
function custom_woocommerce_simple_auctions_bid_value ( $bid_value, $product ){
    
    $auction_bid_increment = ($product->get_auction_bid_increment()) ?(float)$product->get_curent_bid() * ((float)$product->get_auction_bid_increment()/100) : 1;
 
    if((int)$product->get_auction_bid_count() == '0'   ){
            return $product->get_curent_bid();
        } else  {
            if($product->get_auction_type() == 'reverse' ){
                return round( wc_format_decimal($product->get_curent_bid()) - wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
            }else{
                return round(  wc_format_decimal($product->get_curent_bid()) + wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
            }
        }
}
add_action('woocommerce_simple_auctions_proxy_curent_bid_value','custom_woocommerce_simple_auctions_proxy_curent_bid_value',10,3);
function custom_woocommerce_simple_auctions_proxy_curent_bid_value($curent_bid ,$product_data,$bid){
 
    if ( ! ( $product_data->get_auction_reserved_price() && $product_data->is_reserve_met() === FALSE ) ){
        $auction_bid_increment = ($product_data->get_auction_bid_increment()) ?(float)$product_data->get_curent_bid() * ((float)$product_data->get_auction_bid_increment()/100) : 1;
        if ($product_data->get_auction_type() == 'normal') {
            if ($product_data->get_auction_max_bid()){
                $temp_bid = round( wc_format_decimal($product_data->get_auction_max_bid()) + wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
                $curent_bid = ($bid < $temp_bid) ? $bid : $temp_bid ;
            } else {
                $curent_bid = ($bid < $product_data->bid_value()) ? $bid : $product_data->bid_value();      
            }
        }else{
            if ($product_data->get_auction_max_bid()){
                $temp_bid = round( wc_format_decimal($product_data->get_auction_max_bid()) - wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
                $curent_bid = ($bid > $temp_bid) ? $bid : $temp_bid ;
            } else {
                $curent_bid = ($bid < $product_data->bid_value()) ? $bid : $product_data->bid_value();      
            }               
        }   
    }
    return $curent_bid;
}
add_action('woocommerce_simple_auctions_proxy_bid_value','custom_woocommerce_simple_auctions_proxy_bid_value',10,3);
function custom_woocommerce_simple_auctions_proxy_bid_value($curent_bid ,$product_data,$bid){
    $auction_bid_increment = ($product_data->get_auction_bid_increment()) ?(float)$bid * ((float)$product_data->get_auction_bid_increment()/100) : 1;
    if ($product_data->get_auction_type() == 'normal') {
        return round( wc_format_decimal($bid) + wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
    } else{
        return round( wc_format_decimal($bid) - wc_format_decimal($auction_bid_increment),wc_get_price_decimals());
    }   
 
}

Comments