Reputation: 11
I'm working with WooCommerce Bookings (version 1.15.11) and using the REST API to retrieve detailed information about bookable products, specifically the "person types" and their associated prices (e.g., different rates for adults and children for each product). However, my current requests only return an empty object for person types, and I'm unsure if I'm missing any required parameters or if additional metadata settings are needed.
Here’s what I’ve tried so far:
Accessing https://mydomaine.com/wp-json/wc-bookings/v1/products/213
Ensuring API keys have full read/write
permissions.
Example Response: Here is a sample response I receive for a bookable product:
{
"id": 213,
"name": "Bookable product name",
"slug": "bookable-product-name"
"permalink": "https://mydomaine.com/product/bookable-product-name/",
"date_created": "2019-07-09T13:03:33",
"date_created_gmt": "2019-07-09T12:03:33",
"date_modified": "2023-10-19T11:31:12",
"date_modified_gmt": "2023-10-19T10:31:12",
"type": "booking",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Take a shower and relax on arrival in one of our airport arrival lounges.</p>\n<ul>\n<li>Booking Lead Time (hrs) 1</li>\n<li>Airport Time Zone (GMT) +1</li>\n</ul>\n",
"short_description": "<p>Take a shower and relax on arrival in one of our airport arrival lounges.</p>\n",
"sku": "",
"price": "55",
"regular_price": "",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"on_sale": false,
"purchasable": true,
"total_sales": 27,
"virtual": true,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"low_stock_amount": null,
"sold_individually": true,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": false,
"shipping_taxable": false,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": false,
"average_rating": "0.00",
"rating_count": 0,
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 18,
"name": "Uncategorized",
"slug": "uncategorized"
}
],
"tags": [],
"images": [
{
"id": 303,
"date_created": "2019-07-15T15:01:08",
"date_created_gmt": "2019-07-15T14:01:08",
"date_modified": "2019-07-15T15:01:08",
"date_modified_gmt": "2019-07-15T14:01:08",
"src": "https://mydomaine.com/wp-content/uploads/2019/07/bookable-product-name.jpg",
"name": "bookable-product-name",
"alt": ""
}
],
"attributes": [],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 0,
"price_html": "From: <span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">€</span>55.00</bdi></span>",
"related_ids": [
211,
215,
504
],
"meta_data": [
{
"id": 1368,
"key": "_yoast_wpseo_primary_product_cat",
"value": ""
},
{
"id": 1369,
"key": "_yoast_wpseo_content_score",
"value": "90"
},
{
"id": 12112,
"key": "_product_addons",
"value": [
{
"name": "Time of Arrival/Departure",
"title_format": "label",
"description_enable": 1,
"description": "hh:mm am/pm",
"type": "custom_text",
"display": "select",
"position": 0,
"required": 1,
"restrictions": 0,
"restrictions_type": "any_text",
"adjust_price": 0,
"price_type": "flat_fee",
"price": "",
"min": 0,
"max": 0,
"options": [
{
"label": "",
"price": "",
"image": "",
"price_type": "flat_fee"
}
],
"wc_booking_person_qty_multiplier": 0,
"wc_booking_block_qty_multiplier": 0
},
{
"name": "Airline / Flight No",
"title_format": "label",
"description_enable": 0,
"description": "",
"type": "custom_text",
"display": "select",
"position": 1,
"required": 1,
"restrictions": 0,
"restrictions_type": "any_text",
"adjust_price": 0,
"price_type": "flat_fee",
"price": "",
"min": 0,
"max": 0,
"options": [
{
"label": "",
"price": "",
"image": "",
"price_type": "flat_fee"
}
],
"wc_booking_person_qty_multiplier": 0,
"wc_booking_block_qty_multiplier": 0
}
]
},
{
"id": 12113,
"key": "_product_addons_exclude_global",
"value": "1"
},
{
"id": 22888,
"key": "_yoast_wpseo_estimated-reading-time-minutes",
"value": "1"
},
{
"id": 22889,
"key": "_yoast_wpseo_wordproof_timestamp",
"value": ""
}
],
"stock_status": "instock",
"has_options": false,
"post_password": "",
"global_unique_id": "",
"apply_adjacent_buffer": false,
"availability": [],
"block_cost": 0,
"buffer_period": 0,
"calendar_display_mode": "",
"cancel_limit_unit": "month",
"cancel_limit": 1,
"check_start_block_only": false,
"cost": 0,
"default_date_availability": "available",
"display_cost": "55",
"duration_type": "fixed",
"duration_unit": "day",
"duration": 2,
"enable_range_picker": false,
"first_block_time": "",
"has_person_cost_multiplier": false,
"has_person_qty_multiplier": false,
"has_person_types": true,
"has_persons": true,
"has_resources": false,
"has_restricted_days": "",
"max_date": {
"value": 12,
"unit": "month"
},
"max_date_value": 12,
"max_date_unit": "month",
"max_duration": 1,
"max_persons": 1000,
"min_date": {
"value": 2,
"unit": "day"
},
"min_date_value": 2,
"min_date_unit": "day",
"min_duration": 1,
"min_persons": 1,
"person_types": { //this should has the details
"381": {},
"382": {}
},
"pricing": [],
"qty": 1000,
"requires_confirmation": false,
"resource_label": "",
"resource_base_costs": [],
"resource_block_costs": [],
"resource_ids": [],
"resources_assignment": "customer",
"restricted_days": "",
"can_be_cancelled": false,
"user_can_cancel": false,
"_links": {
"self": [
{
"href": "https://fasttrack-casablanca.com/wp-json/wc-bookings/v1/products/213"
}
],
"collection": [
{
"href": "https://fasttrack-casablanca.com/wp-json/wc-bookings/v1/products"
}
]
}
}
the data that i need to retrieve :
My questions:
Are there specific parameters I need to include to retrieve person type details via the WooCommerce REST API?
Is there a dedicated endpoint for accessing person types with price breakdowns that WooCommerce Bookings uses?
If these details are stored as metadata, how can I correctly query them?
Upvotes: 0
Views: 55