Get the last booked listing order


I want a function that returns the last completed order of listing related to a given Vendor (host)
something like :

function get_last_completed_order( $vendor_id ){

Or is there a prebuilt function that I can use instead


It is possible to get the last vendor order with the wc_get_orders function, where you should pass these parameters

'limit' => 1,
'meta_key'   => 'hp_vendor',
'meta_value' => put vendor id here,
'orderby'       => 'date',
'order'         => 'DESC',

After getting the order, it is possible to get a listing by getting the parent id of the order’s product in this way.

\HivePress\Models\Listing::query()->get_by_id(put here order's product parent id);

If you are not familiar with the code customization, then please consider hiring someone for custom work

1 Like

Thank you @yevhen it’s working :wink:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.