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

  • Operation is the same as Rules Event.. I don't have any rules yet for the stock. I only want to disable the product that is sold out (stock = 0).. I added the export. But I need the condition before I can add an action..
    – Finduilas
    Feb 20, 2018 at 10:32

1 Answer 1


As per the UC issue about "Stock transaction should be more flexible through Rules" (from 6 years ago, status "needs work" ...), it seems that at this time trying to use the Rules module for such "out of order" situations may not be a good idea.

You may want to try to use the Ubercart Out of stock Notification module instead. Some details about it (from its project page):

Out of stock notification for Ubercart.

It uses ajax and jquery and asks the server for available stock and replaces the 'Add to cart' button with some configurable HTML.


It also provides server-side validation so this module can prevent the addition of out of stock items even if JS is disabled or if the user clicks on an "Add to cart" button too quickly.

  • Ok, I will try. I'm using Ubercart now for 3 months. But all the additional modules for UC I used so far are very buggy (like UC discounts, UC VAT ...)..
    – Finduilas
    Feb 20, 2018 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.