Skip to content

Instantly share code, notes, and snippets.

View JonS7's full-sized avatar

Jon Packman JonS7

View GitHub Profile
@JonS7
JonS7 / get-resource-availability.js
Last active September 27, 2015 13:53
Hacky way to show what resources are fully booked on a single product page using Woocommerce Bookings.
var $product = $('#product');
var $bookingForm = $product.find('.cart');
var $picker = $bookingForm.find('.picker');
var $resources = $('#resources');
function checkAvailability( el ) {
var fully_booked_ids = [];
var jsonArray = el.data( 'fully-booked-days' );
var booking_date_year = $bookingForm.find('#booking_date_year').val();
@JonS7
JonS7 / get-product-availability.php
Last active February 22, 2023 05:49
Couldn't figure out how to use Woocommerce Bookings functions to show if a product was fully booked or not, so came up with this.
function get_product_availability() {
global $product, $post;
// Get dates from custom field
$start_date = get_field('start_date');
$end_date = get_field('end_date');
// Get into class
$WC_Product_Booking = new WC_Product_Booking($product);