Shipment::postDelete deleting profiles that exist for other Shipments

Created on 6 September 2023, over 1 year ago

Problem/Motivation

The Shipment::postDelete() method deletes the associated Shipping Profiles automatically. This is great except when the same profile is used for multiple Shipments.

Steps to reproduce

Create an order with multiple order items and pack it to multiple Shipments. We do this through Commerce API + Custom Shipment Packer, but it can be done manually as well. Remove an order item from the order, which triggers repacking down to a single Shipment. The shipment related to the deleted order item is deleted, which then deletes the associated shipping profile. This breaks the still-existing shipment on the order due to it's now-missing profile.

Proposed resolution

Before deleting shipping profiles in Shipment::postDelete(), check for any other shipments in the system using the same profile.

Remaining tasks

See MR patch.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States alexandersluiter

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

Comments & Activities

Production build 0.71.5 2024