Problem/Motivation

It would be nice if we added a negate checkbox to wrap each condition. This allow for more complex conditions and would solve a lot of use cases where they are needed. This seems to be a recurring need in the commerce issue que. See this issue for example

Proposed resolution

Make it happen.

CommentFileSizeAuthor
#3 Screenshot (227).png25.68 KBtonytheferg
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

tonytheferg created an issue. See original summary.

tonytheferg’s picture

tonytheferg’s picture

StatusFileSize
new25.68 KB

We could start by adding a validation column in the table in ConditionsTable.php @ namespace Drupal\commerce_conditions_plus\Element;,

    $element['condition_plugins'] = [
      '#type' => 'table',
      '#header' => [
        ['data' => t('Condition name'), 'colspan' => 3],
        t('Settings'),
        t('Weight'),
+        t('Validation'),
        t('Operations'),
      ],
      '#tabledrag' => [
        [
          'action' => 'order',
          'relationship' => 'sibling',
          'group' => 'condition-order-weight',
        ],
      ],

And then add the wrapper and checkbox

      $condition_form['negate_wrapper'] = [
        '#type' => 'container',
        '#title' => t('Negate'),
      ];
      $condition_form['negate_wrapper']['negate'] = [
        '#type' => 'checkbox',
        '#title' => t('Negate condition'),
      ];

screenshot of table

Of course the difficult part is figuring our how to tap into commerce core conditions and negate any condition.

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

mglaman’s picture

Status: Active » Needs review

  • mglaman committed df28875 on 1.0.x
    Issue #3221174 by mglaman: Add a negate option for each condition
    
mglaman’s picture

Status: Needs review » Fixed
mglaman’s picture

tonytheferg’s picture

Status: Fixed » Closed (fixed)