Automattic\WooCommerce\Blocks\Patterns

PTKPatternsStore::fetch_patternspublicWC 1.0

Reset the cached patterns and fetch them again from the PTK API.

Method of the class: PTKPatternsStore{}

No Hooks.

Returns

null. Nothing (null).

Usage

$PTKPatternsStore = new PTKPatternsStore();
$PTKPatternsStore->fetch_patterns();

PTKPatternsStore::fetch_patterns() code WC 9.9.3

public function fetch_patterns() {
	if ( ! $this->allowed_tracking_is_enabled() ) {
		return;
	}

	$this->flush_cached_patterns();

	$patterns = $this->ptk_client->fetch_patterns(
		array(
			// This is the site where the patterns are stored. Despite the 'wpcomstaging.com' domain suggesting a staging environment, this URL points to the production environment where stable versions of the patterns are maintained.
			'site'       => 'wooblockpatterns.wpcomstaging.com',
			'categories' => array(
				'_woo_intro',
				'_woo_featured_selling',
				'_woo_about',
				'_woo_reviews',
				'_woo_social_media',
				'_woo_woocommerce',
				'_dotcom_imported_intro',
				'_dotcom_imported_about',
				'_dotcom_imported_services',
				'_dotcom_imported_reviews',
			),
		)
	);
	if ( is_wp_error( $patterns ) ) {
		wc_get_logger()->warning(
			sprintf(
			// translators: %s is a generated error message.
				__( 'Failed to get WooCommerce patterns from the PTK: "%s"', 'woocommerce' ),
				$patterns->get_error_message()
			),
		);
		return;
	}

	$patterns = $this->filter_patterns( $patterns );
	$patterns = $this->map_categories( $patterns );

	set_transient( self::TRANSIENT_NAME, $patterns );
}