Automattic\WooCommerce\Internal\StockNotifications\Frontend
ProductPageIntegration::maybe_render_form
Handle BIS form.
Метод класса: ProductPageIntegration{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$ProductPageIntegration = new ProductPageIntegration(); $ProductPageIntegration->maybe_render_form();
Код ProductPageIntegration::maybe_render_form() ProductPageIntegration::maybe render form WC 11.2.2
public function maybe_render_form() {
if ( ! Config::allows_signups() ) {
return;
}
// Add to Cart + Options buffers this hook inside its <form> and falls back to a
// legacy HTML form when the buffer contains form elements. Block-theme support
// will ship separately.
if ( $this->is_rendering_inside_add_to_cart_with_options() ) {
return;
}
global $product;
if ( ! is_product() || ! is_a( $product, 'WC_Product' ) ) {
return;
}
if ( isset( $this->rendered[ $product->get_id() ] ) ) {
return;
}
$this->rendered[ $product->get_id() ] = true;
$is_variable = $product->is_type( 'variable' );
// Check if the product is in stock.
// Hint: This is negative logic. If the product is eligible for notifications, skip rendering.
// We avoid checking for variable products here because we want to render the form for out of stock variations.
if ( ! $is_variable && $this->eligibility_service->is_stock_status_eligible( $product->get_stock_status() ) ) {
return;
}
if ( ! $this->eligibility_service->is_product_eligible( $product ) ) {
return;
}
if ( ! $this->eligibility_service->product_allows_signups( $product ) ) {
return;
}
// Enqueue the script.
wp_enqueue_script( 'wc-back-in-stock-form' );
$this->render_form( $product );
}