I want to create a fixed amount coupon using rule..
Please tell me how I can create a fixed amount coupon using rules in drupal commerce.. I am creating a rule for gift card by using following step-
- after completing the checkout process -event
- cart contain a particular product type - condition
- create a entity type of commerce_coupon
- set value data - entity created coupon code
- save entity
Now I am getting a automatically generated coupon but I am not able to assign amount to the coupon code..
How I can assign value to generated coupon code?
& rule code-
{ "rules_gift_card_product_purchased" : {
"LABEL" : "gift card product purchased",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "commerce_order", "rules", "commerce_coupon", "commerce_cart" ],
"ON" : [ "commerce_cart_product_add" ],
"IF" : [
{ "commerce_order_contains_product_type" : {
"commerce_order" : [ "commerce_order" ],
"product_type" : { "value" : { "product" : "product" } },
"operator" : "\u003E=",
"value" : "1"
}
}
],
"DO" : [
{ "entity_create" : {
"USING" : { "type" : "commerce_coupon" },
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "data_set" : {
"data" : [ "entity-created:commerce-coupon-code" ],
"value" : "ord[commerce-order:order-id]ers"
}
},
{ "data_set" : { "data" : [ "entity-created:type" ], "value" : "commerce_coupon_fixed" } },
{ "data_set" : { "data" : [ "entity-created:is-active" ], "value" : 1 } },
{ "variable_add" : {
"USING" : { "type" : "commerce_coupon", "value" : [ "entity-created" ] },
"PROVIDE" : { "variable_added" : { "variable_added" : "Added variable" } }
}
},
{ "data_set" : {
"data" : [ "entity-created:commerce-coupon-number-of-uses" ],
"value" : "1"
}
},
{ "commerce_coupon_action_create_coupon_line_item" : {
"USING" : {
"commerce_coupon" : [ "variable-added" ],
"commerce_order" : [ "commerce_order" ],
"amount" : [ "commerce-product:commerce-price:amount" ],
"component_name" : "commerce_coupon_fixed_giftcard",
"currency_code" : "[commerce-product:commerce_price]"
},
"PROVIDE" : { "commerce_coupon_line_item" : { "commerce_coupon_line_item" : "commerce coupon line item" } }
}
},
{ "entity_save" : { "data" : [ "entity-created" ] } },
{ "mail" : {
"to" : "[commerce-order:mail]",
"subject" : "your order completed",
"message" : "[entity-created:commerce-coupon-code][entity-created:commerce_coupon_fixed_amount]",
"from" : "[site:mail]",
"language" : [ "site:current-cart-order:state" ]
}
}
]
}
}