In this chapter, we will learn how to Receive Donation in Drupal. Donation is some amount of gift given by an organization or individual to a non-profit organization or private foundation.
Following are the steps to receive donation in Drupal.
Step 1 − Download the latest file of Commerce Custom Line Items module and install in your Drupal site.
Step 2 − Enable the Commerce Custom Line Items and Others in Modules and click Save configuration.
Step 3 − Next, go to Store --> Configuration
Step 4 − Click on Line item types.
Step 5 − Then, click Add line item types to add items.
Step 6 − Now, Add line item type page will get displayed as shown in the following screen.
It contains fields such as −
Line item type name − Enter the name of the line item type.
Description − Enter a brief description about the line item type.
Add form submit value − Enter the text of the button on the order page which allows adding line items.
Step 7 − You can view the created donation item in the list. Click manage fields.
Step 8 − Add a new field as Donation Amount, Select Integer for type of data from the dropdown.
Click the Save button.
Step 9 − Now, after clicking on save, the page redirects to the field setting page as shown in the following screen. Click the Save field settings button.
Step 10 − The page is redirected to the Donation Amount page.
It contains fields such as −
Label − Donation type identifier.
Help text − Enter instructions to present to the user.
Minimum − Enter the minimum value that should be allowed.
Maximum − Enter the maximum value that should be allowed.
Prefix − Enter the string that should be prefixed to the value.
Suffix − Enter the string that should be suffixed to the value.
Default Value − Enter the default donation amount.
Add to Cart Form Settings − Includes the product line item types in the ‘add to cart form’ to collect information.
Donation Amount Field settings − Number of values user can enter for this field.
After filling the page, click the Save settings button.
Step 11 − Next, you can view the created Donation Amount field in the list.
Following are the steps to create product for donation.
Step 1 − Click on Store --> Products
Step 2 − Click Add a product to add product.
Step 3 − Next, it will open a Create Product screen as shown in the following screen.
It contain fields such as −
Product SKU − It is a unique identifier for the product.
Title − It is title for the specified product.
Image − Add image for the product.
Price − Enter the amount of the product.
Status − Set this field to Active option, so that it can be added to shopping cart. If it set to Disabled option, products cannot be added to shopping carts and may be hidden in administrative product lists.
After filling all the details, click the Save product button.
Step 4 − Now you can see the newly created product as shown in the following screen.
Step 5 − Go to Structure --> Content Types. The following page will get displayed, click Add content type.
Step 6 − Add a name as Donation and click Save and add fields.
Step 7 − It will open the Manage Fields tab as shown in the following screen.
Add fields into Add existing field section as Product and select Product reference from the dropdown and click the Save button.
Step 8 − Now, Product page will get displayed, click the Save settings button.
Step 9 − You can view the created Product field in the list.
Step 10 − Now, click the Manage Display tab. Click the symbol present on the right side of the field Product, and the following screen will get displayed.
Here, Select as Donation from the dropdown in Add to Cart line item type. Later click the Update button and then on Save button.
Step 11 − Next, click Content --> Add Content to add donation information.
Step 12 − Click on Donation.
Step 13 − Enter your Donation information and click the Save button.
Step 14 − The page of donation will get displayed as shown in the following screen.
Here, you can fill the amount according to your wish and click the Add to cart button.
Step 15 − Now, you can view the donation amounts in the block present on the right side of the page. Click View Cart.
Step 16 − You can view the Shopping cart donation amount and click the Checkout button.
Step 17 − Now, you can enter the information of billing and click Continue to next step.
Step 18 − The next step is the review order page, where you can review the order information and click Continue to next step.
Step 19 − A message will get displayed as Checkout complete as shown in the following screen.