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,
}
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?
We intend on using the plugin to connect the client’s Amrod API to their WordPress/WooCommerce website.
Please let us know whether it will work for this purpose.
Thank you in advance.
When I disable the plugin then the API works fine. This was working fine until today morning though
{
“status”: “error”,
“error”: “Restricted”,
“error_description”: “Sorry, you are not allowed to access REST API.”,
“error_reason”: “With the free plan, only WordPress default endpoints can be authenticated. You can upgrade to the suitable premium plan to securely access the custom built or 3rd-party plugin endpoint.”
}
]]>I am trying to change a key-value pair in woocommerce using put
in postman, but just cannot get ANY data to change.
I know it works from our ERP system, where I just put the key and value in and it does its magic. But I want to learn and be able to test some other scenarios manually.
GET
and get a correct reply with infoPUT
a specific meta_data field.This is the reply from?GET
?(just made it shorter)
{
"id": 123445,
"name": "Productname",
"meta_data": [
{
"id": 121796,
"key": "_product_checkbox",
"value": "0"
}
]
}
I want to change the value of?_product_checkbox
, but even if I try just?name
, I have no success.
These are my PUT
settings:
staging102.ourdomain.com/wp-json/wc/v3/products/123445?consumer_key=ck_something&consumer_secret=cs_somethingelse
and then I tried in Body > raw > JSON
{"name":"Postmantest"}
and also separately
{
"meta_data": [
{
"key": "_product_checkbox",
"value": "1"
}
]
}
It always returns with status 200 and ok, but there is just nothing at all happening. What am I doing wrong, what have I missed?
Thanks!
]]>Recently (several days ago) my WooCommerce Mobile App stopped working and writes “error fetching data”. I have isolated the issue and found out that app starts to work with URL Shortify plugin disabled.
I suppose, that URL Shortify somehow conflicts with WooCommerce API.
Hope that you will manage to fix this issue and help me!
Thanks!
]]>When user applies points on Website UI checkout, appears Cart Discount and everything works good. But if we apply points on Website UI and after that use Woocommerce API: GET /wp-json/wc/store/v1/cart/ in the json response we get error.
Example of response:
{
"items": [
{
"key": "8a1e808b55fde9455cb3d8857ed88389",
"id": 1076,
"type": "simple",
"quantity": 1,
"quantity_limits": {
"minimum": 1,
"maximum": 9999,
"multiple_of": 1,
"editable": true
},
"name": "Adidas Cap",
"short_description": "",
"description": "",
"sku": "PPYX-CAU086_80X",
"low_stock_remaining": null,
"backorders_allowed": false,
"show_backorder_badge": false,
"sold_individually": false,
"permalink": "/product/adidas-cap-2/",
"images": [
],
"variation": [],
"item_data": [],
"prices": {
"price": "73900",
"regular_price": "73900",
"sale_price": "73900",
"price_range": null,
"currency_code": "UAH",
"currency_symbol": "?",
"currency_minor_unit": 2,
"currency_decimal_separator": ",",
"currency_thousand_separator": "",
"currency_prefix": "",
"currency_suffix": " ?",
"raw_prices": {
"precision": 6,
"price": "739000000",
"regular_price": "739000000",
"sale_price": "739000000"
}
},
"totals": {
"line_subtotal": "73900",
"line_subtotal_tax": "0",
"line_total": "73900",
"line_total_tax": "0",
"currency_code": "UAH",
"currency_symbol": "?",
"currency_minor_unit": 2,
"currency_decimal_separator": ",",
"currency_thousand_separator": "",
"currency_prefix": "",
"currency_suffix": " ?"
},
"catalog_visibility": "visible",
"extensions": {}
}
],
"coupons": [],
"fees": [],
"totals": {
"total_items": "73900",
"total_items_tax": "0",
"total_fees": "0",
"total_fees_tax": "0",
"total_discount": "0",
"total_discount_tax": "0",
"total_shipping": "0",
"total_shipping_tax": "0",
"total_price": "73900",
"total_tax": "0",
"tax_lines": [],
"currency_code": "UAH",
"currency_symbol": "?",
"currency_minor_unit": 2,
"currency_decimal_separator": ",",
"currency_thousand_separator": "",
"currency_prefix": "",
"currency_suffix": " ?"
},
"shipping_address": {},
"billing_address": {},
"needs_payment": true,
"needs_shipping": true,
"payment_requirements": [
"products"
],
"has_calculated_shipping": true,
"shipping_rates": [
],
"items_count": 1,
"items_weight": 0,
"cross_sells": [],
"errors": [
{
"code": "woocommerce_rest_cart_coupon_error",
"message": "The “cart discount” coupon has been removed from your cart: Coupon “cart discount” does not exist!"
}
],
"payment_methods": [],
"extensions": {}
}
]]>UPDATE 'wp_options' SET option_value = 1701286503' WHERE "option_name" = '_transient_timeout_woocommerce_blocks_asset_api_script_data_ssl'
Is there anyway to stop this happening?
]]>add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$percentage = 0.0195;
$totalCCExpense = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;
$surcharge = ($totalCCExpense / 3) * 2; // They pay 2/3 of the handling fee, we pay 1/3.
$woocommerce->cart->add_fee( '& Handling', round($surcharge, 2), true, '' );
}
The code above is what I did to add a handling charge to the orders. We have to manually do the orders, so I just add a small charge and have the customer pay 2/3 of that small fee, to recoup our loss of hiring the person to manually process orders. it does not cover it all, but helps us a tiny bit… But my question is…
I was able to successfully add a handling charge to the main order, but when it shows the future subscription order, it does not include the handling charge. How do I have it add it to both?
Here is the result of the cart when I added a product to it:
…
& Handling $1.02
Tax $6.33
Total $85.87
Recurring totals
Subtotal $62.32 / month
Shipping
UPS Ground: $16.20 / month
UPS Next Day Air: $67.54 / month
UPS 2nd Day Air: $31.41 / month
Tax $6.22 / month
Recurring total $84.74 / month
First renewal: August 7, 2023
See it did not add that to the Recurring Totals…
is there another function I can use to add it to the subscription part?
I got the code from: https://woocommerce.com/document/add-a-surcharge-to-cart-and-checkout-uses-fees-api/
{
"body": [],
"error": {
"status_code": 200,
"status_message": "OK",
"body": "\"[]\""
},
"returned_an_error": false,
"headers": {
"server": "nginx",
"date": "Fri, 07 Apr 2023 20:35:49 GMT",
"content-type": "application/json; charset=UTF-8",
"content-length": "2",
"connection": "keep-alive",
"set-cookie": [
"mailpoet_page_view=%7B%22timestamp%22%3A1680899748%7D; expires=Mon, 04-Apr-2033 20:35:48 GMT; Max-Age=315360000; path=/"
],
"x-robots-tag": "noindex",
"link": "https://shop.iwantthat.io/wp-json/; rel=\"https://api.w.org/\"",
"x-content-type-options": "nosniff",
"access-control-expose-headers": "X-WP-Total, X-WP-TotalPages, Link",
"access-control-allow-headers": "Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type",
"expires": "Wed, 11 Jan 1984 05:00:00 GMT",
"cache-control": "no-cache, must-revalidate, max-age=0",
"x-wp-total": "0",
"x-wp-totalpages": "0",
"x-xss-protection": "1; mode=block",
"allow": "GET, POST",
"x-httpd-modphp": "1",
"host-header": "6b7412fb82ca5edfd0917e3957f05d89",
"x-proxy-cache": "MISS",
"x-proxy-cache-info": "0 NC:000000 UP:SKIP_CACHE_NO_CACHE"
}
}
]]>