Documentation

Does Drupal Commerce support free orders?

Yes, Drupal Commerce supports free orders thanks to its use of Rules when determining which payment methods should be shown for an order on the checkout form. You can simply add conditions to your payment method rules that require the order total amount to be greater than 0 for a payment method to be shown (and therefore payment to be required). Provided you have not configured the payment method checkout pane to prevent checkout without payment, the customer simply won't see the payment pane and can proceed to the completion page without submitting payment.

The only caveat is in how you structure your checkout completion rules or Rules that react to the "When an order is first paid in full" event. Because you are not collecting payment for the order, no payment transaction will be made. This will prevent the aforementioned Rule from ever being triggered, so any actions you take based on that event may need to be duplicated in a checkout completion rule for free orders.

Comments

sher1 on May 8, 2012

I have tried to follow your instructions above and am not quite there. Here is what I have:

{ "rules_free_item_checkouts" : {
    "LABEL" : "Free Item checkouts",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "commerce_order", "commerce_payment", "commerce_checkout" ],
    "ON" : [ "commerce_payment_methods" ],
    "IF" : [
      { "commerce_order_compare_total_product_quantity" : {
          "commerce_order" : [ "commerce_order" ],
          "operator" : "\u003E=",
          "value" : "1"
        }
      },
      { "AND" : [
          { "commerce_payment_order_balance_comparison" : { "commerce_order" : [ "commerce_order" ], "value" : "0" } }
        ]
      }
    ],
    "DO" : [
      { "commerce_checkout_complete" : { "commerce_order" : [ "commerce_order" ] } }
    ]
  }
}

Tried this too and it also didn't work
{ "rules_free_item_checkouts" : {
    "LABEL" : "Free Item checkouts",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "commerce_order", "commerce_payment" ],
    "ON" : [ "commerce_payment_methods" ],
    "IF" : [
      { "commerce_order_compare_total_product_quantity" : {
          "commerce_order" : [ "commerce_order" ],
          "operator" : "\u003E=",
          "value" : "1"
        }
      },
      { "AND" : [
          { "commerce_payment_order_balance_comparison" : { "commerce_order" : [ "commerce_order" ], "value" : "0" } }
        ]
      }
    ],
    "DO" : [
      { "commerce_order_update_state" : { "commerce_order" : [ "commerce_order" ], "order_state" : "completed" } },
      { "commerce_order_update_status" : { "commerce_order" : [ "commerce_order" ], "order_status" : "completed" } }
    ]
  }
}

Any help would be greatly appreciated.

michaelphipps on May 8, 2012

Hi, lets see if this helps. I'm using a PayPal WPS payment method. I have coupons that can make the amount of an order come to zero. What I am doing in the Payment Methods rule for the payment method is saying "If the order total amount is greater than zero, then display the payment method, otherwise display nothing" - so it should handle the free products scenario that you've described. If anything it might help point you towards a solution.

Here is the exported rule

{ "commerce_payment_paypal_wps" : {
    "LABEL" : "PayPal WPS",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "commerce_payment" ],
    "ON" : [ "commerce_payment_methods" ],
    "IF" : [
      { "data_is" : {
          "data" : [ "commerce-order:commerce-order-total:amount" ],
          "op" : "\u003E",
          "value" : "0"
        }
      }
    ],
    "DO" : [
      { "commerce_payment_enable_paypal_wps" : {
          "commerce_order" : [ "commerce-order" ],
          "payment_method" : { "value" : {
              "method_id" : "paypal_wps",
              "settings" : {
                "business" : "[email protected]",
                "currency_code" : "AUD",
                "language" : "AU",
                "server" : "live",
                "payment_action" : "sale",
                "ipn_logging" : "notification"
              }
            }
          }
        }
      }
    ]
  }
}

sher1 on May 8, 2012

It took me a little bit to get the GUI to do what I needed but here is what my condition looked like:


Data comparison
Parameter: Data to compare: [commerce-order:commerce..., Operator: is greater than, Data value: 0

Hope this helps anyone else wanting to do this.
A big thanks to Michael!!!

Tim Jones on October 28, 2012

Sher1 - I am not sure what your condition is. I am guessing it is commerce-order:commerce-order-total:amount
greater than 0

I am capable of creating this condition, but where do i place it???

a laid out step by step guide would be great.

thanks

Hendrik Martens on May 13, 2013

I got it working as they described it above making the rule for payment to be above 0. It was difficult getting to the answer because they don't explain the steps, but here's my steps if you want to accomplish this:
> Go to Store>Configuration>Payment Methods and "edit" your Payment method, in my store I had to edit Paypal WPS.
>Add a condition for the payment under "Conditions" and select "Price Comparison" . The "Operator" I selected was '>=' and I had to select $1 under "Second Price" because it didn't want to take $0 .
>And save your rule...then it should work although this rule is in effect catered for any products that are cheaper than $1

Bobx on January 28, 2014

I tried .01 (point 01) and it worked for me. Thank you for this post. I've been trying to figure this out for weeks.