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:- Select Operations >> Manage form display.
- Select the "Variation Cart Form" form view mode.
- 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).
- Click "Save" to save your changes.
- Configure Product Variation Types in
Administration >> Commerce >> Configuration >> Product Variation Types
For each Product Variation:- Select Operations >> Manage display.
- Select the appropriate view mode.
- Set the "Add to cart form" field to "visible".
- 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.
- Click "Save" to save your changes.
- Configure Product Types in
Administration >> Commerce >> Configuration >> Product Types
For each Product Type:- Select Operations >> Manage display.
- Select the appropriate display mode.
- For the "Variations" field, select "Rendered Entity" instead of "Add to cart form".
- Click the settings icon and select the view mode that you configured in the previous step.
- Click "Update" to update the settings, then click "Save" to save your changes.
- Click the product type "Edit" tab.
- 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
- Module categories: E-commerce
- Ecosystem: Commerce Core
- 1,741 sites report using this module
- Created by John Pitcairn on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Minor security fix
Development version: 8.x-1.x-dev updated 14 Jun 2023 at 04:24 UTC