Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

Purchase::get_title()publicWC 1.0

Title.

{} It's a method of the class: Purchase{}

No Hooks.

Return

String.

Usage

$Purchase = new Purchase();
$Purchase->get_title();

Code of Purchase::get_title() WC 6.7.0

public function get_title() {
	$products   = $this->get_paid_products_and_themes();
	$first_product    = count( $products['purchaseable'] ) >= 1 ? $products['purchaseable'][0] : false;

	if ( ! $first_product ) {
		return null;
	}

	$product_label    = isset( $first_product['label'] ) ? $first_product['label'] : $first_product['title'];
	$additional_count = count( $products['purchaseable'] ) - 1;

	if ( $this->get_parent_option( 'use_completed_title' ) && $this->is_complete() ) {
		return count( $products['purchaseable'] ) === 1
			? sprintf(
				/* translators: %1$s: a purchased product name */
				__(
					'You added %1$s',
					'woocommerce'
				),
				$product_label
			)
			: sprintf(
				/* translators: %1$s: a purchased product name, %2$d the number of other products purchased */
				_n(
					'You added %1$s and %2$d other product',
					'You added %1$s and %2$d other products',
					$additional_count,
					'woocommerce'
				),
				$product_label,
				$additional_count
			);
	}

	return count( $products['purchaseable'] ) === 1
		? sprintf(
			/* translators: %1$s: a purchaseable product name */
			__(
				'Add %s to my store',
				'woocommerce'
			),
			$product_label
		)
		: sprintf(
			/* translators: %1$s: a purchaseable product name, %2$d the number of other products to purchase */
			_n(
				'Add %1$s and %2$d more product to my store',
				'Add %1$s and %2$d more products to my store',
				$additional_count,
				'woocommerce'
			),
			$product_label,
			$additional_count
		);
}