1

I would like to apply a discount on cart items at check-out. The discount will be based on quantity of particular product type.

What event can I use to calculate a discount during checkout?

Here is the export of my current rule:

{ "rules_group_subscription_discount_4_15_" : {
    "LABEL" : "Group subscription discount (4-15)",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "commerce_order", "rules", "commerce_line_item", "commerce_checkout" ],
    "ON" : { "commerce_checkout_complete" : [] },
    "IF" : [
      { "commerce_order_contains_product_type" : {
          "commerce_order" : [ "commerce_order" ],
          "product_type" : { "value" : { "subscription" : "subscription" } },
          "operator" : "\u003E=",
          "value" : "4"
        }
      },
      { "commerce_order_contains_product_type" : {
          "commerce_order" : [ "commerce_order" ],
          "product_type" : { "value" : { "subscription" : "subscription" } },
          "operator" : "\u003C=",
          "value" : "15"
        }
      }
    ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "decimal", "value" : "0.10" },
          "PROVIDE" : { "variable_added" : { "discount_percentage" : "Discount percentage" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
          "ITEM" : { "line_item" : "Current line item" },
          "DO" : [
            { "component_rules_calculate_group_subscription_discount" : {
                "USING" : {
                  "line_item" : [ "line_item" ],
                  "percentage_discount" : [ "discount-percentage" ]
                },
                "PROVIDE" : { "discounted_subscription_cost" : { "discounted_subscription_cost" : "Discounted subscription cost" } }
              }
            },
            { "commerce_line_item_unit_price_subtract" : {
                "commerce_line_item" : [ "line-item" ],
                "amount" : [ "discounted-subscription-cost" ],
                "component_name" : "discount",
                "round_mode" : "1"
              }
            }
          ]
        }
      }
    ]
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.