diff --git a/includes/API.php b/includes/API.php index 373f043..2a7e75f 100644 --- a/includes/API.php +++ b/includes/API.php @@ -238,6 +238,7 @@ public function rest_index( WP_REST_Response $response ): WP_REST_Response { $response->data['wp_version'] = get_bloginfo( 'version' ); $response->data['wc_version'] = WC()->version; $response->data['wcpos_version'] = VERSION; + $response->data['use_jwt_as_param'] = woocommerce_pos_get_settings( 'tools', 'use_jwt_as_param' ); return $response; } diff --git a/includes/Products.php b/includes/Products.php index 3414ee8..b96f719 100644 --- a/includes/Products.php +++ b/includes/Products.php @@ -27,7 +27,7 @@ public function __construct() { $pos_only_products = woocommerce_pos_get_settings( 'general', 'pos_only_products' ); if ( $pos_only_products ) { - add_filter( 'posts_where', array( $this, 'hide_pos_only_products' ), 10, 2 ); + add_action( 'pre_get_posts', array( $this, 'hide_pos_only_products' ) ); add_filter( 'woocommerce_variation_is_visible', array( $this, 'hide_pos_only_variations' ), 10, 4 ); add_action( 'woocommerce_store_api_validate_add_to_cart', array( $this, 'store_api_prevent_pos_only_add_to_cart' ) ); @@ -76,22 +76,26 @@ public function product_set_stock( WC_Product $product ): void { * * @return string */ - public function hide_pos_only_products( $where, $query ) { - // Ensure this only runs for the main WooCommerce shop queries - if ( ! is_admin() && $query->is_main_query() && ( is_shop() || is_product_category() || is_product_tag() ) ) { - global $wpdb; + public function hide_pos_only_products( $query ) { + // Ensure this only runs for the main WooCommerce queries on product-related pages + if ( ! is_admin() && $query->is_main_query() && ( is_shop() || is_product() || is_post_type_archive( 'product' ) || is_product_taxonomy() ) ) { $settings_instance = Settings::instance(); $settings = $settings_instance->get_pos_only_product_visibility_settings(); if ( isset( $settings['ids'] ) && ! empty( $settings['ids'] ) ) { - $exclude_ids = array_map( 'intval', (array) $settings['ids'] ); - $ids_format = implode( ',', array_fill( 0, count( $exclude_ids ), '%d' ) ); - $where .= $wpdb->prepare( " AND {$wpdb->posts}.ID NOT IN ($ids_format)", $exclude_ids ); + $exclude_ids = array_map( 'intval', (array) $settings['ids'] ); // Sanitize IDs as integers + + // Merge any existing excluded IDs with the new ones + $existing_excludes = $query->get( 'post__not_in' ); + if ( ! is_array( $existing_excludes ) ) { + $existing_excludes = array(); + } + + // Set the post__not_in query parameter to exclude specified IDs + $query->set( 'post__not_in', array_merge( $existing_excludes, $exclude_ids ) ); } } - - return $where; } /** diff --git a/package.json b/package.json index 0c5b91b..3bfea87 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wcpos/woocommerce-pos", - "version": "1.6.3", + "version": "1.6.4", "description": "A simple front-end for taking WooCommerce orders at the Point of Sale.", "main": "index.js", "workspaces": { diff --git a/readme.txt b/readme.txt index b12c56a..43f3448 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: kilbot Tags: ecommerce, point-of-sale, pos, inventory, woocommerce Requires at least: 5.6 Tested up to: 6.5 -Stable tag: 1.6.3 +Stable tag: 1.6.4 License: GPL-3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -80,6 +80,10 @@ There is more information on our website at [https://wcpos.com](https://wcpos.co == Changelog == += 1.6.4 - 2024/09/04 = +* Fix: POS Only Products appearing in the web store +* Fix: Disable wp_footer for POS Order Pay template + = 1.6.3 - 2024/06/29 = - Fix: Critical error preventing bulk update of products diff --git a/woocommerce-pos.php b/woocommerce-pos.php index 78996ed..64b4fd3 100644 --- a/woocommerce-pos.php +++ b/woocommerce-pos.php @@ -3,7 +3,7 @@ * Plugin Name: WooCommerce POS * Plugin URI: https://wordpress.org/plugins/woocommerce-pos/ * Description: A simple front-end for taking WooCommerce orders at the Point of Sale. Requires WooCommerce. - * Version: 1.6.3 + * Version: 1.6.4 * Author: kilbot * Author URI: http://wcpos.com * Text Domain: woocommerce-pos @@ -11,10 +11,10 @@ * License URI: http://www.gnu.org/licenses/gpl-3.0.txt * Domain Path: /languages * Requires at least: 5.6 - * Tested up to: 6.5 + * Tested up to: 6.6 * Requires PHP: 7.4 * Requires Plugins: woocommerce - * WC tested up to: 9.0 + * WC tested up to: 9.2 * WC requires at least: 5.3 * * @see http://wcpos.com @@ -24,7 +24,7 @@ namespace WCPOS\WooCommercePOS; // Define plugin constants. -const VERSION = '1.6.3'; +const VERSION = '1.6.4'; const PLUGIN_NAME = 'woocommerce-pos'; const SHORT_NAME = 'wcpos'; \define( __NAMESPACE__ . '\PLUGIN_FILE', plugin_basename( __FILE__ ) ); // 'woocommerce-pos/woocommerce-pos.php'