Skip to content

Commit

Permalink
for fix tax rates permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Jan 12, 2024
1 parent e49de80 commit e2fed81
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
18 changes: 18 additions & 0 deletions includes/API/Taxes_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions woocommerce-pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="http://wordpress.org/plugins/woocommerce/">WooCommerce</a>.
* Version: 1.4.1
* Version: 1.4.2
* Author: kilbot
* Author URI: http://wcpos.com
* Text Domain: woocommerce-pos
Expand All @@ -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'
Expand Down

0 comments on commit e2fed81

Please sign in to comment.