Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.

Hi I'm developing an inline condition for use with commerce discount and if I don't add a configure callback the inline condition isn't added to the rule condition.

Acording the documentation the configure callback is optional: http://cgit.drupalcode.org/inline_conditions/tree/inline_conditions.api....

Any idea?

Thanks!

Comments

facine created an issue. See original summary.

jkuma’s picture

Hello sir,

May you forward us your code ? Maybe we mess up something here.

facine’s picture

Of course:

mymodule.inline_conditions.inc

function mymodule_inline_conditions_info() {
  $conditions = array();

  $conditions['first_customers_order_of_the_period'] = array(
    'label' => t("First customer's Commerce Order"),
    'entity type' => 'commerce_order',
    'callbacks' => array(
//      'configure' => 'mymodule_first_customers_order_of_the_period_configure',
      'build' => 'mymodule_first_customers_order_of_the_period_build',
    ),
  );

  return $conditions;
}

mymodule.rules.inc

function mymodule_rules_condition_info() {
  $inline_conditions = inline_conditions_get_info();

  return array(
    'first_customers_order_of_the_period' => array(
      'label' => t("Is the first customer's order of the month"),
      'parameter' => array(
        'commerce_order' => array(
          'type' => 'commerce_order',
          'label' => t('Commerce Order'),
          'description' => t('A Drupal Commerce Order.'),
          'wrapped' => TRUE,
        ),
      ),
      'module' => 'mymodule',
      'group' => t('Commerce Order'),
      'callbacks' => array(
        'execute' => $inline_conditions['first_customers_order_of_the_period']['callbacks']['build'],
      ),
    )
  );
}

function mymodule_first_customers_order_of_the_period_build(EntityDrupalWrapper $order_wrapper) {
 //My code.
}

If I don't add a configure callback the inline condition isn't added to the rule condition, I can add manually the condition to the rule abd check that the condition works fine.

Any idea?

facine’s picture

Category: Feature request » Support request
facine’s picture

Status: Active » Closed (cannot reproduce)

By some mystery, now it works well.

Sorry for the inconvenience!

marcoscano’s picture

Category: Support request » Bug report
Priority: Major » Normal
Status: Closed (cannot reproduce) » Active

Seeing the same problem (with the same code)

If there is no configure callback, the value of $value['condition_settings'] is empty, and this will abort the condition being added to the rule here.

Any way to create an inline_condition without config form?

joelpittet’s picture

What version of this module and rules are you using?

If you rebuild rules does it fix?

facine’s picture

Issue summary: View changes
facine’s picture

Issue summary: View changes
facine’s picture

Issue summary: View changes

Hi again, @marcoscano you can solve this issue adding a blank configure callback while this issue is not solved.

     'callbacks' => array(
      // @todo: remove configure callbak and re-export the discount when this
      // has been fixed: https://www.drupal.org/node/2635824
      'configure' => '',
      'build' => 'mymodule_first_customers_order_of_the_period_build',
     ),
marcoscano’s picture

@joelpittet in my case inline_conditions is 7.x-1.0-alpha5 and rules is 7.x-2.9. Unfortunatelly no, rebuilding rules does not change the behavior..

@facine thanks for the tip, actually I have implemented temporarily a similar workaround, with a configure callback that just returns a dummy form.

joelpittet’s picture

Why aren't you using alpha7 or -dev? Can you upgrade and see if it fixes this?

marcoscano’s picture

Status: Active » Fixed

Sorry about that, I can confirm that in alpha7 the problem is solved.

Thanks.

Status: Fixed » Closed (fixed)

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