The following code extends auction end time on every bid placed if the last bid was placed on the last 60 seconds before the end time. Add the code to your iBid Child theme -> functions.php.

Extend Auction End Time with ’60 Seconds’

add_action( 'woocommerce_simple_auctions_outbid', 'ibid_woocommerce_simple_auctions_extend_time', 50 );
add_action( 'woocommerce_simple_auctions_proxy_outbid', 'ibid_woocommerce_simple_auctions_extend_time', 50 );

function ibid_woocommerce_simple_auctions_extend_time($data){
	$product = get_product( $data['product_id'] );
	if ('auction' === $product->get_type() ){
		$date1 = new DateTime($product->get_auction_dates_to());
		$date1->add(new DateInterval('PT60S'));
		update_post_meta( $data['product_id'], '_auction_dates_to', $date1->format('Y-m-d H:i:s') );
	}
}

Note: To replace the 60 seconds to 5 minutes for example, instead of “DateInterval(‘PT60S’)” set “DateInterval(‘PT5M’)“. Read more about PHP DateInterval on php.net.

Extend Auction End Time with ‘5 Minutes’

add_action( 'woocommerce_simple_auctions_outbid', 'ibid_woocommerce_simple_auctions_extend_time', 50 );
add_action( 'woocommerce_simple_auctions_proxy_outbid', 'ibid_woocommerce_simple_auctions_extend_time', 50 );

function ibid_woocommerce_simple_auctions_extend_time($data){
	$product = get_product( $data['product_id'] );
	if ('auction' === $product->get_type() ){
		$date1 = new DateTime($product->get_auction_dates_to());
		$date1->add(new DateInterval('PT5M'));
		update_post_meta( $data['product_id'], '_auction_dates_to', $date1->format('Y-m-d H:i:s') );
	}
}

Extend Auction End Time with ‘1 Hour’

add_action( 'woocommerce_simple_auctions_outbid', 'ibid_woocommerce_simple_auctions_extend_time', 50 );
add_action( 'woocommerce_simple_auctions_proxy_outbid', 'ibid_woocommerce_simple_auctions_extend_time', 50 );

function ibid_woocommerce_simple_auctions_extend_time($data){
	$product = get_product( $data['product_id'] );
	if ('auction' === $product->get_type() ){
		$date1 = new DateTime($product->get_auction_dates_to());
		$date1->add(new DateInterval('PT1H'));
		update_post_meta( $data['product_id'], '_auction_dates_to', $date1->format('Y-m-d H:i:s') );
	}
}

Was this post helpful?