I think is good to have exclude functionality for product which we don't want under promotion.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jkuma’s picture

Title: Exclude products for promotion » Add a new logical operator: NOT
Project: Commerce Discount » Inline Conditions
Assigned: Unassigned » jkuma
Status: Active » Needs work

Thanks for your idea, I have already merged the idea of logical operators (OR and AND) for inline conditions. So I think I can add a new logical operator such as NOT to cover your needs. Let me move this feature request to the correct place.

jkuma’s picture

Status: Needs work » Needs review
FileSize
3.38 KB

Here is my first attempt to add this new logical operator to inline conditions.

jkuma’s picture

Status: Needs review » Reviewed & tested by the community

I've tested in many different configuration and it seems to work fine to me.

jkuma’s picture

Status: Reviewed & tested by the community » Fixed

Merged in the dev branch. commit

Status: Fixed » Closed (fixed)

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

roderik’s picture

Status: Closed (fixed) » Needs work
FileSize
6.66 KB

Reopening issue, as it's not too old yet.

This way of adding NOT doesn't really work, because NOT applies to a single condition. Right now:

  • If you have only one condition, you cannot negate it;
  • the 'Not' operator is equal to 'And Not' - you cannot do 'Or' with a negated condition.

The attached patch implements NOT as a separate control (checkbox) for each condition.

Remarks:

  • I rewrote some code a bit; $temp is now a full condition object instead of an array. (And maybe changing '$temp = NULL' to use 'unset($temp)' was unnecessary... It just spoke more to me in this kind of situation.)
  • I don't see which CSS properties to add, to be consistent with what you have already, and keep the 'negate' checkbox on the same line. Now it's wrapping (sometimes). So that's still Needs Work. For the rest: I think the code is good / tested.
jkuma’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
7.11 KB

Hello Roderik,

Thanks for re-opening this issue, your approach is better than mine, I've just added a CSS rule and i've fixed up the default value of the "negate" form item.

    $element[$delta]['condition_negate'] = array(
      '#type' => 'checkbox',
      '#title' => t('Negate'),
      '#default_value' => !empty($item['condition_negate']) ? $item['condition_negate'] : FALSE,
      '#prefix' => '<div class="negate-condition">',
      '#suffix' => '</div>',
    );
jkuma’s picture

Status: Reviewed & tested by the community » Fixed

Merged in the dev branch.

  • Commit 6a03f7b on 7.x-1.x authored by roderik, committed by goldorak:
    Issue #2133189 by goldorak, roderik: Add a new logical operator: NOT.
    

Status: Fixed » Closed (fixed)

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