Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cristianstan/842b76c683a492fd07e131259dc97516 to your computer and use it in GitHub Desktop.
Save cristianstan/842b76c683a492fd07e131259dc97516 to your computer and use it in GitHub Desktop.
WooCommerce Simple Auctions (Show outbid notice all the time).php
<?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