Non draft orders are refreshed when editing shipments

Created on 20 December 2022, over 2 years ago
Updated 17 January 2023, about 2 years ago

Problem/Motivation

Whenever a shipment is added, edited, or removed the order is refreshed
https://git.drupalcode.org/project/commerce_shipping/-/blob/8.x-2.x/src/...

While this is fine for draft orders and carts it can lead to data loss when the order is refreshed for placed orders. Placed orders should not change unless expressly done by an administrator. The order refresh causes line item prices to be updated, promotions to be reevaluated, taxes recalculated.

When shipments are changed there are three things that do need to happen on placed orders:

  1. The shipping adjustment total on the order needs to be updated to reflect the total cost of the shipments
  2. The shipping promotions need to be recalculated. Other promotions need to remain untouched.
  3. The tax for shipping, if applicable, needs to be recalculated and an event fired for any tax integrations to subscribe to

Steps to reproduce

Add, edit, or delete a shipment using the Shipments tab UI in the order administration area after an order has already been placed.

Proposed resolution

Trigger a shipping specific order refresh on non draft orders.

Possible ways of doing this:
Call the provided functions that commerce_shipping defines for the order refresh to only refresh shipping specific parts of the order. Probably the wrong way.

Provide a shipment refresh service that handles the refresh similar to the core one but skips anything that is not related to shipping.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

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.

Production build 0.71.5 2024