| @@ -34,9 +34,9 @@ | ||
| 34 | 34 | /** |
| 35 | 35 | * Constructor. |
| 36 | 36 | */ |
| 37 | 37 | public function __construct() { |
| 38 | - $pos_only_products = woocommerce_pos_get_settings( 'general', 'pos_only_products' ); | |
| 38 | + $pos_only_products = Settings::instance()->pos_only_products_enabled(); | |
| 39 | 39 | |
| 40 | 40 | if ( $pos_only_products ) { |
| 41 | 41 | add_filter( 'rest_pre_dispatch', array( $this, 'set_woocommerce_rest_api_request_flags' ), 10, 3 ); |
| 42 | 42 | add_filter( 'posts_where', array( $this, 'exclude_pos_only_products_from_api_response' ), 10, 2 ); |
| @@ -50,9 +50,12 @@ | ||
| 50 | 50 | * @param \WP_REST_Server $server The server instance. |
| 51 | 51 | * @param \WP_REST_Request $request The request object. |
| 52 | 52 | */ |
| 53 | 53 | public function set_woocommerce_rest_api_request_flags( $result, $server, $request ) { |
| 54 | - $route = $request->get_route(); | |
| 54 | + // WordPress matches REST routes case-insensitively, so a mixed-case path | |
| 55 | + // still dispatches to the products controller — flag detection must not | |
| 56 | + // be skippable by upper-casing the route. | |
| 57 | + $route = strtolower( $request->get_route() ); | |
| 55 | 58 | |
| 56 | 59 | if ( 0 === strpos( $route, '/wc/v3/products' ) || 0 === strpos( $route, '/wc/v2/products' ) || 0 === strpos( $route, '/wc/v1/products' ) ) { |
| 57 | 60 | $this->is_woocommerce_rest_api_products_request = true; |
| 58 | 61 | |