Tribe__Tickets_Plus__Commerce__WooCommerce__Meta::save_attendee_meta_to_order( int $order_id, string $from_status = null )
Sets attendee data on order posts.
Contents
Parameters
- $order_id
-
(int) (Required) WooCommerce Order ID
- $from_status
-
(string) (Optional) WooCommerce Status (from)
Default value: null
Source
File: src/Tribe/Commerce/WooCommerce/Meta.php
public function save_attendee_meta_to_order( $order_id, $from_status = null ) {
$order = new WC_Order( $order_id );
$order_items = $order->get_items();
// Bail if the order is empty
if ( empty( $order_items ) ) {
return;
}
$product_ids = array();
// gather product ids
foreach ( (array) $order_items as $item ) {
$product_ids[] = isset( $item['product_id'] ) ? $item['product_id'] : $item['id'];
}
$meta_object = Tribe__Tickets_Plus__Main::instance()->meta();
// build the custom meta data that will be stored in the order meta
if ( ! $order_meta = $meta_object->build_order_meta( $product_ids ) ) {
return;
}
// store the custom meta on the order
update_post_meta( $order_id, Tribe__Tickets_Plus__Meta::META_KEY, $order_meta, true );
if ( 'pending' === $from_status ) {
$this->clear_meta_cookie_data_for_products( $product_ids );
}
}
Changelog
| Version | Description |
|---|---|
| 5.9.1 | updated logic to new WooCommerce HPOS requirement. |
| 4.1 | Introduced. |