It is practically impossible for me to set the fixed amount of a coupon created with rules. The coupon is generated allright with a coupon code but the fixed amount value is always empty, I can only edit the generated coupon and set the fixed amount manually. I am referring to these issues which seemed to have never been resolved:
Edit: I know that Commerce GC exists but it is buggy and not production ready (breaks my site during checkout) and the bug issues havent been resolved.
Here is my exported rule:
{ "rules_send_a_gift_certificate" : {
"LABEL" : "Send A Gift Certificate",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "commerce_order", "rules", "commerce_coupon", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
{ "commerce_order_contains_product" : {
"commerce_order" : [ "commerce_order" ],
"product_id" : "BGC-1-8",
"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 } },
{ "data_set" : {
"data" : [ "entity-created:commerce-coupon-number-of-uses" ],
"value" : "1"
}
},
{ "entity_save" : { "data" : [ "entity-created" ] } },
{ "commerce_coupon_action_create_coupon_line_item" : {
"USING" : {
"commerce_coupon" : [ "entity-created" ],
"commerce_order" : [ "commerce_order" ],
"amount" : "100.00",
"component_name" : "commerce_coupon_fixed_ord1ers",
"currency_code" : "NGN"
},
"PROVIDE" : { "commerce_coupon_line_item" : { "commerce_coupon_line_item" : "commerce coupon line item" } }
}
},
{ "data_set" : {
"data" : [ "commerce-coupon-line-item:commerce-total:amount" ],
"value" : "100"
}
},
{ "entity_save" : { "data" : [ "commerce-coupon-line-item" ] } },
{ "LOOP" : {
"USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
"ITEM" : { "list_item" : "Current list item" },
"DO" : [
{ "mail" : {
"to" : "[list-item:field-gift-recipient-email]",
"subject" : "[list-item:field-gift-sender-name] has sent you a Gift Certificate",
"message" : "Hello [list-item:field-gift-recipient-name], [list-item:field-gift-sender-name] has sent you a \u20a6 [entity-created:commerce-coupon-fixed-amount] Gift Certificate to celebrate your birthday. Your Gift certificate code is: [entity-created:commerce-coupon-code]. Please note that your Gift certificate may only be used once, please spend the full amount in one purchase, any balance remaining is non-refundable. Happy birthday celebration!",
"language" : [ "" ]
}
}
]
}
}
]
}
}