Automattic\WooCommerce\Internal\StockNotifications\Frontend
ProductPageIntegration::display_account_required
Display the account required message.
Method of the class: ProductPageIntegration{}
Hooks from the method
Returns
void. Nothing (null).
Usage
$ProductPageIntegration = new ProductPageIntegration(); $ProductPageIntegration->display_account_required( $product ): void;
- $product(WC_Product) (required)
- Product object.
ProductPageIntegration::display_account_required() ProductPageIntegration::display account required code WC 11.3.0
public function display_account_required( WC_Product $product ): void {
/**
* Filter the account required message HTML.
*
* @since 10.2.0
*
* @param string|null $pre The message.
* @param WC_Product $product Product object.
* @return string|null The message.
*/
$pre = apply_filters( 'woocommerce_customer_stock_notifications_account_required_message_html', null, $product );
if ( ! is_null( $pre ) ) {
echo wp_kses_post( $pre );
return;
}
// The My Account login form turns `redirect_to` into its hidden `redirect` field, so the shopper comes back here after logging in.
$login_url = add_query_arg( 'redirect_to', rawurlencode( $product->get_permalink() ), wc_get_page_permalink( 'myaccount' ) );
$text = __( 'Please {login_link} to sign up for stock notifications.', 'woocommerce' );
$text = str_replace( '{login_link}', '<a href="' . esc_url( $login_url ) . '">' . _x( 'log in', 'back in stock form', 'woocommerce' ) . '</a>', $text );
wc_print_notice( $text, 'notice' );
}