You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Staff who could only manage discounts hit a stack of "you need one of the
following permissions: MANAGE_PRODUCTS" errors as soon as a voucher opened.
Nothing changed on the API side; the dashboard was asking for a product-gated
field on a discounts page.
Two causes:
- The voucher detail and create views mounted the assign-product and
assign-variant searches on page load, every picker closed. SearchProduct
selects Product.channelListings, which Core gates behind MANAGE_PRODUCTS.
Long-standing, but error toasts became sticky in #6812 so it turned loud.
- The Eligible products accordion requested the same field, and #6812 made the
catalogue auto-open the first non-empty group instead of always defaulting to
Categories, so vouchers with assigned products hit it on load.
Gate the field with @include(if: $PERMISSION_MANAGE_PRODUCTS) — makeQuery
already injects a PERMISSION_<CODE> variable per query from the signed-in
user's permissions, as CustomerDetails does for MANAGE_ORDERS. The catalogue
mutations get it passed explicitly since makeMutation does not inject.
SearchProducts declares it with a default so makeSearch callers, which do not
strip PERMISSION_* from their variable types, need no changes.
Where availability is unknowable, drop the feature rather than fake a value:
the assign picker stops filtering by voucher channels, disabling rows and
showing the unavailable hint, and the Eligible products table drops its
Availability column. Also fixes the same latent bug on shipping rates and
collections, where a user without MANAGE_PRODUCTS saw an empty picker because
every product looked channel-mismatched.
Also skip the four picker searches until their dialog opens, so opening a
voucher no longer fires four catalog queries, one asking for 100 products.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Vouchers no longer demand the MANAGE_PRODUCTS permission. Staff who could only manage discounts were met with a stack of "you need one of the following permissions: MANAGE_PRODUCTS" errors as soon as a voucher opened.
6
+
7
+
Two things caused it. The voucher page ran the assign-product and assign-variant picker searches on page load, with every picker closed — those searches now wait until their dialog is opened. And product channel availability, which does require MANAGE_PRODUCTS, was requested unconditionally — it is now requested only when the signed-in user can actually read it.
8
+
9
+
Staff without MANAGE_PRODUCTS see the Eligible products list without its Availability column, and the assign-product picker no longer filters by voucher channels, since it cannot know which channels a product is in. Nothing changes for staff who do have the permission.
10
+
11
+
Opening a voucher is also lighter: four catalog searches no longer fire on every page load.
0 commit comments