When your company or your workplace doesn't have a restaurant for lunch, it's pretty common nowadays to get food delivery at work. Because we are in a hurry, because we don't want to bring food from home, because we are lazy, or because it's convenient, there are plenty of reasons why this commercial activity is becoming more popular.
It's not rare to find clients asking you to build a food delivery website and your first choice will probably to take a look at WordPress templates to find one that fits your need.
But this task has become quite easier on Drupal with Commerce Funds module.
So, why commerce funds?
Because one of the major issue when delivering food at work is to deal with cash transactions. Most of your clients will request you to find a proper solution with an online payment gateway integration. When most of them will allow you to bill the customer from dish to dish, commerce funds will allow you to create a virtual bank account for each of them.
Each customer will be able to deposit funds in their account and then use these credits to pay their meal. This way you also build up your customer loyalty.
Starting with Commerce and Commerce Funds
The fastest way to get a complete installation of Drupal Commerce and Drupal Commerce Funds is to install Commerce Funds.
composer require drupal/commerce_funds
This will download both modules and all their dependencies. You can then manually enable Commerce Funds which will automatically enable all the necessary modules for you. Or, you can use drush as follows:
drush en commerce_funds
Configuring a store
What we will first do is creating a custom currency so customer accounts won't hold any official currency but a "virtual" one.
In /admin/commerce/config/currencies add a new custom currency. Let's call it "token".
Now configure a store with the seller details and select the "token" currency as the default one.
Add a new payment gateway using the plugin "Funds Balance" and restrict it to the store product (you shouldn't allow customers to use this payment gateway for their deposit).
You'll also have to enable another payment gateway for the customers to deposit money in their account. I'm gonna use "manual" here because it's more convenient for the purpose of this tutorial, but you can set up PayPal, Stripe, Skrill or whatever.
In order to configure Commerce Funds, we will need to do the following:
- enable the user balance block so customers can see how many tokens they have left,
- enable the site balance block so your client can keep track of its incomes,
- give permission to authenticated users to deposit money in their accounts.
When it's done, it's time to create our first product.
Create your first product
If you are not used to Drupal Commerce you'll probably have to put your hands in the work here, but basically, for a delivery platform, you need a quite simple setup. You'll need a product type with an image and a description. You can, for example, edit the default product type and add an image field to it or create a new product type.
Then simply add a new product, give it a name and add a new variation with the price in tokens.
The customer workflow
It's now time to see the other side of the website. How does it work when you are a customer? Here is what a customer will see with the configuration we have made.
That's quite simple, your customer will firstly make a deposit.
It's now time for your customer to buy a healthy lunch! They will just add it to their cart and then go through the checkout process where they'll be asked to create a virtual wallet for Tokens. After that, they'll be able to pay their lunch in tokens!
That's it, we've just created what can be the base of a food delivery platform and the Drupal Commerce and Commerce Funds module can actually do a lot more when combined altogether!