Syncing the Search Element with WooCommerce Inventory

Job ID: 40322942

Budget: ₹600 – ₹1,500 INR

Our Elementor-based “Search” widget is meant to return only boats that are actually available, yet right now it simply reads from the custom post type and ignores all the booking and stock metadata stored by WooCommerce. I need code that intervenes at query time so the widget stops showing boats that are out of stock or already booked for the dates a visitor selects.

Here is exactly what has to happen:

• Hook into the WP_Query (or the specific AJAX filter the Elementor widget fires) and merge in logic from WooCommerce Bookings.
• Cross-reference each returned post’s product_id against the wc_booking and/or order_item_meta tables.
• Append a meta_query that removes any post whose _stock_status equals “outofstock”.
• For the visitor’s requested start_date and end_date, check existing orders with status processing or completed; if there is any overlap, push that boat’s ID into post__not_in before the final query runs.

I am happy with either a pure SQL JOIN approach or the official WooCommerce Bookings API—whichever proves cleaner and more future-proof. What matters is that the final JSON response powering the Elementor results contains only boats that are simultaneously in stock and free for the chosen date range.

Please deliver a commented PHP snippet (functions.php ready) plus brief notes describing where to hook it and how to adjust if we later add new booking statuses.
Related categories: PHP JavaScript AJAX SQL WordPress MySQL HTML WooCommerce Web Development Elementor