I'm doing a favor for a family member by helping set up their store. I've never worked with Drupal before.

They are selling one item, but they want the shipping cost per item to change based on the number of items purchased.

  • 1 item - $3.50 shipping
  • 2 to 9 items - $2.75 shipping PER ITEM
  • more than 10 items - $2.00 shipping PER ITEM

After a few hours of research I half-understand the rules system, but I can't figure out how to combine rules like this. Can anyone point me in the right direction?

  • In the settings for your rule you can have a condition "Order contains a particular product" and the the settings for that there is Quantity. Setup several rules for the different shipping costs. Aug 7, 2014 at 7:20
  • try this, look close to your requirement drupal.org/project/commerce_shipping_postal_code_weight
    – Bala
    Sep 17, 2014 at 8:12

1 Answer 1


Pontus Nilsson has the right idea, just shared it as a comment instead of an answer?

I decided this was a good teachable moment (this also turned out to be a head scratcher at more than one turn), so below is the screencast of how to do this and a step-by-step:



  1. Install https://www.drupal.org/project/commerce_shipping and https://www.drupal.org/project/commerce_flat_rate

  2. Create three different flat rates (I recommend you keep the "Title" different, but change the "Display Title" to be the same, so the rate change is transparent to the user)

  3. Configure each flat rate component to have a condition on "Total product quantity comparison" so that only the appropriate rates show up based on number of products. Note this will only work if you use the standard line item type "Product" ... if you have custom line item types, you will have to create a component that does the comparison/counting that you need.

  4. In order to count the number of eligible products, we will need to create a component rule that has a "line item" parameter and has an "number decimal" provided called "is_a_product".

This component simply needs to have a condition on entity bundle for "Product" and needs an action that "sets a data value" ... the is_a_product ... to the line-item:quantity.

  1. Next, we will need to create a pricing rule for your first "Medium" level shipping price calculation.

    A. Once you discover where to create the shipping price calculation rule you will need to create two conditions:

    • Entity has field (it should have the shipping service field)
    • Data Comparison (the shipping service field should equal the medium shipping service)

    B. Now you will need to count the number of products. Let's add an action "create a variable" for an number decimal called "num_products"

    C. Next you will need to loop over all the line items in the order.

    D. Next you will add an action for the component you created in step 4.

    E. Then you will need to "Calculate a value" by adding the "num_products" and the "is_a_product" (through some testing I confirmed the integer is zero by default) and then save the result by "setting a data value" and setting "num_products" to the result value

    F. Finally, you will need to "Multiply the unit price by some amount" and select the num_products as the multiplier

  2. Repeat step 5 for each breakdown of product quantity rate change

  • Thanks! That's basically what I figured out, but I'm glad I inspired a video tutorial! Sep 20, 2014 at 20:37
  • Unfortunately the video link seems to be dead :( Nov 20, 2020 at 7:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.