Automattic\WooCommerce\Internal\StockNotifications\Emails

CustomerStockNotificationEmail::get_additional_template_argsprivateWC 1.0

Get template args.

Method of the class: CustomerStockNotificationEmail{}

Returns

Array.

Usage

// private - for code of main (parent) class only
$result = $this->get_additional_template_args(): array;

CustomerStockNotificationEmail::get_additional_template_args() code WC 10.3.6

private function get_additional_template_args(): array {

	$notification = $this->object;
	$product      = $notification->get_product();

	/**
	 * Filter the button text.
	 *
	 * @since 10.2.0
	 *
	 * @param string $button_text The button text.
	 * @param Notification $notification The notification object.
	 * @param WC_Product $product The product object.
	 */
	$button_text = apply_filters( 'woocommerce_email_stock_notification_button_text', _x( 'Shop Now', 'Email notification', 'woocommerce' ), $notification, $product );

	$query_args = array(
		'utm_source' => 'back-in-stock-notifications',
		'utm_medium' => 'email',
	);

	/**
	 * Filter the button href.
	 *
	 * @since 10.2.0
	 *
	 * @param string $button_href The button href.
	 * @param Notification $notification The notification object.
	 * @param WC_Product $product The product object.
	 */
	$button_link = apply_filters(
		'woocommerce_email_stock_notification_button_link',
		add_query_arg(
			$query_args,
			$notification->get_product_permalink()
		),
		$notification,
		$product
	);

	$unsubscribe_key = $notification->get_unsubscribe_key( true );
	$user            = get_user_by( 'email', $notification->get_user_email() );
	$is_guest        = ! is_a( $user, 'WP_User' );

	return array(
		'button_text'      => $button_text,
		'button_link'      => $button_link,
		'unsubscribe_link' => add_query_arg(
			array(
				'email_link_action_key' => $unsubscribe_key,
				'notification_id'       => $notification->get_id(),
			),
			get_option( 'siteurl' )
		),
		'is_guest'         => $is_guest,
	);
}