0

I have been trying to figure out how i get the ressource on a WC-order, from the product line data, but i seem not to be able to figure this out in WC 3.0+ - pre that it was pretty easy.
I have looked at both the booking meta data, the order meta data, and everything else i can think of, but still unable to find what im looking for.
I have 1 Product with the ID 194 and that product have 2 ressources - and im looking to find the resource in the order line.

Code:

$order = new WC_Order((int)$order_id);
$orderLine = array_values($order->get_items())[0];

Plugins:

  • Updated WooCommerce
  • Updated WooCommerce-Booking
1

For existing orders, you need to use the wc_get_order() function.

  • Sadly this does not help me, either way im left behind with a WC_Order_Item_Product Object, that i cant get any usefull information out of (Ressource ID, of the purchase) - but in the future i will make sure to use wc_get_order(), when dealing with existing orders – Mac Mar 26 '18 at 7:17
0

So i found a "solution" even though it's not as good as i hoped - or atleast not as good as the way it was done pre 3.0.

$iOrderID = $_POST['iOrderID'];
$aBookingQuery = new WP_Query( 
    array( 
        'post_parent'       => (int)$iOrderID,
        'post_type'         => 'wc_booking',
        'posts_per_page'    => 1 
        )
    );
 = $aBookingQuery->posts[0]->ID;
$iBookingRessoureceID = get_post_meta($iBookingID)['_booking_resource_id'][0];

this gives you the ressource ID of said booked product.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.