Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* visit us - https://wpgenie.org */
- /* Auto Extend Auction by 2 min when a bid is placed within the last 5mins */
- add_action( 'woocommerce_simple_auctions_outbid', 'woocommerce_simple_auctions_extend_time', 50 );
- add_action( 'woocommerce_simple_auctions_proxy_outbid', 'woocommerce_simple_auctions_extend_time', 50 );
- function woocommerce_simple_auctions_extend_time($data) {
- $product = get_product( $data['product_id'] );
- if ('auction' === $product->get_type() ) {
- $auctionend = new DateTime($product->get_auction_dates_to());
- $auctionendformat = $auctionend->format('Y-m-d H:i:s');
- $time = current_time( 'timestamp' );
- $timeplus5 = date('Y-m-d H:i:s', strtotime('+5 minutes', $time)); // if bid is placed in less than 5 minutes before auction end time
- if ($timeplus5 > $auctionendformat) {
- $auctionend->add(new DateInterval('PT120S')); // extend auction end time for 120 seconds
- update_post_meta( $data['product_id'], '_auction_dates_to', $auctionend->format('Y-m-d H:i:s') );
- // wc_add_notice(sprintf(__('Anti snipping enabled - auction end time extended for 2 minutes', 'wc_simple_auctions')), 'notice'); // optional, uncomment to use
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement