Hi

I'm implementing my hook_default_rules_configuration in my mymodule.rules_defaults.inc

<?php
/**
 * @file
 * aibm_commerce.rules_defaults.inc
 */

/**
 * Implements hook_default_rules_configuration().
 */
function mymodule_default_rules_configuration() {
  $items = array();
  $items['get_quote_from_flatrate_8'] = entity_import('rules_config', '{ "get_quote_from_flatrate_8" : {
    "LABEL" : "UK Flat rate conditions",
    "PLUGIN" : "and",
    "REQUIRES" : [ "uc_order" ],
    "USES VARIABLES" : { "order" : { "label" : "Order", "type" : "uc_order" } },
    "AND" : [
      { "uc_order_condition_delivery_country" : { "order" : [ "order" ], "countries" : { "value" : { "826" : "826" } } } }
    ]
  }
}');

  return $items;
}

However in the rules UI, it seems the conditions are missing, is this a bug in ubercart or rules? where do I start?

Comments

tr’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

It's not clear to me what you're trying to do. Ubercart will define Rules components for all the configured flat rates, and those components will be named with the prefix 'get_quote_from_flatrate_'. I suspect you're trying to override the Ubercart component 'get_quote_from_flatrate_8' by implementing hook_default_rules_configuration(), but I'm not sure why you would or would have to do that - all you should have to do is configure the component once then it will stay configured, you don't have to override that. Or if you want to override it, just re-configure it. I don't see the need to do both.

Anyway, because the 'get_quote_from_flatrate_' components are defined in Ubercart's hook_default_rules_configuration() you need to ensure that your module gets loaded AFTER Ubercart, otherwise when the Ubercart hook_default_rules_configuration() gets called it will overwrite what you are defining in your own hook. That would explain what you're seeing because the default Ubercart component 'get_quote_from_flatrate_' doesn't have any conditions, so then it would look like your conditions disappeared.

The way to ensure your module gets loaded after Ubercart is to set the weight of your module in hook_install(). Search the documentation on drupal.org to see how this is done.