Problem/Motivation

We are unable to save a shipping method that contained a deleted Product as part of the shipping method's match criteria. Unchecking "Order Products" completely still prevents the form from being saved with an error: "Products field is required".

We did identify a workaround for this by resaving a valid product reference in the match criteria. After a successful save we were able to uncheck "Order Products" and save again.

Product restrictions form

Steps to reproduce

  • Create a shipping method that has a product restriction:
    • Check "Order products"
    • Select "Order contains none of the following products"
    • Add a single reference to a valid Product
    • Select any other valid criteria under the Product restriction such as "Order contains product types"
  • Save the Shipping Method
  • Delete the product that was referenced
  • Edit the shipping method that was previously created
  • See that there are no products referenced under "Order contains none of the following products"
  • Uncheck "Order Products"
  • Attempt to save the shipping method
  • An error will prevent form from saving: Products field is required

Proposed resolution

Fix the validation issue preventing the form from saving when a user unchecks Order Products.

CommentFileSizeAuthor
product_restrictions_error.png114.79 KBjordan.caldwell

Issue fork commerce-3510759

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:

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:

    1 hidden branch
  • 3510759-unable-to-save Comparecompare

Comments

jordan.caldwell created an issue. See original summary.

jordan.caldwell’s picture

Issue summary: View changes
alex.bukach’s picture

It seems to be a common Commerce issue, see Cannot remove conditions if you remove required field values first.

alex.bukach’s picture

Project: Commerce Shipping » Commerce
Assigned: Unassigned » alex.bukach

It seems to be a general Commerce issue related to how Commerce condition checkboxes are handled on AJAX.

alex.bukach’s picture

Project: Commerce » Commerce Core
Version: 8.x-2.x-dev » 3.1.0
Component: Code » Documentation

Oops, wrong project.

alex.bukach changed the visibility of the branch 3510759-unable-to-save to hidden.

alex.bukach’s picture

Version: 3.1.0 » 3.x-dev
Assigned: alex.bukach » Unassigned
Status: Active » Needs review
jsacksick’s picture

@alex.bukach: Can you explain what we're changing exactly? The validation is now skipped if the condition is unchecked... or? Not fully clear by just looking at the code change.

alex.bukach’s picture

Yes @jsacksick, the validation of a plugin configuration is now skipped if the plugin checkbox is unchecked as the respective configuration is not added to the form. Previously a condition was considered as "enabled" based on the default value even if a user disabled it before submitting a form.

jsacksick’s picture

Component: Documentation » User experience
Status: Needs review » Fixed

I tried merging from the issue to give credits to multiple people but that didn't work. Merged from the MR but that didn't edit the commit message... Anyway... Thanks for this!

Status: Fixed » Closed (fixed)

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