“Available now” feature to show availability

Is there a way for users to toggle on/ off their availability on ads and have it be filtered to only show ads marked as available now?

Similar to an online indicator, would show as green badge on users ads and would stay on for 4 hours before automatically toggling off unless user toggles off sooner.

For example someone has posted a listing for doing nails and has availability at that time they may toggle on available now to show frontend they currently have availability

Maybe plugin or something I’m able to achieve similar goal already built in?

Hi,

Unfortunately, there’s no such feature, it would require a custom implementation. But thanks for your suggestion, we’ll consider adding this feature.

1 Like

That would be amazing, but is possible to implement if I hire a developer?

Everything is usually possible with a developer and customizations.

Let me research it a little bit and see if I take a crack at it. I’ve managed to create code to show when the vendor is online and display it, but this is a little more complex.

Wow thats honestly just refreshing to hear things are possible (and complex) I assumed they were. Not a developer myself, but after spending an embarrassing amount of money before giving up every developer I hired always needed to start from scratch nothing I ever had should have been added to because it would end up costing my users their privacy and eventually my entire site but if I spent just a little more they could build a complete working end product exactly what I wanted no problem. Easy and usually way quicker than I would’ve expected.

So thanks I sincerely appreciate it and I’m not sure if this helps, I had hoped there was a plugin making plugin to make it easy but ai made this, maybe it can be helpful I am not sure

Here’s an example of the code for a WordPress plugin that adds an “Available Now” feature to HivePress classifieds:

<?php
/*
Plugin Name: HivePress Available Now
Description: Enables the "Available Now" feature for HivePress classifieds.
Version: 1.0
Author: Your Name
*/

// Add custom meta field for "Available Now" feature
function hp_an_add_available_now_meta_field() {
    hivepress()->listing->add_field(
        'available_now',
        [
            'label' => __('Available Now', 'hivepress'),
            'type' => 'checkbox',
            'position' => 5,
            'listing_types' => ['default'],
        ]
    );
}
add_action('hp_init', 'hp_an_add_available_now_meta_field');

// Add "Available Now" badge to the listing card
function hp_an_add_available_now_badge($listing_id) {
    $is_available_now = get_post_meta($listing_id, '_hp_available_now', true);

    if ($is_available_now) {
        echo '<span class="available-now-badge">Available Now</span>';
    }
}

// Enable "Available Now" feature for vendors
function hp_an_enable_available_now_feature($listing) {
    // Check if the user is a vendor
    if (current_user_can('hp_vendor')) {
        // Add "Available Now" checkbox to the listing form
        hivepress()->listing->add_field(
            'available_now',
            [
                'label' => __('Available Now', 'hivepress'),
                'type' => 'checkbox',
                'position' => 5,
                'listing_types' => ['default'],
                'editable' => true,
                'visible' => true,
            ]
        );
      
        // Automatically turn off the "Available Now" feature after 4 hours
        $expiration_time = 4 * 60 * 60; // 4 hours in seconds
      
        if (isset($listing['available_now']) && $listing['available_now']) {
            update_post_meta($listing['ID'], '_hp_available_now', true);
            update_post_meta($listing['ID'], '_hp_available_now_expiration', time() + $expiration_time);
        } else {
            update_post_meta($listing['ID'], '_hp_available_now', false);
        }
    }
}
add_action('hp_save_listing', 'hp_an_enable_available_now_feature');

// Disable "Available Now" feature if time has expired
function hp_an_disable_available_now_feature($listing_id) {
    $is_available_now = get_post_meta($listing_id, '_hp_available_now', true);
    $expiration_time = get_post_meta($listing_id, '_hp_available_now_expiration', true);

    if ($is_available_now && ($expiration_time <= time())) {
        update_post_meta($listing_id, '_hp_available_now', false);
    }
}
add_action('hp_save_listing', 'hp_an_disable_available_now_feature');

// Add custom CSS for "Available Now" badge
function hp_an_custom_css() {
    echo '<style>.available-now-badge { background-color: #00ff00; color: #fff; padding: 5px;}</style>';
}
add_action('wp_head', 'hp_an_custom_css');

Please note that this code assumes you have the HivePress plugin installed and activated. Also, make sure to test the plugin thoroughly before deploying it on a live site.

Hi Lexisux3033,

If I’m understanding correctly this is the customization you are requesting:

Each listing to display the available status of the vendor.
This available status to automatically turn to off after 4 hours, if the vendor does not turn it off themselves.

Email me & ill help you set it up: aqmiami7@gmail.com I’ll be leaving for vacation soon, so email me quickly to get it done before I leave.