drupaldrupal-modulesdrupal-8drupal-commercedrupal-rules

Drupal 8: Only add to cart if user has enough credits


I've a site where transactions are based purely on credits. No actual money is exchanged. In such a case, I want to restrict users from adding products to cart if they do not have credits to do so.

In steps of how this should be accomplished, here is the sequence of events which I think should work :

Whenever somebody tries to add a product :

I use the loyalty points module for the user credits.

How can I set up the rules for this scenario?


Solution

  • Instead of using a module I just used a custom_validation function on commerce_add_to_card_form as suggested by lamp5