PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.27
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.27
1.10.27 1.10.26 1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 All 171 releases
← All changes | includes/WC_API.php +11 -1 1.10.3 → 1.10.27 View file →
@@ -36,9 +36,13 @@
36 36 */
37 37 public function __construct() {
38 38 $pos_only_products = Settings::instance()->pos_only_products_enabled();
39 39
40 - if ( $pos_only_products ) {
40 + // `wp wc product list` dispatches these same routes. A WP-CLI command is the
41 + // merchant operating the shop, like wp-admin, so it lists every product.
42 + $is_cli = \defined( 'WP_CLI' ) && WP_CLI;
43 +
44 + if ( $pos_only_products && ! $is_cli ) {
41 45 add_filter( 'rest_pre_dispatch', array( $this, 'set_woocommerce_rest_api_request_flags' ), 10, 3 );
42 46 add_filter( 'posts_where', array( $this, 'exclude_pos_only_products_from_api_response' ), 10, 2 );
43 47 }
44 48 }
@@ -54,8 +58,14 @@
54 58 // WordPress matches REST routes case-insensitively, so a mixed-case path
55 59 // still dispatches to the products controller — flag detection must not
56 60 // be skippable by upper-casing the route.
57 61 $route = strtolower( $request->get_route() );
62 +
63 + // The flags describe THIS dispatch. A `/batch/v1` request dispatches its
64 + // sub-requests one after another through this same filter, so a products
65 + // sub-request must not leave the flags set for the one that follows it.
66 + $this->is_woocommerce_rest_api_products_request = false;
67 + $this->is_woocommerce_rest_api_variations_request = false;
58 68
59 69 if ( 0 === strpos( $route, '/wc/v3/products' ) || 0 === strpos( $route, '/wc/v2/products' ) || 0 === strpos( $route, '/wc/v1/products' ) ) {
60 70 $this->is_woocommerce_rest_api_products_request = true;
61 71