Problem/Motivation

The default shipping method plugin base class enforces in its form validation that the chosen shipment workflow must have a Finalize and a Cancel transition. This is not always the case; for example, fulfillment may not happen within Drupal and shipment states are not utilized at all i.e. never transitioned, or fulfillment happens outside of Drupal and they are synced back to Drupal but they are either completed (shipped) or cancel i.e. Drupal is not concerned with the intermediate Ready state, or for whatever reason the site has a custom workflow that does not require a Finalize and/or a Cancel transition.

The validation method could be overridden in the shipping method, however the issue is that the shipping method might not be directly connected to the shipment workflow. For example, the Flat Rate plugin defines a shipping method that is only concerned with providing the price for the order's shipping adjustment; it is not concerned with what is the fulfillment process. Then another module (contrib or custom) defines the shipment workflow that is relevant to the store's fulfillment process that might not have a Finalize and or Cancel transition.

In my case I could manipulate the form validation using a hook, but I feel that's not the right way generally speaking. Why does the validation happen in the first place, is it assumed to exist somewhere else in Commerce Shipping? The shipping method should not validate the shipment workflow since, as demonstrated in the given example, they can be independent.

Steps to reproduce

Create a custom shipment workflow that does not have a Finalize transition. Create or Edit a shipping method and select that workflow, submit.

Proposed resolution

Remove the relevant validation from the base shipping method plugin.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

krystalcode created an issue. See original summary.

krystalcode’s picture

mistrae’s picture

Thanks for the patch. We do not need the finalize transition either.

anybody’s picture

Status: Active » Needs review
jsacksick’s picture

Status: Needs review » Needs work

I'm not necessarily against this. However the change is insufficient as is. Please open an MR as the tests are for sure failing with this change. We also have an order subscriber finalizing the shipments when an order is completed, that code potentially needs to change as well.

jsacksick’s picture

Version: 8.x-2.x-dev » 3.x-dev

tbkot made their first commit to this issue’s fork.

tbkot’s picture

Status: Needs work » Needs review

We should not have issues with the OrderSubscriber, as it checks if the transition is allowed.

jsacksick’s picture

Title: The Default workflow does not have a "Finalize" transition. » Disable validation for missing 'finalize' and 'cancel' transitions
Category: Bug report » Feature request

  • jsacksick committed 68123df0 on 3.x authored by tbkot
    feat: #3179317 Disable validation for missing 'finalize' and 'cancel'...
jsacksick’s picture

Status: Needs review » Fixed

Merged, thank you Dmytrii!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.