Skip to content

Hide fully-cartoned shipments on the admin order page (#3357)#6463

Draft
luwiee wants to merge 1 commit intosolidusio:mainfrom
luwiee:fix/3357-shipment-dedup
Draft

Hide fully-cartoned shipments on the admin order page (#3357)#6463
luwiee wants to merge 1 commit intosolidusio:mainfrom
luwiee:fix/3357-shipment-dedup

Conversation

@luwiee
Copy link
Copy Markdown

@luwiee luwiee commented Apr 26, 2026

Summary

Closes #3357.

The admin order edit page renders a "Shipped package from 'X'" legend twice for fully-shipped orders: once from the Carton partial and once from the Shipment partial that the carton was created from. The reporter's screenshot shows the visual confusion this causes — admins see two rows that look like distinct packages but represent the same items.

Approach

The Shipment partial already filters its manifest to inventory units with carton_id IS NULL. When that filter returns an empty list (i.e., every inventory unit has been moved into a Carton), the partial has nothing meaningful left to show:

  • no items to display in the manifest table,
  • no "Ship" action to expose (the shipment is already shipped),
  • no tracking — that authoritatively lives on the Carton.

So this PR skips rendering the Shipment partial entirely in that case. The Carton partial remains the single source of truth for fully-shipped packages, and in-progress shipments (with any non-cartoned units) render unchanged.

Test

Added a non-JS feature spec:

Shipments
  an order whose units have all been moved into a carton
    does not render the now-empty shipment alongside the carton

Verified the spec fails on main with the exact symptom reported in #3357 ("H... - Shipped package from 'NY Warehouse'" matching [data-hook='admin_shipment_form']) and passes with the fix applied. Existing shipment specs continue to pass.

Trade-offs / alternatives considered

  • Filter at the call site (_form.html.erb) instead of inside the partial — rejected because it would either trigger N+1 (shipments.select { |s| s.inventory_units.where(carton_id: nil).any? }) or push a more complex SQL filter into the view. Skipping render at the partial boundary keeps the change local and avoids any query restructuring.
  • A larger refactor along the lines of [RFC] Nest carton into shipment view #4319 (RFC: nest cartons under shipments, possibly extract cartons into their own admin tab) — out of scope for a bug fix; this PR is intentionally minimal so the visible duplication can ship without waiting on a product decision about cartons.

Out of scope

  • The Carton partial still has its own quirks (e.g., it doesn't show special-instructions like the Shipment partial does) — left untouched.
  • No i18n changes.

Cartons and Shipments both render a "Shipped package from 'X'"
legend on the admin order edit page. When all of a shipment's
inventory units have been moved into a Carton (i.e., the shipment is
fully shipped), both partials render against the same data, producing
a duplicate row that confuses admins (solidusio#3357).

The Shipment partial already filters its manifest items to inventory
units with `carton_id IS NULL`. When that filter returns an empty
list, the partial has nothing meaningful to show: there is no
"Ship" action to expose, no items to display, and no tracking — the
authoritative shipped state lives on the Carton.

Skip rendering the partial entirely in that case. The Carton partial
remains the single source of truth for fully shipped packages, and
in-progress shipments (with any non-cartoned inventory units) render
unchanged.
@github-actions github-actions Bot added the changelog:solidus_backend Changes to the solidus_backend gem label Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_backend Changes to the solidus_backend gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cartons vs Shipments admin UI

1 participant