Automattic\WooCommerce\Internal\Fulfillments
Fulfillment::get_order
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.
Method of the class: Fulfillment{}
No Hooks.
Returns
\WC_Order|null. The order object or null if not found.
Usage
$Fulfillment = new Fulfillment(); $Fulfillment->get_order(): ?\WC_Order;
Fulfillment::get_order() Fulfillment::get order code WC 10.3.3
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;
}