ACF\Pro\Meta

WooOrder::decode_woo_order_idpublicACF 6.4

Checks numerical post IDs to see if they belong to a WC order.

Method of the class: WooOrder{}

No Hooks.

Returns

Array.

Usage

$WooOrder = new WooOrder();
$WooOrder->decode_woo_order_id( $decoded, $post_id );
$decoded(array) (required)
The decoded post ID props.
$post_id(int|string) (required)
The original post ID.

Changelog

Since 6.4 Introduced.

WooOrder::decode_woo_order_id() code ACF 6.8.8

public function decode_woo_order_id( $decoded, $post_id ) {
	// Bail if not a standard numeric post ID.
	if ( ! is_numeric( $post_id ) || empty( $decoded['type'] ) || 'post' !== $decoded['type'] ) {
		return $decoded;
	}

	// Bail if HPOS isn't enabled (traditional ACF meta methods work otherwise).
	if ( ! method_exists( OrderUtil::class, 'custom_orders_table_usage_is_enabled' ) ||
		! OrderUtil::custom_orders_table_usage_is_enabled() ) {
		return $decoded;
	}

	if ( 'shop_order_placehold' === get_post_type( $post_id ) ) {
		$decoded['type'] = 'woo_order';
	}

	return $decoded;
}