Administer store orders permission

Created on 4 January 2018, almost 7 years ago
Updated 24 November 2023, about 1 year ago

As a customer, you get the "View own orders" permission,
As an admin, you get "Administer orders".

For a site with multiple stores with different owners, we need an "Administer store orders". This should check the owner field on stores, and allow that user access to view/edit orders for that store.

✨ Feature request
Status

Needs work

Version

2.0

Component

Order

Created by

πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡­Switzerland megadesk3000

    The patch in 33 has a problem together with drupal 10.1 since the line
    $store_ids = \Drupal::entityTypeManager()->getStorage('commerce_store')->getQuery()->condition('uid', $account->id())->accessCheck()->execute();
    is missing the mandatory access check.

    I add a patch that fixes that.

  • πŸ‡¨πŸ‡­Switzerland megadesk3000

    Found another missing access check in the original patch and fixed it.

  • I think this should be done using 🌱 [Meta, Plan] Pitch-Burgh: Policy based access in core Active .
    The description of the Flexible permissions β†’ module mentions twice this case, permissions for Commerce stores

  • πŸ‡ΊπŸ‡ΈUnited States bradhawkins

    I ran into some issues with patches 30-34. The patches caused an "InvalidQueryException" error whenever a non-store owner (i.e. a regular user) tried to access their orders via JSON API.

    Here's an example of the error produced:
    Drupal\Core\Database\InvalidQueryException: Query condition 'commerce_order_2.store_id IN ()' cannot be empty. in Drupal\Core\Database\Query\Condition->condition() (line 117 of /app/web/core/lib/Drupal/Core/Database/Query/Condition.php).

    I've updated patch 34 to include some if statements to check if $store_ids is empty before continuing.

  • Status changed to Needs review 3 months ago
  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    #36 seems to do the trick so far :). Thanks everyone for the great work. I think this should be ready for review?

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    I just found out that the "View orders in own store" permission is not working. Store owners can't view their orders (in a multi-store setup).

Production build 0.71.5 2024