Automattic\WooCommerce\Internal\ProductFeed\Mapping
UcpProductMapper::build_variation_list
Hydrate and transform variations in order, stopping at an optional limit.
The limit is applied while iterating rather than by slicing afterwards, so variations past it are never loaded.
Метод класса: UcpProductMapper{}
Хуков нет.
Возвращает
array.
Использование
// private - только в коде основоного (родительского) класса $result = $this->build_variation_list( $variation_ids, $options, $currency, ?int $limit ): array;
- $variation_ids(массив) (обязательный)
- Variation ids, in the order to build them.
- $options(массив) (обязательный)
- Selected options keyed by variation id, from the parent item.
- $currency(строка) (обязательный)
- ISO 4217 currency code.
- ?int $limit
- .
По умолчанию:null
Код UcpProductMapper::build_variation_list() UcpProductMapper::build variation list WC 11.3.0
private function build_variation_list( array $variation_ids, array $options, string $currency, ?int $limit = null ): array {
$variants = array();
foreach ( $variation_ids as $variation_id ) {
if ( null !== $limit && count( $variants ) >= $limit ) {
break;
}
$variation = wc_get_product( $variation_id );
if ( ! $variation instanceof \WC_Product_Variation ) {
continue;
}
$variants[] = $this->build_variation_variant( $this->item( $variation ), $options[ (int) $variation_id ] ?? array(), $currency );
}
return $variants;
}