Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

Purchase::get_paid_products_and_themes()privateWC 1.0

Get purchaseable and remaining products.

{} Это метод класса: Purchase{}

Хуков нет.

Возвращает

Массив.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_paid_products_and_themes();

Код Purchase::get_paid_products_and_themes() WC 6.4.1

private function get_paid_products_and_themes() {
	$profiler_data = get_option( Onboarding::PROFILE_DATA_OPTION, array() );
	$installed     = PluginsHelper::get_installed_plugin_slugs();
	$product_types = isset( $profiler_data['product_types'] ) ? $profiler_data['product_types'] : array();
	$product_data  = Onboarding::get_product_data( Onboarding::get_allowed_product_types() );

	$theme      = isset( $profiler_data['theme'] ) ? $profiler_data['theme'] : null;
	$paid_theme = $theme ? $this->get_paid_theme_by_slug( $theme ) : null;
	if ( $paid_theme ) {
		$product_types[]        = 'themes';
		$product_data['themes'] = $paid_theme;
	}

	$purchaseable = array();
	$remaining    = array();
	foreach ( $product_types as $type ) {
		if ( ! isset( $product_data[ $type ]['slug'] ) ) {
			continue;
		}

		$purchaseable[] = $product_data[ $type ];

		if ( 'themes' === $type && isset( $product_data[ $type ]['is_installed'] ) && false === $product_data[ $type ]['is_installed'] ) {
			$remaining[] = $product_data[ $type ]['title'];
		}
		if ( 'themes' !== $type && ! in_array( $product_data[ $type ]['slug'], $installed, true ) ) {
			$remaining[] = $product_data[ $type ]['label'];
		}
	}

	return array(
		'purchaseable' => $purchaseable,
		'remaining'    => $remaining,
	);
}