Discussions

Quantity Discount Rule

I'm trying to figure out how to use rules. What I need is a discount that will take 25% off order if there are 14 or more products in the cart of any kind.

Posted: Sep 19, 2014

Comments

pooon on September 21, 2014

Hey thanks. I took an attempt at it, but I can't get it working. Here's what I have:

{ "rules_overall_discount" : {
    "LABEL" : "Volume Discount",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [
      "php",
      "inline_conditions",
      "commerce_line_item",
      "commerce_product_reference"
    ],
    "ON" : { "commerce_product_calculate_sell_price" : [] },
    "IF" : [
      { "commerce_order_has_specific_quantity_products" : {
          "commerce_order" : [ "site:current-cart-order" ],
          "products" : "\u003C? $commerce_line_item ?\u003E",
          "operator" : "\u003C",
          "quantity" : "14"
        }
      }
    ],
    "DO" : [
      { "commerce_line_item_unit_price_multiply" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : ".9",
          "component_name" : "base_price",
          "round_mode" : "1"
        }
      }
    ]
  }
}

I think the:

"products" : "\u003C? $commerce_line_item ?\u003E",

might be the problem. It's asking for SKU's but I simply want it to apply to everything.

pooon on September 22, 2014

Figured it out. Here's the rules settings. This will take 10% off your order if the total quantity of your cart is 14+

    { "rules_overall_discount" : {
        "LABEL" : "Volume Discount",
        "PLUGIN" : "reaction rule",
        "OWNER" : "rules",
        "REQUIRES" : [ "commerce_order", "commerce_line_item", "commerce_product_reference" ],
        "ON" : { "commerce_product_calculate_sell_price" : [] },
        "IF" : [
          { "commerce_order_compare_total_product_quantity" : {
              "commerce_order" : [ "site:current-cart-order" ],
              "operator" : "\u003E=",
              "value" : "14"
            }
          }
        ],
        "DO" : [
          { "commerce_line_item_unit_price_multiply" : {
              "commerce_line_item" : [ "commerce_line_item" ],
              "amount" : ".9",
              "component_name" : "base_price",
              "round_mode" : "1"
            }
          }
        ]
      }
    }