Skip to content

Commit a5e6458

Browse files
committed
v1.7.0
1 parent 009b295 commit a5e6458

File tree

7 files changed

+155
-13
lines changed

7 files changed

+155
-13
lines changed

includes/API/Customers_Controller.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ public function get_collection_params() {
112112
}
113113
}
114114

115+
// Add 'roles' filter, this allows us to filter by multiple roles.
116+
$params['roles'] = array(
117+
'description' => __( 'Filter customers by roles.', 'woocommerce-pos' ),
118+
'type' => 'array',
119+
'items' => array(
120+
'type' => 'string',
121+
),
122+
'required' => false,
123+
);
124+
115125
return $params;
116126
}
117127

@@ -490,6 +500,14 @@ public function wcpos_customer_query( array $prepared_args, WP_REST_Request $req
490500
add_action( 'pre_user_query', array( $this, 'wcpos_include_exclude_users_by_id' ) );
491501
}
492502

503+
// Filter by roles (this is a comma separated list of roles).
504+
if ( ! empty( $request['roles'] ) && is_array( $request['roles'] ) ) {
505+
$roles = array_map( 'sanitize_text_field', $request['roles'] );
506+
$prepared_args['role__in'] = $roles;
507+
// remove $prepared_args['role'] to prevent it from overriding $prepared_args['role__in']
508+
unset( $prepared_args['role'] );
509+
}
510+
493511
return $prepared_args;
494512
}
495513

includes/API/Orders_Controller.php

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,25 +370,40 @@ public function wcpos_validate_billing_email( WP_REST_Request $request ) {
370370
return true;
371371
}
372372

373-
374-
375373
/**
376374
* Modify the collection params.
377375
*/
378376
public function get_collection_params() {
379377
$params = parent::get_collection_params();
380378

381-
if ( isset( $params['per_page'] ) ) {
379+
// Ensure 'per_page' is an array and has a 'minimum' key
380+
if ( isset( $params['per_page'] ) && is_array( $params['per_page'] ) ) {
382381
$params['per_page']['minimum'] = -1;
383382
}
384383

385-
if ( isset( $params['orderby'] ) && \is_array( $params['orderby']['enum'] ) ) {
384+
// Ensure 'orderby' is an array and has an 'enum' key that is also an array
385+
if ( isset( $params['orderby'] ) && is_array( $params['orderby'] ) && isset( $params['orderby']['enum'] ) && is_array( $params['orderby']['enum'] ) ) {
386386
$params['orderby']['enum'] = array_merge(
387387
$params['orderby']['enum'],
388388
array( 'status', 'customer_id', 'payment_method', 'total' )
389389
);
390390
}
391391

392+
// Add 'pos_cashier' parameter
393+
$params['pos_cashier'] = array(
394+
'description' => __('Filter orders by POS cashier.', 'woocommerce-pos'),
395+
'type' => 'integer',
396+
'required' => false,
397+
);
398+
399+
// Add 'pos_store' parameter
400+
// @NOTE - this is different to 'store_id' which is the store the request was made from.
401+
$params['pos_store'] = array(
402+
'description' => __('Filter orders by POS store.', 'woocommerce-pos'),
403+
'type' => 'integer',
404+
'required' => false,
405+
);
406+
392407
return $params;
393408
}
394409

@@ -603,6 +618,22 @@ public function wcpos_shop_order_query( array $args, WP_REST_Request $request )
603618
}
604619
}
605620

621+
// Add 'pos_cashier' filter.
622+
if ( isset( $request['pos_cashier'] ) ) {
623+
$args['meta_query'][] = array(
624+
'key' => '_pos_user',
625+
'value' => $request['pos_cashier'],
626+
);
627+
}
628+
629+
// Add 'pos_store' filter.
630+
if ( isset( $request['pos_store'] ) ) {
631+
$args['meta_query'][] = array(
632+
'key' => '_pos_store',
633+
'value' => $request['pos_store'],
634+
);
635+
}
636+
606637
return $args;
607638
}
608639

includes/Templates/Frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function ( $store ) {
147147
*/
148148
$vars = apply_filters( 'woocommerce_pos_inline_vars', $vars );
149149
$initial_props = wp_json_encode( $vars );
150-
$dev_bundle = 'http://localhost:8081/index.bundle?platform=web&dev=true&hot=false';
150+
$dev_bundle = site_url( '/index.bundle?platform=web&dev=true&hot=false' );
151151

152152
/**
153153
* Add path to worker scripts

readme.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: kilbot
33
Tags: ecommerce, point-of-sale, pos, inventory, woocommerce
44
Requires at least: 5.6
5-
Tested up to: 6.5
6-
Stable tag: 1.6.6
5+
Tested up to: 6.7
6+
Stable tag: 1.7.0
77
License: GPL-3.0
88
License URI: http://www.gnu.org/licenses/gpl-3.0.html
99

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

8181
== Changelog ==
8282

83+
= 1.7.0 - 2024/11/13 =
84+
* Enhancement: Updated all React components to use modern standards (Tailwind, Radix UI), improving reliability and usability
85+
* Enhancement: Improved the local database query engine for a more responsive POS experience
86+
* Enhancement: Improved barcode scanning detection
87+
* Fix: Popover positioning issues
88+
* Fix: Customer search on Android devices
89+
* Fix: Quick discounts calculation bug affecting some users
90+
* Pro: New Reports page for End of Day Reporting (Z-Report)
91+
8392
= 1.6.6 - 2024/09/05 =
8493
* Fix: POS Only Products appearing in the POS 😓
8594

@@ -283,8 +292,8 @@ There is more information on our website at [https://wcpos.com](https://wcpos.co
283292

284293
== Upgrade Notice ==
285294

286-
= 1.5.0 =
295+
= 1.7.0 =
287296
**Important Update Notice:**
288-
We have made some significant changes to the local POS database in this update. To ensure a smooth transition, please consider updating your system when you have a quiet moment, such as outside of your busy sales hours. This will allow you to thoroughly test the new features and changes.
297+
We have made some significant changes to the User Interface. To ensure a smooth transition, please consider updating your system when you have a quiet moment, such as outside of your busy sales hours. This will allow you to thoroughly test the new features and changes.
289298

290299
For the latest updates and real-time information, please visit our community chat at [wcpos.com/discord](https://wcpos.com/discord).

tests/includes/API/Test_HPOS_Orders_Controller.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,4 +880,46 @@ public function test_create_order_with_decimal_quantity() {
880880

881881
$this->assertEquals( 'woocommerce-pos', $data['created_via'] );
882882
}
883+
884+
/**
885+
*
886+
*/
887+
public function test_filter_order_by_cashier() {
888+
$order1 = OrderHelper::create_order();
889+
$order2 = OrderHelper::create_order();
890+
$order2->add_meta_data( '_pos_user', 4, true );
891+
$order2->save();
892+
893+
$request = $this->wp_rest_get_request( '/wcpos/v1/orders' );
894+
$request->set_param( 'pos_cashier', 4 );
895+
896+
$response = $this->server->dispatch( $request );
897+
$data = $response->get_data();
898+
$this->assertEquals( 200, $response->get_status() );
899+
$this->assertEquals( 1, \count( $data ) );
900+
901+
$ids = wp_list_pluck( $data, 'id' );
902+
$this->assertEquals( array( $order2->get_id() ), $ids );
903+
}
904+
905+
/**
906+
*
907+
*/
908+
public function test_filter_order_by_store() {
909+
$order1 = OrderHelper::create_order();
910+
$order2 = OrderHelper::create_order();
911+
$order2->add_meta_data( '_pos_store', 64, true );
912+
$order2->save();
913+
914+
$request = $this->wp_rest_get_request( '/wcpos/v1/orders' );
915+
$request->set_param( 'pos_store', 64 );
916+
917+
$response = $this->server->dispatch( $request );
918+
$data = $response->get_data();
919+
$this->assertEquals( 200, $response->get_status() );
920+
$this->assertEquals( 1, \count( $data ) );
921+
922+
$ids = wp_list_pluck( $data, 'id' );
923+
$this->assertEquals( array( $order2->get_id() ), $ids );
924+
}
883925
}

tests/includes/API/Test_Orders_Controller.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,4 +832,46 @@ public function test_create_order_with_decimal_quantity() {
832832

833833
$this->assertEquals( 'woocommerce-pos', $data['created_via'] );
834834
}
835+
836+
/**
837+
*
838+
*/
839+
public function test_filter_order_by_cashier() {
840+
$order1 = OrderHelper::create_order();
841+
$order2 = OrderHelper::create_order();
842+
$order2->add_meta_data( '_pos_user', 4, true );
843+
$order2->save();
844+
845+
$request = $this->wp_rest_get_request( '/wcpos/v1/orders' );
846+
$request->set_param( 'pos_cashier', 4 );
847+
848+
$response = $this->server->dispatch( $request );
849+
$data = $response->get_data();
850+
$this->assertEquals( 200, $response->get_status() );
851+
$this->assertEquals( 1, \count( $data ) );
852+
853+
$ids = wp_list_pluck( $data, 'id' );
854+
$this->assertEquals( array( $order2->get_id() ), $ids );
855+
}
856+
857+
/**
858+
*
859+
*/
860+
public function test_filter_order_by_store() {
861+
$order1 = OrderHelper::create_order();
862+
$order2 = OrderHelper::create_order();
863+
$order2->add_meta_data( '_pos_store', 64, true );
864+
$order2->save();
865+
866+
$request = $this->wp_rest_get_request( '/wcpos/v1/orders' );
867+
$request->set_param( 'pos_store', 64 );
868+
869+
$response = $this->server->dispatch( $request );
870+
$data = $response->get_data();
871+
$this->assertEquals( 200, $response->get_status() );
872+
$this->assertEquals( 1, \count( $data ) );
873+
874+
$ids = wp_list_pluck( $data, 'id' );
875+
$this->assertEquals( array( $order2->get_id() ), $ids );
876+
}
835877
}

woocommerce-pos.php

Lines changed: 4 additions & 4 deletions
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.6
6+
* Version: 1.7.0
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.6
14+
* Tested up to: 6.7
1515
* Requires PHP: 7.4
1616
* Requires Plugins: woocommerce
17-
* WC tested up to: 9.2
17+
* WC tested up to: 9.4
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.6';
27+
const VERSION = '1.7.0';
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)