WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Blocks

InboxNotifications::create_surface_cart_checkout_blocks_notification() public WC 1.0

Creates a notification letting merchants know about the Cart and Checkout Blocks.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

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

Хуков нет.

Возвращает

null. Ничего.

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

$result = InboxNotifications::create_surface_cart_checkout_blocks_notification();

Код InboxNotifications::create_surface_cart_checkout_blocks_notification() WC 5.8.0

public static function create_surface_cart_checkout_blocks_notification() {

	// If this is the feature plugin, then we don't need to do this. This should only show when Blocks is bundled
	// with WooCommerce Core.
	if ( Package::feature()->is_feature_plugin_build() ) {
		return;
	}

	if ( ! class_exists( 'Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes' ) ) {
		return;
	}

	if ( ! class_exists( 'WC_Data_Store' ) ) {
		return;
	}

	$data_store = \WC_Data_Store::load( 'admin-note' );
	$note_ids   = $data_store->get_notes_with_name( self::SURFACE_CART_CHECKOUT_NOTE_NAME );

	// Calculate store's eligibility to be shown the notice, starting with whether they have any plugins we know to
	// be incompatible with Blocks. This check is done before checking if the note exists already because we want to
	// delete the note if the merchant activates an ineligible plugin.
	foreach ( self::INELIGIBLE_EXTENSIONS as $extension ) {
		if ( is_plugin_active( $extension . '/' . $extension . '.php' ) ) {

			// Delete the notification here, we shouldn't show it if it's not going to work with the merchant's site.
			self::delete_surface_cart_checkout_blocks_notification();
			return;
		}
	}

	foreach ( (array) $note_ids as $note_id ) {
		$note = Notes::get_note( $note_id );

		// Return now because the note already exists.
		if ( $note->get_name() === self::SURFACE_CART_CHECKOUT_NOTE_NAME ) {
			return;
		}
	}

	// Next check the store is located in one of the eligible countries.
	$raw_country = get_option( 'woocommerce_default_country' );
	$country     = explode( ':', $raw_country )[0];
	if ( ! in_array( $country, self::ELIGIBLE_COUNTRIES, true ) ) {
		return;
	}

	// Pick a random number between 1 and 100 and add this to the wp_options table. This can then be used to target
	// a percentage of users. We do this here so we target a truer percentage of eligible users than if we did it
	// before checking plugins/country.
	$existing_probability = get_option( self::SURFACE_CART_CHECKOUT_PROBABILITY_OPTION );
	if ( false === $existing_probability ) {
		$existing_probability = wp_rand( 0, 100 );
		add_option( self::SURFACE_CART_CHECKOUT_PROBABILITY_OPTION, $existing_probability );
	}

	// Finally, check if the store's generated % chance is below the % of users we want to surface this to.
	if ( $existing_probability > self::PERCENT_USERS_TO_TARGET ) {
		return;
	}

	// At this point, the store meets all the criteria to be shown the notice! Woo!
	$note = new Note();
	$note->set_title(
		__(
			'Introducing the Cart and Checkout blocks!',
			'woocommerce'
		)
	);
	$note->set_content(
		__(
			"Increase your store's revenue with the conversion optimized Cart & Checkout WooCommerce blocks available in the WooCommerce Blocks extension.",
			'woocommerce'
		)
	);
	$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
	$note->set_source( 'woo-gutenberg-products-block' );
	$note->set_name( self::SURFACE_CART_CHECKOUT_NOTE_NAME );
	$note->add_action(
		'learn_more',
		'Learn More',
		'https://woocommerce.com/checkout-blocks/'
	);
	$note->save();

}