Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives
Incentive::get_by_promo_id
Get an incentive by promo 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_promo_id( $promo_id, $country_code, $incentive_type ): ?array;
- $promo_id(строка) (обязательный)
- The incentive promo ID.
- $country_code(строка) (обязательный)
- The business location country code to get incentives for.
- $incentive_type(строка)
- The type of incentive to search for.
По умолчанию:''
Код Incentive::get_by_promo_id() Incentive::get by promo id WC 10.5.0
public function get_by_promo_id( string $promo_id, string $country_code, string $incentive_type = '' ): ?array {
$incentives = array_filter(
$this->get_all( $country_code, $incentive_type ),
function ( $incentive ) use ( $promo_id ) {
return $incentive['promo_id'] === $promo_id;
}
);
if ( empty( $incentives ) ) {
return null;
}
// Get the first found incentive, in the unlikely case there are multiple incentives with the same promo ID.
return reset( $incentives );
}