Automattic\WooCommerce\Internal

ScheduledSaleRun::__construct │ public │ WC 1.0

Initialize a scheduled sale run.

Метод класса: ScheduledSaleRun{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$ScheduledSaleRun = new ScheduledSaleRun();
$ScheduledSaleRun->__construct( $entries, $mode );
$entries(mixed[]) (обязательный)
Product references returned by the data store.
$mode(строка) (обязательный)
One of MODE_START or MODE_END.

Код ScheduledSaleRun::__construct() WC 11.3.0

public function __construct( array $entries, string $mode ) {
	if ( ! in_array( $mode, array( self::MODE_START, self::MODE_END ), true ) ) {
		throw new \InvalidArgumentException( 'Scheduled sale mode must be either start or end.' );
	}

	$this->mode         = $mode;
	$this->product_ids  = array();
	$this->product_util = wc_get_container()->get( ProductUtil::class );

	foreach ( $entries as $entry ) {
		$product_id = $this->product_util->get_product_id( $entry );
		if ( $product_id > 0 ) {
			$this->product_ids[ $product_id ] = $product_id;
		}
	}

	$this->product_cache = FeaturesUtil::feature_is_enabled( ProductCacheController::FEATURE_NAME )
		? wc_get_container()->get( ProductCache::class )
		: null;

	// Shared groups can only be flushed when the cache belongs to this request.
	$this->flush_shared_groups = wp_cache_supports( 'flush_group' ) && ! wp_using_ext_object_cache();
}