Tribe__Tickets__Commerce__PayPal__Order::hydrate_from_post( int $order_post_id, null|array $fields = null )
Fills an order information from a post stored fields and meta.
Contents
This is a database-light operation that will not update the Order database information, use the update method to update the Order information on the database.
See also
Parameters
- $order_post_id
-
(int) (Required) The Order post ID.
- $fields
-
(null|array) (Optional) List of fields to hydrate, or null for all.
Default value: null
Return
Source
File: src/Tribe/Commerce/PayPal/Order.php
public function hydrate_from_post( $order_post_id ) {
$order_post = get_post( $order_post_id );
if (
! $order_post instanceof WP_Post
|| Tribe__Tickets__Commerce__PayPal__Main::ORDER_OBJECT !== $order_post->post_type
) {
return $this;
}
$status = tribe( 'tickets.commerce.paypal' )->get_order_statuses();
$this->paypal_order_id = $order_post->post_title;
$this->post_id = $order_post_id;
$this->status = $order_post->post_status;
$this->status_label = $status[ $order_post->post_status ];
$this->created = $order_post->post_date;
$this->modified = $order_post->post_modified;
$hashed_meta = get_post_meta( $order_post_id, $this->hashed_meta_key, true );
if ( ! empty( $hashed_meta ) ) {
foreach ( $hashed_meta as $key => $value ) {
$this->set_meta( $key, $value );
}
}
foreach ( $this->searchable_meta_keys as $key ) {
$prefixed_key = self::$meta_prefix . $key;
$this->set_meta( $key, get_post_meta( $order_post_id, $prefixed_key, true ) );
}
/**
* Fired after an Orde object has been filled from post fields and meta. *
*
* @since 4.7
*
* @param Tribe__Tickets__Commerce__PayPal__Order $this
*/
do_action( 'tribe_tickets_tpp_order_from_post', $this );
return $this;
}
Changelog
| Version | Description |
|---|---|
| 4.7 | |
| 4.10.11 | Introduced. |