add_action( 'wp_head', function () {
// Hide default vendor dashboard
echo '';
// Bootstrap 5 CSS CDN
echo '';
echo '';
} );
add_action( 'woocommerce_account_vendor-dashboard_endpoint', 'dm_custom_vendor_dashboard', 5 );
function dm_custom_vendor_dashboard() {
if ( ! is_user_logged_in() || ! function_exists( 'yith_get_vendor' ) ) {
return;
}
$vendor = yith_get_vendor( get_current_user_id(), 'user' );
if ( ! $vendor || ! $vendor->is_valid() ) {
echo '
You are not recognised as a vendor.
';
return;
}
$all_product_ids = $vendor->get_products( false );
if ( empty( $all_product_ids ) ) {
echo 'No products found.
';
return;
}
$products_per_page = 5;
$total_products = count( $all_product_ids );
$total_pages = ceil( $total_products / $products_per_page );
$current_page = isset( $_GET['vd_page'] ) ? max( 1, intval( $_GET['vd_page'] ) ) : 1;
if ( $current_page > $total_pages ) {
$current_page = $total_pages;
}
$offset = ( $current_page - 1 ) * $products_per_page;
$paged_product_ids = array_slice( $all_product_ids, $offset, $products_per_page );
echo '';
echo '
Your Auction Products
';
echo '
';
echo '
';
echo '';
echo '';
echo 'Image | ';
echo 'Title | ';
echo 'Start Bid | ';
echo 'Lot Number | ';
echo 'Status | ';
echo 'Start Date (AUS Sydney) | ';
echo 'End Date (AUS Sydney) | ';
echo '
';
echo '';
$now = current_time( 'timestamp' );
// Function to convert timestamp to Australia/Sydney timezone formatted string
function convert_to_sydney_time( $timestamp ) {
if ( ! $timestamp ) {
return '-';
}
try {
$date = new DateTime('@' . $timestamp); // UTC time
$tz = new DateTimeZone('Australia/Sydney');
$date->setTimezone($tz);
// Format: day/month/year, 12-hour time with seconds and AM/PM uppercase
return $date->format('d/m/Y, h:i:s A');
} catch (Exception $e) {
return '-';
}
}
foreach ( $paged_product_ids as $pid ) {
$product = wc_get_product( $pid );
if ( ! $product ) {
continue;
}
$image = get_the_post_thumbnail_url( $pid, 'thumbnail' ) ?: wc_placeholder_img_src();
$title = esc_html( $product->get_name() );
$start_bid = get_post_meta( $pid, '_yith_auction_start_price', true );
$start_raw = get_post_meta( $pid, '_yith_auction_for', true );
$end_raw = get_post_meta( $pid, '_yith_auction_to', true );
// Convert raw meta to timestamp
$start_ts = 0;
if ( ctype_digit( $start_raw ) ) {
$start_ts = (int) $start_raw;
} elseif ( !empty($start_raw) ) {
$temp_ts = strtotime( $start_raw );
if ( $temp_ts !== false ) {
$start_ts = $temp_ts;
}
}
$end_ts = 0;
if ( ctype_digit( $end_raw ) ) {
$end_ts = (int) $end_raw;
} elseif ( !empty($end_raw) ) {
$temp_ts = strtotime( $end_raw );
if ( $temp_ts !== false ) {
$end_ts = $temp_ts;
}
}
$lot_number = esc_html( get_post_meta( $pid, 'lot_number', true ) );
// Determine auction status
if ( $start_ts && $now < $start_ts ) {
$status = 'Upcoming';
} elseif ( $start_ts && $end_ts && $now >= $start_ts && $now <= $end_ts ) {
$status = 'Ongoing';
} elseif ( $end_ts && $now > $end_ts ) {
$status = 'Finished';
} else {
$status = 'Unknown';
}
// Format dates for Sydney time display
$start_date_formatted = convert_to_sydney_time( $start_ts );
$end_date_formatted = convert_to_sydney_time( $end_ts );
echo '';
echo '
| ';
echo '' . $title . ' | ';
echo '' . wc_price( $start_bid ?: 0 ) . ' | ';
echo '' . ( $lot_number ?: '-' ) . ' | ';
echo '' . $status . ' | ';
echo '' . esc_html( $start_date_formatted ) . ' | ';
echo '' . esc_html( $end_date_formatted ) . ' | ';
echo '
';
}
echo '
';
// Pagination
if ( $total_pages > 1 ) {
echo '
';
}
echo '
';
}
Shop - Whisky Estate
Skip to content