Skip to content

Commit

Permalink
v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Nov 13, 2024
1 parent 009b295 commit a5e6458
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 13 deletions.
18 changes: 18 additions & 0 deletions includes/API/Customers_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ public function get_collection_params() {
}
}

// Add 'roles' filter, this allows us to filter by multiple roles.
$params['roles'] = array(
'description' => __( 'Filter customers by roles.', 'woocommerce-pos' ),
'type' => 'array',
'items' => array(
'type' => 'string',
),
'required' => false,
);

return $params;
}

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

// Filter by roles (this is a comma separated list of roles).
if ( ! empty( $request['roles'] ) && is_array( $request['roles'] ) ) {
$roles = array_map( 'sanitize_text_field', $request['roles'] );
$prepared_args['role__in'] = $roles;
// remove $prepared_args['role'] to prevent it from overriding $prepared_args['role__in']
unset( $prepared_args['role'] );
}

return $prepared_args;
}

Expand Down
39 changes: 35 additions & 4 deletions includes/API/Orders_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,25 +370,40 @@ public function wcpos_validate_billing_email( WP_REST_Request $request ) {
return true;
}



/**
* Modify the collection params.
*/
public function get_collection_params() {
$params = parent::get_collection_params();

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

if ( isset( $params['orderby'] ) && \is_array( $params['orderby']['enum'] ) ) {
// Ensure 'orderby' is an array and has an 'enum' key that is also an array
if ( isset( $params['orderby'] ) && is_array( $params['orderby'] ) && isset( $params['orderby']['enum'] ) && is_array( $params['orderby']['enum'] ) ) {
$params['orderby']['enum'] = array_merge(
$params['orderby']['enum'],
array( 'status', 'customer_id', 'payment_method', 'total' )
);
}

// Add 'pos_cashier' parameter
$params['pos_cashier'] = array(
'description' => __('Filter orders by POS cashier.', 'woocommerce-pos'),
'type' => 'integer',
'required' => false,
);

// Add 'pos_store' parameter
// @NOTE - this is different to 'store_id' which is the store the request was made from.
$params['pos_store'] = array(
'description' => __('Filter orders by POS store.', 'woocommerce-pos'),
'type' => 'integer',
'required' => false,
);

return $params;
}

Expand Down Expand Up @@ -603,6 +618,22 @@ public function wcpos_shop_order_query( array $args, WP_REST_Request $request )
}
}

// Add 'pos_cashier' filter.
if ( isset( $request['pos_cashier'] ) ) {
$args['meta_query'][] = array(
'key' => '_pos_user',
'value' => $request['pos_cashier'],
);
}

// Add 'pos_store' filter.
if ( isset( $request['pos_store'] ) ) {
$args['meta_query'][] = array(
'key' => '_pos_store',
'value' => $request['pos_store'],
);
}

return $args;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Templates/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function ( $store ) {
*/
$vars = apply_filters( 'woocommerce_pos_inline_vars', $vars );
$initial_props = wp_json_encode( $vars );
$dev_bundle = 'http://localhost:8081/index.bundle?platform=web&dev=true&hot=false';
$dev_bundle = site_url( '/index.bundle?platform=web&dev=true&hot=false' );

/**
* Add path to worker scripts
Expand Down
17 changes: 13 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: kilbot
Tags: ecommerce, point-of-sale, pos, inventory, woocommerce
Requires at least: 5.6
Tested up to: 6.5
Stable tag: 1.6.6
Tested up to: 6.7
Stable tag: 1.7.0
License: GPL-3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html

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

== Changelog ==

= 1.7.0 - 2024/11/13 =
* Enhancement: Updated all React components to use modern standards (Tailwind, Radix UI), improving reliability and usability
* Enhancement: Improved the local database query engine for a more responsive POS experience
* Enhancement: Improved barcode scanning detection
* Fix: Popover positioning issues
* Fix: Customer search on Android devices
* Fix: Quick discounts calculation bug affecting some users
* Pro: New Reports page for End of Day Reporting (Z-Report)

= 1.6.6 - 2024/09/05 =
* Fix: POS Only Products appearing in the POS 😓

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

== Upgrade Notice ==

= 1.5.0 =
= 1.7.0 =
**Important Update Notice:**
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.
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.

For the latest updates and real-time information, please visit our community chat at [wcpos.com/discord](https://wcpos.com/discord).
42 changes: 42 additions & 0 deletions tests/includes/API/Test_HPOS_Orders_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,4 +880,46 @@ public function test_create_order_with_decimal_quantity() {

$this->assertEquals( 'woocommerce-pos', $data['created_via'] );
}

/**
*
*/
public function test_filter_order_by_cashier() {
$order1 = OrderHelper::create_order();
$order2 = OrderHelper::create_order();
$order2->add_meta_data( '_pos_user', 4, true );
$order2->save();

$request = $this->wp_rest_get_request( '/wcpos/v1/orders' );
$request->set_param( 'pos_cashier', 4 );

$response = $this->server->dispatch( $request );
$data = $response->get_data();
$this->assertEquals( 200, $response->get_status() );
$this->assertEquals( 1, \count( $data ) );

$ids = wp_list_pluck( $data, 'id' );
$this->assertEquals( array( $order2->get_id() ), $ids );
}

/**
*
*/
public function test_filter_order_by_store() {
$order1 = OrderHelper::create_order();
$order2 = OrderHelper::create_order();
$order2->add_meta_data( '_pos_store', 64, true );
$order2->save();

$request = $this->wp_rest_get_request( '/wcpos/v1/orders' );
$request->set_param( 'pos_store', 64 );

$response = $this->server->dispatch( $request );
$data = $response->get_data();
$this->assertEquals( 200, $response->get_status() );
$this->assertEquals( 1, \count( $data ) );

$ids = wp_list_pluck( $data, 'id' );
$this->assertEquals( array( $order2->get_id() ), $ids );
}
}
42 changes: 42 additions & 0 deletions tests/includes/API/Test_Orders_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,4 +832,46 @@ public function test_create_order_with_decimal_quantity() {

$this->assertEquals( 'woocommerce-pos', $data['created_via'] );
}

/**
*
*/
public function test_filter_order_by_cashier() {
$order1 = OrderHelper::create_order();
$order2 = OrderHelper::create_order();
$order2->add_meta_data( '_pos_user', 4, true );
$order2->save();

$request = $this->wp_rest_get_request( '/wcpos/v1/orders' );
$request->set_param( 'pos_cashier', 4 );

$response = $this->server->dispatch( $request );
$data = $response->get_data();
$this->assertEquals( 200, $response->get_status() );
$this->assertEquals( 1, \count( $data ) );

$ids = wp_list_pluck( $data, 'id' );
$this->assertEquals( array( $order2->get_id() ), $ids );
}

/**
*
*/
public function test_filter_order_by_store() {
$order1 = OrderHelper::create_order();
$order2 = OrderHelper::create_order();
$order2->add_meta_data( '_pos_store', 64, true );
$order2->save();

$request = $this->wp_rest_get_request( '/wcpos/v1/orders' );
$request->set_param( 'pos_store', 64 );

$response = $this->server->dispatch( $request );
$data = $response->get_data();
$this->assertEquals( 200, $response->get_status() );
$this->assertEquals( 1, \count( $data ) );

$ids = wp_list_pluck( $data, 'id' );
$this->assertEquals( array( $order2->get_id() ), $ids );
}
}
8 changes: 4 additions & 4 deletions woocommerce-pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
* 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 <a href="http://wordpress.org/plugins/woocommerce/">WooCommerce</a>.
* Version: 1.6.6
* Version: 1.7.0
* Author: kilbot
* Author URI: http://wcpos.com
* Text Domain: woocommerce-pos
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Domain Path: /languages
* Requires at least: 5.6
* Tested up to: 6.6
* Tested up to: 6.7
* Requires PHP: 7.4
* Requires Plugins: woocommerce
* WC tested up to: 9.2
* WC tested up to: 9.4
* WC requires at least: 5.3
*
* @see http://wcpos.com
Expand All @@ -24,7 +24,7 @@
namespace WCPOS\WooCommercePOS;

// Define plugin constants.
const VERSION = '1.6.6';
const VERSION = '1.7.0';
const PLUGIN_NAME = 'woocommerce-pos';
const SHORT_NAME = 'wcpos';
\define( __NAMESPACE__ . '\PLUGIN_FILE', plugin_basename( __FILE__ ) ); // 'woocommerce-pos/woocommerce-pos.php'
Expand Down

0 comments on commit a5e6458

Please sign in to comment.