[英]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? 如何为这种情况设置规则?
我没有使用模块,而是按照lamp5的建议在commerce_add_to_card_form上使用了custom_validation函数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.