我试图迭代现有的订单项,并根据每年或每月的文字列表安排收费结算......
它没有工作所以我把它分解为行动中的元素基础
这是我的导出规则
{ "rules_schedule_next_billing_cloned_" : {
"LABEL" : "schedule next billing (cloned)",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
{ "entity_has_field" : {
"entity" : [ "commerce-order:commerce-line-items:0" ],
"field" : "commerce_product"
}
},
{ "entity_has_field" : {
"entity" : [ "commerce-order:commerce-line-items:0:commerce-product" ],
"field" : "field_cycle_start"
}
},
{ "entity_has_field" : {
"entity" : [ "commerce-order:commerce-line-items:0:commerce-product" ],
"field" : "field_cycle_period_list"
}
},
{ "entity_has_field" : {
"entity" : [ "commerce-order:commerce-line-items:0:commerce-product" ],
"field" : "field_client"
}
},
{ "entity_is_of_bundle" : {
"entity" : [ "commerce-order:commerce-line-items:0:commerce-product" ],
"type" : "commerce_product",
"bundle" : { "value" : { "recurring_service" : "recurring_service" } }
}
}
],
"DO" : [
{ "LOOP" : {
"USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
"ITEM" : { "cycled_billing_charge" : "cycled billing charge" },
"DO" : [
{ "drupal_message" : { "message" : "the period is [commerce-order:commerce-line-items:0:commerce-product:field-cycle-period-list]" } }
]
}
}
]
}
}
发生什么事情是它遍历了适当数量的订单项,但它没有递增......它只是发送它看到的第一个订单项
请帮忙。我已经看了几篇文章,我花了很多时间试图调试...我在一个非常基本的水平,它没有增加
答案 0 :(得分:0)
您的规则似乎“按实施方式工作”,因为在您的“drupal_message”中,您使用commerce-order:commerce-line-items:0...
(指的是您的第一个订单项,按照“最后0“。相反,您应该使用“正在处理的当前项目”(您使用机器名称为cycled_billing_charge
的变量)
尝试通过(简称)“commerce-order:commerce-line-items:0:commerce-product:field-cycle-period-list
”替换“drupal_message”中的“cycled_billing_charge:commerce-product:field-cycle-period-list
”,以便规则循环看起来像这样(同样在规则导出格式中):
{ "LOOP" : {
"USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
"ITEM" : { "cycled_billing_charge" : "cycled billing charge" },
"DO" : [
{ "drupal_message" : { "message" : "the period is [cycled_billing_charge:commerce-product:field-cycle-period-list]" } }
]
}
}