0

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-

  1. after completing the checkout process -event
  2. cart contain a particular product type - condition
  3. create a entity type of commerce_coupon
  4. set value data - entity created coupon code
  5. 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" ]
        }
      }
    ]
  }
}
5
  • Can you export your rule & paste here, so that anybody can help further...
    – RajeevK
    Commented Jun 26, 2013 at 6:41
  • we are posting whole rule in parts..please check
    – jyoti
    Commented Jun 26, 2013 at 7:41
  • Please edit the question and put this rules below your texts...
    – RajeevK
    Commented Jun 26, 2013 at 7:43
  • please check ..we are posted the rule..
    – jyoti
    Commented Jun 26, 2013 at 7:52
  • Question has been answered in this post: drupal.stackexchange.com/questions/110168/… Commented Apr 15, 2014 at 18:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.