Initial Setup

Last updated on
11 March 2021

This documentation needs work. See "Help improve this page" in the sidebar.

Installation

If you do not have Drupal Commerce installed, that is your first step.  Please follow the Drupal Commerce Installation Guide.

The recommended way to install any Drupal 8 module is to Require It Using Composer to ensure all dependencies are included.  If you are not familiar with Composer, you can use any install method mentioned in the Installing Drupal 8 Modules Guide for this module since it does not require any external libraries (at the time of writing this at least).  Once you have the module installed, make sure that you Enable It.

Configuration

There are multiple entities that need to be configured to enable rental capability.

Order Item Type 

Location: admin/commerce/config/order-item-types

Install Rental Trait:

  • Edit or create a new order item type.  Enable the 'Rental' trait by clicking the checkbox.
  • Make note of the 'Purchasable Entity Type' and 'Order Type', these entities will need to have rental traits enabled as well (which will be explained later in this guide).
  • Save

Manage Form Display:

  • Navigate to the 'Manage Form Display' tab for the Order Item Type that you created/edited.
  • Set the 'Unit price' field widget to 'Rental Price'.  This widget will allow the unit price to be calculated based on the rental rates you specify for a product when managing orders through the Admin UI.
  • Make sure that the 'Rental Quantity' field is not disabled, the following settings should be used:
    • Rental Quantity Widget: Rental Quantity
  • Save the form display.
  • Navigate to the 'Add to cart' form display.  Drag the 'Rental Quantity' field from the disabled section to the enabled section.
  • Save the form display.

Product Variation Type

Location: admin/commerce/config/product-variation-types

Install Rental Trait:

  • Edit or create a new product variation type.  Enable the 'Rental' trait by clicking the checkbox.
  • Save

Rental Periods

Location: admin/commerce/rental-periods

  • A 'Default' Rental Period Type is included with Commerce Rental.  Multiple Rental Period Types are supported, please read the Rental Rates and Rental Periods/Types Guide for more information about advanced use cases.
  • Create the rental periods that you will use on your product variations.
  • Here are a few examples of rental periods you may want to create:
    • Daily
      • Title: Daily
      • Granularity: Days
      • Time Units: 1
    • Weekly
      • Title: Weekly
      • Granularity: Days
      • Time Units: 7
    • Monthly
      • Title: Monthly
      • Granularity: Days
      • Time Units: 28

Product / Product Variation

Location: admin/commerce/products

You are now ready to start creating some rental products!  The process mostly the same as creating any other Commerce Product / Variation, here is what is new:

Price:

  • Commerce requires that this field is set, so we default it to 0.00 because it is not used.

Rental Rate:

This is where we select a rental period that we created above and assign a price to it. 

  • Examples given below:
    • Daily Rate
      • Rental Period: Daily
      • $75
    • Weekly Rate
      • Rental Period: Weekly
      • $255
    • Monthly Rate
      • Rental Period: Monthly
      • $765
  • NOTES:
    • There is currently no REMOVE button. To delete a rental rate, empty the price field next to the rental rate.  Once you save the variation/product, that rate will be removed.

Configuration (Rental Reservation)

To track rental products by individual serial numbers, enable the 'Commerce Rental Reservation' sub-module.

Order Item Type 

Location: admin/commerce/config/order-item-types

Install Rental Reservation Trait:

  • Edit or create a new order item type.  Enable the 'Rental Reservation' trait by clicking the checkbox.
  • Save

Manage Form Display:

  • Navigate to the 'Manage Form Display' tab for the Order Item Type that you created/edited.
  • Make sure that the 'Rental Instance' field is not disabled if you want to allow people to select an instance manually.  The following settings should be used:
    • Rental Instance Widget: Select Option
  • Save the form display.

Product Variation Type

Location: admin/commerce/config/product-variation-types

Install Reservation Trait:

  • Edit or create a new product variation type.  Enable the 'Rental Reservation' trait by clicking the checkbox.
  • Set the Rental Instance Type
  • Save

Product Type

Location: admin/commerce/config/product-types

  • Edit or create a product type.  Make sure it points to a Product Variation Type that has the Reservation Trait enabled.
  • Navigate to 'Manage Display' for the product type.
  • For the 'Variations' field, make sure the format is set to 'Add to cart form' and that the 'Combine order items containing the same product variation' setting is UNCHECKED. This is important, because a rental order item is tied to a specific serial #, so it does not make sense to combine order items (the quantity will always be 1).  Price is calculated based on rental rates on the product variation, not quantity.

Order Type 

Location: admin/commerce/config/order-types

  • Edit or create an order type.
  • Change the Workflow to 'Fulfillment, with returns (rental)'.  This workflow provides States and Transitions that update the state of each individual serial # (rental instance) when they are sent out or returned.  These States on the Rental Instance are used to determine its availability.
  • Make sure the 'Enable order period for this order type' checkbox is CHECKED.
  • Save

Product / Product Variation

Location: admin/commerce/products

You are now able to attach Rental Instances to your product variations.  These entities are what stores the information on individual serial numbers.

Rental Instances

Rental instances are your individual units that you will be renting.

Serial Number:

  • This is the identifier for the rental instance.  It is not a primary key, as there is always a chance that two separate types of rental instances could share the same serial number.

Title:

  • The title for the rental instance is generally the same as the Product.  The purpose of the Title field is if you need to differentiate between two instances for whatever reason. 
  • Here's an example use case:
    • You have a rental product that comes in a 5-pack.  Something happens to one of the units, so maybe you want to change the title to 4-Pack so that your employees are aware.  

NOTES

  • Product Variations can share rental instances.  Use the 'Add Existing Rental Instance' to add a rental instance that has already been created instead of duplicating it.

KNOWN ISSUES

  • When creating a new Product that has not been saved and adding multiple Variations, after you save the first variation and go to create another one, you will notice that the Rental Instance list from the previous variation is populated.  This appears to be a bug with the Inline Entity Form.  In order to create separate rental instances for each variation, make sure to save the product after you create the first variation.

Help improve this page

Page status: Needs work

You can: