Skip to content

Commit

Permalink
Fix #454
Browse files Browse the repository at this point in the history
  • Loading branch information
kawsarahmedr committed Dec 3, 2024
1 parent 5e124f6 commit f4107ee
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions includes/Admin/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public function add_order_action( $actions ) {
* @since 1.0.0
*/
public function handle_order_action( $order ) {
// Must have manage woocommerce user capability role to access this endpoint.
if ( ! current_user_can( 'manage_woocommerce' ) ) { // phpcs:ignore WordPress.WP.Capabilities.Unknown
WCSN()->add_notice( __( 'You do not have permission to perform this action.', 'wc-serial-numbers' ), 'error' );
wp_safe_redirect( wp_get_referer() );
exit;
}

$order_id = $order->get_id();
$action = current_action();
$action = str_replace( 'woocommerce_order_action_', '', $action );
Expand Down Expand Up @@ -197,6 +204,13 @@ public function add_order_bulk_action( $actions ) {
* @return string
*/
public function handle_order_bulk_action( $redirect_to, $action, $order_ids ) {
// Must have manage woocommerce user capability role to access this endpoint.
if ( ! current_user_can( 'manage_woocommerce' ) ) { // phpcs:ignore WordPress.WP.Capabilities.Unknown
WCSN()->add_notice( __( 'You do not have permission to perform this action.', 'wc-serial-numbers' ), 'error' );
wp_safe_redirect( wp_get_referer() );
exit;
}

if ( in_array( $action, array( 'wcsn_add_keys', 'wcsn_remove_keys' ), true ) ) {
foreach ( $order_ids as $order_id ) {
switch ( $action ) {
Expand Down

0 comments on commit f4107ee

Please sign in to comment.