I have some nodes I use as rentable objects, and I want to check availability on the Commerce Cart page (made by Views, the one you see at /cart). I also need to check it a last time before the user is sent off to payment, but as for the views Cart form, what function actually handles the quantity updates? I can see that the edit quantity field has my pre-update value as default_value and the new value as value, but which function actually sets that on submit?

  • Is this node has product attach to it, which you send for checkout ?
    – RajeevK
    Jun 27, 2013 at 16:24

1 Answer 1


I'm not sure what you're asking about quantity for, so I'm going to set that question aside and answer the broader question of confirming availability before purchase. In Drupal Commerce, the product pricing system serves a two-fold purpose:

  1. Determine the price of a product for the current user.
  2. Determine if the product is no longer purchasable.

While #1 is the most common use case, #2 even has some core representation: if you add a product to your cart and then disable that product as an administrator, the product will be removed from your cart thanks to a default product pricing rule that unsets the price of disabled products. We'll make this process more explicit in the next version of Drupal Commerce, but right now you should understand that if the unit price of a product line item is "unset" or set to a NULL (empty) value, the product will not be considered purchasable.

This will result in one of two behaviors:

  1. For a product in the cart, it will be removed.
  2. For an Add to Cart form, the Add to cart button will be changed to Product not available.

So, in your case, I'd just add a product pricing rule that performed the availability check. If the product is not available, the Add to Cart form will not allow the product to be purchased. If it was already in the cart, it would be removed, so you might use a separate rule to remove unavailable products from the cart and display a message informing the customer what happened. If they were on a checkout page, it would be user friendly to also send them back to the cart page.

Since I don't know how you're checking availability, I'll just add that if you can't do what you need through Rules directly, you can just whip up a simple custom condition to perform the check for ya. There should be plenty of examples in our code and elsewhere.

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.