'Retrieve filled in Add-on data from booking/product
I'm writing a plugin to intercept the creation of bookings in wordpress. To have all the booking information I need to access the information filled in the addon fields (Woocommerce Product Add-Ons plugin) of a bookable product. The hooks I currently use give me access to the bookingId and object:
- woocommerce_new_booking
- woocommerce_booking_unpaid
I want to know how to get the add-on data from here, since I can't find it in the meta data? Is there a way to get it from the bookingId, orderId, etc?
Kind regards.
Solution 1:[1]
I have found the following:
$orderItem = wc_get_order($booking->order_id)->get_item($booking->order_item_id);
foreach($orderItem->get_data()["meta_data"] as $value){
error_log($value->key);
error_log($value->value);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | VincentD |