2

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.

VincentD
  • 45
  • 6

1 Answers1

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);
    }
VincentD
  • 45
  • 6