ActionScheduler_HybridStore::get_store_from_action_id()protectedWC 1.0

Return which store an action is stored in.

Method of the class: ActionScheduler_HybridStore{}

No Hooks.

Return

ActionScheduler_Store.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_store_from_action_id( $action_id, $primary_first );
$action_id(int) (required)
ID of the action.
$primary_first(true|false)
Optional flag indicating search the primary store first.
Default: false

ActionScheduler_HybridStore::get_store_from_action_id() code WC 9.3.1

protected function get_store_from_action_id( $action_id, $primary_first = false ) {
	if ( $primary_first ) {
		$stores = [
			$this->primary_store,
			$this->secondary_store,
		];
	} elseif ( $action_id < $this->demarkation_id ) {
		$stores = [
			$this->secondary_store,
			$this->primary_store,
		];
	} else {
		$stores = [
			$this->primary_store,
		];
	}

	foreach ( $stores as $store ) {
		$action = $store->fetch_action( $action_id );
		if ( ! is_a( $action, 'ActionScheduler_NullAction' ) ) {
			return $store;
		}
	}
	return null;
}