| @@ -10,8 +10,9 @@ | ||
| 10 | 10 | |
| 11 | 11 | namespace WCPOS\WooCommercePOS\Templates; |
| 12 | 12 | |
| 13 | 13 | use WCPOS\WooCommercePOS\Services\Auth; |
| 14 | +use WCPOS\WooCommercePOS\Services\Cashier; | |
| 14 | 15 | use WCPOS\WooCommercePOS\Services\Lifecycle_Events; |
| 15 | 16 | use WCPOS\WooCommercePOS\Services\Settings; |
| 16 | 17 | use WCPOS\WooCommercePOS\Sync\Pos_Uuid; |
| 17 | 18 | use WCPOS\WooCommercePOS\Template_Router; |
| @@ -53,11 +54,11 @@ | ||
| 53 | 54 | auth_redirect(); |
| 54 | 55 | } |
| 55 | 56 | |
| 56 | 57 | // check privileges. |
| 57 | - if ( ! current_user_can( 'access_woocommerce_pos' ) ) { | |
| 58 | - // translators: Authorization error shown when a logged-in user lacks permission to open the POS page. | |
| 59 | - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'woocommerce-pos' ) ); | |
| 58 | + $user = wp_get_current_user(); | |
| 59 | + if ( ! Cashier::instance()->can_open_pos( $user ) ) { | |
| 60 | + wp_die( esc_html( Cashier::instance()->missing_pos_capabilities_message( $user ) ), '', array( 'response' => 403 ) ); | |
| 60 | 61 | } |
| 61 | 62 | |
| 62 | 63 | // disable cache plugins. |
| 63 | 64 | $this->no_cache(); |