Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives
Incentive::get_by_id()
Get an incentive by ID.
The incentives are filtered based on the country code, incentive type, if provided, and their visibility.
Метод класса: Incentive{}
Хуков нет.
Возвращает
?Массив
. The incentive details. Returns null if there is no incentive available.
Использование
$Incentive = new Incentive(); $Incentive->get_by_id( $incentive_id, $country_code ): ?array;
- $incentive_id(строка) (обязательный)
- The incentive ID.
- $country_code(строка) (обязательный)
- The business location country code to get incentives for.
Код Incentive::get_by_id() Incentive::get by id WC 9.6.1
public function get_by_id( string $incentive_id, string $country_code ): ?array { $incentives = array_filter( $this->get_all( $country_code ), function ( $incentive ) use ( $incentive_id ) { return $incentive['id'] === $incentive_id; } ); if ( empty( $incentives ) ) { return null; } // Get the first found incentive, in the unlikely case there are multiple incentives with the same ID. return reset( $incentives ); }