Add the appointment info in the WC New Order endpoint

Issue #1048 new
Valentina R created an issue

It’s very hard to retrieve the appointment info via REST API when a new order is created. There is no info in the order. One has to use the Appointments controller with the combo of product_id and customer_id and then loop through and match it to the order_id to get the needed data. Probably it’s harder with a guest user.

It would be great to get the basic info like the:

  • appointment ID
  • start time
  • end time
  • staff ids

Requested here.

Comments (2)

  1. Valentina R reporter

    A user figured that if you add the app data in the order item meta, you can retrieve it with the WC REST API as it’s part of the order.

    So, he did this:

    // Add appointment item meta 
    function jd_checkout_create_order_line_item($item, $cart_item_key, $values, $order)
    {
        if( isset( $values['appointment'] ) ) {
           $item->add_meta_data('appointment_meta', $values['appointment'], true);
        }
    }
    add_action('woocommerce_checkout_create_order_line_item', 'jd_checkout_create_order_line_item', 10, 4);
    

    SUGGESTION: Add this to core Appointments.

  2. Log in to comment