The question of how to get working for multiple skus was posted in #1491940: How to use? Provide example link and rule.. This isn't really the "right" way to do it, but it's working for what I need. This will support links in the form of [my_linkevent_link]/sku1,sku2 (using commas because pluses were getting stripped out of the path. You could change this to try other characters, just don't use a '/'!).
Step 1: Create a Rules Component as an Action Set. This is your "do this for every sku" action.
Here's my export:
{ "rules_add_sku_to_cart" : {
"LABEL" : "Add SKU to Cart",
"PLUGIN" : "action set",
"REQUIRES" : [ "rules", "commerce_cart" ],
"USES VARIABLES" : { "sku" : { "label" : "SKU", "type" : "text" } },
"ACTION SET" : [
{ "commerce_cart_product_add_by_sku" : {
"USING" : {
"user" : [ "site:current-user" ],
"sku" : "[sku:value]",
"quantity" : "1",
"combine" : 1
},
"PROVIDE" : { "product_add_line_item" : { "product_add_line_item" : "Added product line item" } }
}
}
]
}
}Step 2: As part of your "link was accessed" rule, add the action "Execute custom PHP code," changing the [path:last] token to wherever your SKUs are being passed in the path.
$skus = '[path:last]';
$skus_array = explode(',',$skus);
foreach ($skus_array as $sku) {
rules_invoke_component('rules_add_sku_to_cart', $sku);
}