Last active
March 2, 2022 12:23
-
-
Save cristianstan/842b76c683a492fd07e131259dc97516 to your computer and use it in GitHub Desktop.
WooCommerce Simple Auctions (Show outbid notice all the time).php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// For iBid Auctions theme: https://themeforest.net/item/ibid-multi-vendor-auctions-woocommerce-theme/24923136 | |
function ibid_outbid_always_notice_product_page() { | |
if (is_user_logged_in() && is_singular('product')) { | |
$user_id = get_current_user_id(); | |
$notice_type = 'error'; | |
// if ($user_id == '35') { | |
$product = wc_get_product( get_the_ID() ); | |
if( $product->is_type( 'auction' ) ){ | |
$auction_history = apply_filters('woocommerce__auction_history_data', $product->auction_history()); | |
$all_bidders = array(); | |
foreach ($auction_history as $history_value) { | |
if (!in_array($bidder_name, $all_bidders)) { | |
$bidder_id = $history_value->userid; | |
array_push($all_bidders, $bidder_id); | |
} | |
} | |
$all_bidders = array_unique($all_bidders); | |
// echo '<pre>' . var_export($all_bidders, true) . '</pre>'; | |
// echo '<pre>' . var_export($user_id, true) . '</pre>'; | |
if (in_array($user_id, $all_bidders)) { | |
if ($user_id != $all_bidders[0]) { | |
wc_add_notice( __('You\'ve been outbid!', 'ibid'), 'error' ); | |
} | |
} | |
} | |
// } | |
} | |
} | |
add_action( 'template_redirect', 'ibid_outbid_always_notice_product_page' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment