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.


Top ↑

Return Return

(int|bool) false on failure


Top ↑

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;
		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.