Skip to main content
3 of 3
integrate comment from OPer and improve title
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

How to check in a Rules Condition if an Ubercart product is out of order?

There isn't a good support for "out of order" in Ubercart for Drupal. I'm trying to fix that with the Rules module.

I'm trying to add a rule that disables the product after the stock is updated, using Rules event After updating existing content of type Product. I want to disable the product that is sold out (stock = 0).

Here is an export of the rule I have so far:

{ "rules_product_sold_out_check" : {
    "LABEL" : "Product sold out check",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_update--product" : { "bundle" : "product" } },
    "DO" : []
  }
}

But the stock isn't a field of the node. How can I select that field within a Rules Condition? I have no idea how to use that in the Rules module as a data selector.

The data to be compared, specified by using a data selector, e.g. "node:author:name".

I'm using the stock also in a view. This is what I use there (export-code-view to show the fieldnames / structure).

$handler->display->display_options['fields']['stock']['id'] = 'stock';
$handler->display->display_options['fields']['stock']['table'] = 'uc_product_stock';
$handler->display->display_options['fields']['stock']['field'] = 'stock';

I use Ubercart 7.x-3.10 (with Stock 7.x-3.10), Drupal 7, Rules 7.x-2.10