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.9.4

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 );

	/**
	 * 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',
		UtmHelper::add_email_utm_params( $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' => UtmHelper::add_email_utm_params(
			add_query_arg(
				array(
					'email_link_action'     => EmailActionController::ACTION_UNSUBSCRIBE,
					'email_link_action_key' => $unsubscribe_key,
					'notification_id'       => $notification->get_id(),
				),
				get_option( 'siteurl' )
			)
		),
		'is_guest'         => $is_guest,
	);
}