Admin_Products_Filter::filter_list_table_request( WP $request )

Summary

Enforce a channel filter when displaying the products list table by setting query vars on the request


Parameters

$request

(WP) (Required)


Return

(void)


Source

File: src/BigCommerce/Taxonomies/Channel/Admin_Products_Filter.php

	public function filter_list_table_request( \WP $request ) {
		if ( empty( $request->query_vars['post_type'] ) || $request->query_vars['post_type'] !== Product::NAME ) {
			return; // not a product query, let it through
		}
		if ( ! empty( $request->query_vars[ Channel::NAME ] ) ) {
			return; // already filtered by channel, let it through
		}
		try {
			$connections = new Connections();
			$primary = $connections->primary();
		} catch ( Channel_Not_Found_Exception $e ) {
			return; // we don't know which channel to use, let it through
		}
		$request->set_query_var( Channel::NAME, $primary->slug );
	}

User Contributed Notes

You must log in before being able to contribute a note or feedback.