我有3条规则构成我的会员资格"。
请注意,2分钟和4分钟仅用于测试目的,它们将分别为350天和365天。
虽然2或3都工作,但我有两个问题:
规则n2和n3同时触发,因此在2分钟标记不仅会发送电子邮件,而且还会删除该角色。
让我们说用户 MARK 购买产品X,一分钟后, JOE 也会这样做。 MARK 购买产品X 2分钟后, MARK 收到提醒电子邮件,其角色已删除但 JOE 获取提醒电子邮件,并删除他的角色。
似乎很快就会触发,所有人都会这样做。
从导出中可以看出,我从商业订单的x分钟完成了一个规则触发器,另一个从分配的角色开始,认为与2个不同的事件有关,我会解决问题。它没有用。
以下是我的规则的出口:
规则"发送提醒"成分:
{ "rules_sends_email_to_pipps_reminder_1_week_prior_expiry" : {
"LABEL" : "Sends Email to PIPPS Reminder 1 week prior expiry",
"PLUGIN" : "rule set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "user_argument" : { "label" : "User {argument}", "type" : "user" } },
"RULES" : [
{ "RULE" : {
"DO" : [
{ "mail" : {
"to" : "[commerce-order:mail]",
"subject" : "Heads up!",
"message" : "Yo! Heads up!",
"from" : "pipps@siteemail.com",
"language" : [ "site:current-cart-order:state" ]
}
}
],
"LABEL" : "Send email reminder to PIPPS"
}
}
]
} }
规则"发送提醒"触发:
{ "rules_send_reminder_email_to_pipps_role_trigger_rule_" : {
"LABEL" : "Send reminder email to PIPPS Role {trigger rule}",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "commerce_order", "rules", "rules_scheduler", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
{ "commerce_order_contains_product" : {
"commerce_order" : [ "commerce_order" ],
"product_id" : "PIPPS",
"operator" : "=",
"value" : "1"
}
}
],
"DO" : [
{ "schedule" : {
"component" : "rules_sends_email_to_pipps_reminder_1_week_prior_expiry",
"date" : {
"select" : "site:current-cart-order:created",
"date_offset" : { "value" : 120 }
},
"identifier" : "Reminder email to [account:uid]",
"param_user_argument" : [ "commerce-order:owner" ]
}
}
]
} }
规则"角色过期"成分:
{ "rules_expire_pipps_role_rule_set_" : {
"LABEL" : "Expire PIPPS Role {rule_set}",
"PLUGIN" : "rule set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "user_argument" : { "label" : "User {argument}", "type" : "user" } },
"RULES" : [
{ "RULE" : {
"DO" : [
{ "user_remove_role" : {
"account" : [ "user_argument" ],
"roles" : { "value" : { "13" : "13" } }
}
}
],
"LABEL" : "Expire action {rule}"
}
}
]
} }
规则"到期角色"触发:
{ "rules_remove_pipps_role_trigger_rule_" : {
"LABEL" : "Remove PIPPS Role {trigger rule}",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_scheduler" ],
"ON" : { "user_update" : [] },
"IF" : [
{ "user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "13" : "13" } } } }
],
"DO" : [
{ "schedule" : {
"component" : "rules_expire_pipps_role_rule_set_",
"date" : {
"select" : "site:current-cart-order:created",
"date_offset" : { "value" : 240 }
},
"identifier" : "Remove User role [account:uid]",
"param_user_argument" : [ "account" ]
}
}
]
} }
非常感谢任何建议!感谢。
答案 0 :(得分:1)
您的规则(和规则组件),似乎“按实施方式工作”......您的“问题”似乎是您在测试期间应该更耐心...继续阅读以获取更多详细信息......
安排规则后(使用规则调度程序子模块),下次执行cron 时,它实际上只会执行 。
示例:
timestamp X1
执行。Y mins after timestamp X1
,那么第一个规则组件的执行只会发生(= Y mins after timestamp X1
)。timestamp X2
执行。Y mins after timestamp X2
,那么第二个规则组件的执行只会发生(= Y mins after timestamp X2
)。由于问题的情景中描述的内容,似乎timestamp X2
正在Y mins after timestamp X1
之前发生。这也可以解释为什么BOTH Rules Components实际上同时执行(或多或少)。
假设您的cron作业每小时运行一次,对 4分钟之后安排的规则组件进行直接(次要)修复,将在(例如)之后安排它们2小时代替。这样您就可以确保在同一个cron作业中实际上并未执行两个Rules Component。