Skip to content

Commit 4bb69cf

Browse files
committed
Fix: POS Only Products appearing in the web store
1 parent 949c1a4 commit 4bb69cf

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

includes/API.php

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ public function rest_index( WP_REST_Response $response ): WP_REST_Response {
238238
$response->data['wp_version'] = get_bloginfo( 'version' );
239239
$response->data['wc_version'] = WC()->version;
240240
$response->data['wcpos_version'] = VERSION;
241+
$response->data['use_jwt_as_param'] = woocommerce_pos_get_settings( 'tools', 'use_jwt_as_param' );
241242

242243
return $response;
243244
}

includes/Products.php

+14-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct() {
2727
$pos_only_products = woocommerce_pos_get_settings( 'general', 'pos_only_products' );
2828

2929
if ( $pos_only_products ) {
30-
add_filter( 'posts_where', array( $this, 'hide_pos_only_products' ), 10, 2 );
30+
add_action( 'pre_get_posts', array( $this, 'hide_pos_only_products' ) );
3131
add_filter( 'woocommerce_variation_is_visible', array( $this, 'hide_pos_only_variations' ), 10, 4 );
3232
add_action( 'woocommerce_store_api_validate_add_to_cart', array( $this, 'store_api_prevent_pos_only_add_to_cart' ) );
3333

@@ -76,22 +76,26 @@ public function product_set_stock( WC_Product $product ): void {
7676
*
7777
* @return string
7878
*/
79-
public function hide_pos_only_products( $where, $query ) {
80-
// Ensure this only runs for the main WooCommerce shop queries
81-
if ( ! is_admin() && $query->is_main_query() && ( is_shop() || is_product_category() || is_product_tag() ) ) {
82-
global $wpdb;
79+
public function hide_pos_only_products( $query ) {
80+
// Ensure this only runs for the main WooCommerce queries on product-related pages
81+
if ( ! is_admin() && $query->is_main_query() && ( is_shop() || is_product() || is_post_type_archive( 'product' ) || is_product_taxonomy() ) ) {
8382

8483
$settings_instance = Settings::instance();
8584
$settings = $settings_instance->get_pos_only_product_visibility_settings();
8685

8786
if ( isset( $settings['ids'] ) && ! empty( $settings['ids'] ) ) {
88-
$exclude_ids = array_map( 'intval', (array) $settings['ids'] );
89-
$ids_format = implode( ',', array_fill( 0, count( $exclude_ids ), '%d' ) );
90-
$where .= $wpdb->prepare( " AND {$wpdb->posts}.ID NOT IN ($ids_format)", $exclude_ids );
87+
$exclude_ids = array_map( 'intval', (array) $settings['ids'] ); // Sanitize IDs as integers
88+
89+
// Merge any existing excluded IDs with the new ones
90+
$existing_excludes = $query->get( 'post__not_in' );
91+
if ( ! is_array( $existing_excludes ) ) {
92+
$existing_excludes = array();
93+
}
94+
95+
// Set the post__not_in query parameter to exclude specified IDs
96+
$query->set( 'post__not_in', array_merge( $existing_excludes, $exclude_ids ) );
9197
}
9298
}
93-
94-
return $where;
9599
}
96100

97101
/**

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wcpos/woocommerce-pos",
3-
"version": "1.6.3",
3+
"version": "1.6.4",
44
"description": "A simple front-end for taking WooCommerce orders at the Point of Sale.",
55
"main": "index.js",
66
"workspaces": {

readme.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: kilbot
33
Tags: ecommerce, point-of-sale, pos, inventory, woocommerce
44
Requires at least: 5.6
55
Tested up to: 6.5
6-
Stable tag: 1.6.3
6+
Stable tag: 1.6.4
77
License: GPL-3.0
88
License URI: http://www.gnu.org/licenses/gpl-3.0.html
99

@@ -80,6 +80,10 @@ There is more information on our website at [https://wcpos.com](https://wcpos.co
8080

8181
== Changelog ==
8282

83+
= 1.6.4 - 2024/09/04 =
84+
* Fix: POS Only Products appearing in the web store
85+
* Fix: Disable wp_footer for POS Order Pay template
86+
8387
= 1.6.3 - 2024/06/29 =
8488
- Fix: Critical error preventing bulk update of products
8589

woocommerce-pos.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
* Plugin Name: WooCommerce POS
44
* Plugin URI: https://wordpress.org/plugins/woocommerce-pos/
55
* Description: A simple front-end for taking WooCommerce orders at the Point of Sale. Requires <a href="http://wordpress.org/plugins/woocommerce/">WooCommerce</a>.
6-
* Version: 1.6.3
6+
* Version: 1.6.4
77
* Author: kilbot
88
* Author URI: http://wcpos.com
99
* Text Domain: woocommerce-pos
1010
* License: GPL-3.0+
1111
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
1212
* Domain Path: /languages
1313
* Requires at least: 5.6
14-
* Tested up to: 6.5
14+
* Tested up to: 6.6
1515
* Requires PHP: 7.4
1616
* Requires Plugins: woocommerce
17-
* WC tested up to: 9.0
17+
* WC tested up to: 9.2
1818
* WC requires at least: 5.3
1919
*
2020
* @see http://wcpos.com
@@ -24,7 +24,7 @@
2424
namespace WCPOS\WooCommercePOS;
2525

2626
// Define plugin constants.
27-
const VERSION = '1.6.3';
27+
const VERSION = '1.6.4';
2828
const PLUGIN_NAME = 'woocommerce-pos';
2929
const SHORT_NAME = 'wcpos';
3030
\define( __NAMESPACE__ . '\PLUGIN_FILE', plugin_basename( __FILE__ ) ); // 'woocommerce-pos/woocommerce-pos.php'

0 commit comments

Comments
 (0)