In a webshop I’ve build I want to send individual e-mails to owners of a prodruct in the shop after a product is sold. To do this I got this as a solution: Send mail to product owner with Rules
But with this I’m only able to send the product owner an e-mail about the product. I am not able to add a shipping/billing address or mailadres form the customer profile to it.
When I try to add the customer profile as a parameter to the component the rules breaks and doesn't work anymore.
This is an export of my component:
{ "rules_perform_an_action_on_a_selected_line_item" : {
"LABEL" : "Perform an action on a selected line item",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "mimemail" ],
"USES VARIABLES" : {
"selected_line_item" : { "label" : "Selected Line Item", "type" : "commerce_line_item" },
"commerce_order" : { "label" : "Commerce Order", "type" : "commerce_order" },
"commerce_customer" : { "label" : "Commerce Customer", "type" : "commerce_customer_profile" }
},
"IF" : [
{ "entity_has_field" : { "entity" : [ "selected-line-item" ], "field" : "commerce_product" } }
],
"DO" : [
{ "entity_fetch" : {
"USING" : {
"type" : "commerce_product",
"id" : [ "selected-line-item:commerce-product:product-id" ]
},
"PROVIDE" : { "entity_fetched" : { "product_fetched" : "Fetched Product" } }
}
},
{ "entity_fetch" : {
"USING" : { "type" : "commerce_customer_profile", "id" : [ "commerce-order:uid" ] },
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched user" } }
}
},
{ "drupal_message" : { "message" : "Product Mail = [product-fetched:field-e-mailadres-product]" } },
{ "mimemail" : {
"key" : "[commerce-order:order-id]",
"to" : "[product-fetched:field-e-mailadres-product]",
"subject" : "Product order",
"body" : "OUTPUT PRODUCT INFORMATION AND USER INFORMATION HERE",
"language" : [ "" ]
}
}
]
}
}
This is the export of my rule to loop trough the line-items:
{ "rules_send_mail_to_product_owner" : {
"LABEL" : "Send mail to product owner",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Custom" ],
"REQUIRES" : [ "rules", "entity" ],
"ON" : { "commerce_order_presave" : [] },
"DO" : [
{ "LOOP" : {
"USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
"ITEM" : { "line_items" : "Commerce Line Items" },
"DO" : [
{ "component_rules_perform_an_action_on_a_selected_line_item" : { "selected_line_item" : [ "line-items" ] } }
]
}
}
]
}
}
I set the rules action to order presave
as this is the easiest way testing the rule, in the end it should run on when payment is first payed in full
.
The rule isn't running because of my fault in the parameter settings the parameter commerce_customer
is giving problems, I get an error that says: "Missing configuration for parameter commerce_customer"
.
How can I get to this information in my component?