diff --git a/includes/API/Taxes_Controller.php b/includes/API/Taxes_Controller.php index 5a13ac4..c03fad1 100644 --- a/includes/API/Taxes_Controller.php +++ b/includes/API/Taxes_Controller.php @@ -39,12 +39,30 @@ class Taxes_Controller extends WC_REST_Taxes_Controller { */ public function __construct() { add_filter( 'woocommerce_pos_rest_dispatch_taxes_request', array( $this, 'wcpos_dispatch_request' ), 10, 4 ); + add_filter( 'woocommerce_rest_check_permissions', array( $this, 'check_permissions' ) ); if ( method_exists( parent::class, '__construct' ) ) { parent::__construct(); } } + /** + * Check if the current user can view the taxes. + * Note: WC REST API currently requires manage_woocommerce capability to access the endpoint (even for read only). + * This would stop the Cashier role from being able to view the taxes, so we check for read_private_products instead. + * + * @param mixed $permission + * + * @return bool + */ + public function check_permissions( $permission ) { + if ( ! $permission ) { + return current_user_can( 'read_private_products' ); + } + + return $permission; + } + /** * Dispatch request to parent controller, or override if needed. * diff --git a/readme.txt b/readme.txt index cf51bd1..8ec7ec4 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: kilbot Tags: cart, e-commerce, ecommerce, inventory, point-of-sale, pos, sales, sell, shop, shopify, store, vend, woocommerce, wordpress-ecommerce Requires at least: 5.6 & WooCommerce 5.3 Tested up to: 6.4 -Stable tag: 1.4.1 +Stable tag: 1.4.2 License: GPL-3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -63,6 +63,9 @@ There is more information on our website at [https://wcpos.com](https://wcpos.co == Changelog == += 1.4.2 - 2024/01/12 = +* Urgent Fix: users with role 'cashier' unable to access tax rates API + = 1.4.1 - 2024/01/12 = * No change, just messed up the release to WordPress.org diff --git a/woocommerce-pos.php b/woocommerce-pos.php index ae99c6b..a80cd81 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.4.1 + * Version: 1.4.2 * Author: kilbot * Author URI: http://wcpos.com * Text Domain: woocommerce-pos @@ -22,7 +22,7 @@ namespace WCPOS\WooCommercePOS; // Define plugin constants. -const VERSION = '1.4.1'; +const VERSION = '1.4.2'; const PLUGIN_NAME = 'woocommerce-pos'; const SHORT_NAME = 'wcpos'; \define( __NAMESPACE__ . '\PLUGIN_FILE', plugin_basename( __FILE__ ) ); // 'woocommerce-pos/woocommerce-pos.php'