Skip to content

Instantly share code, notes, and snippets.

//WP Query to get all bookable products of a vendor
$args = array(
'post_type' => 'product',
'author' => $vendor,
'meta_query' => array(
array(
'key' => '_wc_booking_availability',
'compare' => 'EXISTS',
),
// Woocommerce
// Restrict customer to buy in only one shop
add_filter( 'woocommerce_add_cart_item_data', 'woo_custom_add_to_cart_with_variations' );
function woo_custom_add_to_cart_with_variations( $cart_item_data ) {
//Compliant with product-variations
//Tested with woocoommerce 3.1 | WC Vendors PRO 1.4.3
global $woocommerce;
$items = $woocommerce->cart->get_cart(); //getting cart items
$_product = array();
foreach($items as $item => $values) {