Automattic\WooCommerce\Admin\Features\Fulfillments

Fulfillment::get_order │ public │ WC 1.0

Get the order associated with this fulfillment.

This method retrieves the order based on the entity type and entity ID. If the entity type is WC_Order, it returns the order object.

Метод класса: Fulfillment{}

Хуков нет.

Возвращает

\WC_Order|null. The order object or null if not found.

Использование

$Fulfillment = new Fulfillment();
$Fulfillment->get_order(): ?\WC_Order;

Код Fulfillment::get_order() WC 11.3.0

public function get_order(): ?\WC_Order {
	$entity_type = $this->get_entity_type();
	$entity_id   = $this->get_entity_id();

	if ( ! $entity_type || ! $entity_id ) {
		return null;
	}

	if ( \WC_Order::class === $entity_type ) {
		$order = wc_get_order( (int) $entity_id );
		if ( $order instanceof \WC_Order ) {
			return $order;
		}
	}

	return null;
}