Automattic\WooCommerce\Internal\Email

DeferredEmailQueue::get_supported_object_typesprivateWC 1.0

Get supported queued object types.

Method of the class: DeferredEmailQueue{}

No Hooks.

Returns

Array. array{class: class-string, get_id: callable, fetch: callable}>

Usage

// private - for code of main (parent) class only
$result = $this->get_supported_object_types(): array;

DeferredEmailQueue::get_supported_object_types() code WC 10.9.1

private function get_supported_object_types(): array {
	return array(
		'product'            => array(
			'class'  => \WC_Product::class,
			'get_id' => static function ( $queued_object ) {
				return $queued_object instanceof \WC_Product ? $queued_object->get_id() : null;
			},
			'fetch'  => static function ( $id ) {
				return \WC()->call_function( 'wc_get_product', $id );
			},
		),
		'order'              => array(
			'class'  => \WC_Order::class,
			'get_id' => static function ( $queued_object ) {
				return $queued_object instanceof \WC_Order ? $queued_object->get_id() : null;
			},
			'fetch'  => static function ( $id ) {
				return \WC()->call_function( 'wc_get_order', $id );
			},
		),
		'payment_gateway'    => array(
			'class'  => \WC_Payment_Gateway::class,
			'get_id' => static function ( $queued_object ) {
				return $queued_object instanceof \WC_Payment_Gateway ? $queued_object->id : null;
			},
			'fetch'  => static function ( $id ) {
				$gateways = \WC()->payment_gateways()->payment_gateways();
				return $gateways[ $id ] ?? null;
			},
		),
		'stock_notification' => array(
			'class'  => StockNotification::class,
			'get_id' => static function ( $queued_object ) {
				return $queued_object instanceof StockNotification ? $queued_object->get_id() : null;
			},
			'fetch'  => static function ( $id ) {
				return StockNotificationFactory::get_notification( (int) $id );
			},
		),
	);
}