Automattic\WooCommerce\Internal\StockNotifications\Admin

ListTable::display_product_dropdownprotectedWC 1.0

Display product filter.

Method of the class: ListTable{}

No Hooks.

Returns

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->display_product_dropdown();

ListTable::display_product_dropdown() code WC 10.3.6

<?php
protected function display_product_dropdown() {
	$product_string = '';
	$product_id     = '';

	if ( ! empty( $_GET['customer_stock_notifications_product_filter'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		$product_id = wc_clean( wp_unslash( $_GET['customer_stock_notifications_product_filter'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		$product    = wc_get_product( absint( $product_id ) );

		if ( $product ) {
			$product_string = sprintf(
				/* translators: 1: product title 2: product ID */
				esc_html__( '%1$s (#%2$s)', 'woocommerce' ),
				$product->get_parent_id() ? $product->get_name() : $product->get_title(),
				absint( $product->get_id() )
			);
		}
	}
	?>
	<select class="wc-product-search" name="customer_stock_notifications_product_filter" data-placeholder="<?php esc_attr_e( 'Select product&hellip;', 'woocommerce' ); ?>" data-allow_clear="true" id="customer_stock_notifications_product_filter">
		<?php if ( $product_string && $product_id ) { ?>
			<option value="<?php echo esc_attr( $product_id ); ?>" selected="selected"><?php echo wp_kses_post( htmlspecialchars( $product_string, ENT_COMPAT ) ); ?></option>
		<?php } ?>
	</select>
	<?php
}