This module provides an add-to-cart form for individual Commerce Product Variation entities. The form is added to the Product Variation "manage display" tab as a field, and uses the standard Commerce add-to-cart form functionality.

Form elements may be configured via a form display mode, "Variation Cart Form", on the Commerce Order Item Type "manage form display" tab - similar to configuration for the standard Commerce Product add-to-cart form.

Typical use cases

  • The standard Commerce Product add-to-cart form needs to be replaced with the individual Product Variations as rendered entities, each with their own add-to-cart functionality
  • An individual Product Variation entity needs to be displayed standalone with its own add-to-cart functionality (including Views).
  • The add-to-cart form needs to be displayed among the Product Variation fields.

Requirements

Drupal Commerce modules:

  • Commerce Product
  • Commerce Order
  • Commerce Cart

Configuration

  • Configure Order Item Types in
    Administration >> Commerce >> Configuration >> OrderItem Types
    For each Order Item Type:
    1. Select Operations >> Manage form display.
    2. Select the "Variation Cart Form" form view mode.
    3. Show or hide and configure form fields as desired. Typically you will will either want only the "Quantity" field displayed, or no fields displayed (to show an "add to cart" button with default quantity 1).
    4. Click "Save" to save your changes.
  • Configure Product Variation Types in
    Administration >> Commerce >> Configuration >> Product Variation Types
    For each Product Variation:
    1. Select Operations >> Manage display.
    2. Select the appropriate view mode.
    3. Set the "Add to cart form" field to "visible".
    4. Check the "Combine order items containing the same product variation" checkbox if you want the added Product Variation to be combined with the same item if it already exists in the user's cart.
    5. Click "Save" to save your changes.
  • Configure Product Types in
    Administration >> Commerce >> Configuration >> Product Types
    For each Product Type:
    1. Select Operations >> Manage display.
    2. Select the appropriate display mode.
    3. For the "Variations" field, select "Rendered Entity" instead of "Add to cart form".
    4. Click the settings icon and select the view mode that you configured in the previous step.
    5. Click "Update" to update the settings, then click "Save" to save your changes.
    6. Click the product type "Edit" tab.
    7. Uncheck "Inject product variation fields into the rendered product." This prevents the default variation cart form being duplicated into the product fields.

Similar modules

Commerce Variation Add To Cart provides a field formatter for the Product's variation reference field that displays each Product Variation separately with configurable attributes.

Project information

Releases