Posted by jazzdrive3 on January 11, 2013 at 4:11pm
1 follower
| Project: | Rules |
| Version: | 7.x-2.2 |
| Component: | Module Integrations |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I have a default rule configuration in a hook_default_rules_configuration function:
$rule = rules_reaction_rule();
$rule->label = 'Add the selected product add-on to the cart';
$rule->active = TRUE;
$rule->event('commerce_pado_add_to_cart')
->action('commerce_cart_product_add_by_sku', array('user:select' => 'site:current-user'),
array('sku:select' => 'commerce-product:sku'));The user parameter for the action works fine. It is set to the token site:current-user. But the sku parameter is not. It never works. It is always blank, and so the rule is invalid. It never sets it to data selection either. This is the correct order of parameters for the action.
I can manually set the sku field to data selection and put in the token just fine. But it never works only through the default configuration.
For now, I have replaced the code with the follow to get it to work properly, but obviously I'd like to use the normal convention:
$exported_rule = '{ "commerce_pado_add_selected_add_ons_to_cart" : {
"LABEL" : "Add the selected product add-on to the cart",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "commerce_cart", "commerce_pado" ],
"ON" : [ "commerce_pado_add_to_cart" ],
"DO" : [
{ "commerce_cart_product_add_by_sku" : {
"USING" : {
"user" : [ "site:current-user" ],
"sku" : [ "commerce-product:sku" ],
"quantity" : "1",
"combine" : 1
},
"PROVIDE" : { "product_add_line_item" : { "product_add_line_item" : "Added product line item" } }
}
}
]
}
}';
//$rules['commerce_pado_add_selected_add_ons_to_cart'] = $rule;
$rules['commerce_pado_add_selected_add_ons_to_cart'] = rules_import($exported_rule);Thanks.