WC_Order_Factory::get_order_id( mixed $order )
Get the order ID depending on what was passed.
Description Description
Parameters Parameters
- $order
-
(Required) Order data to convert to an ID.
Return Return
(int|bool) false on failure
Source Source
File: includes/class-wc-order-factory.php
public static function get_order_id( $order ) {
global $post;
if ( false === $order && is_a( $post, 'WP_Post' ) && 'shop_order' === get_post_type( $post ) ) {
return absint( $post->ID );
} elseif ( is_numeric( $order ) ) {
return $order;
} elseif ( $order instanceof WC_Abstract_Order ) {
return $order->get_id();
} elseif ( ! empty( $order->ID ) ) {
return $order->ID;
} else {
return false;
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |