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.

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.
| Comment | File | Size | Author |
|---|---|---|---|
| product_restrictions_error.png | 114.79 KB | jordan.caldwell |
Issue fork commerce-3510759
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:
Issue fork commerce_shipping-3510759
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:
- 3510759-unable-to-save
compare
Comments
Comment #2
jordan.caldwell commentedComment #3
alex.bukach commentedIt seems to be a common Commerce issue, see Cannot remove conditions if you remove required field values first.
Comment #4
alex.bukach commentedIt seems to be a general Commerce issue related to how Commerce condition checkboxes are handled on AJAX.
Comment #5
alex.bukach commentedOops, wrong project.
Comment #8
alex.bukach commentedComment #9
jsacksick commented@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.
Comment #10
alex.bukach commentedYes @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.
Comment #11
jsacksick commentedI 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!