2

With Drupal Commerce 8.x-2.0-beta5, I created some products and a view that lists all products with their variations.

I wanted to add the cart form to any variation, but I was not able to do so.

How can I achieve it?

2 Answers 2

4

To display an "add to cart" button on a product's display you need to:

  1. Go to /admin/commerce/config/product-types/TYPE/edit/display
  2. Make sure that Variations field is displayed
  3. Select "Add to cart form"

Views display:

You simply need to add the "Product: Variations" field and set its display as "Add to cart form"

You of course you need to have the "Commerce Cart" module enabled :)

Not intuitive really. I might end up using Commerce Variation Add to Cart module.

1

You can use this module Commerce Variation Add to Cart

How to use it?

After you install the module go to product types 'admin/commerce/config/product-types' and click on the Edit button of your product type. Now go to Manage display tab and choose 'Variation add to cart form' as a formatter for Variations field. If you click on the gear icon, you can see additional settings.

After that choose Product variation referenced from variations as a relationship in your view and add the field Product: Variations with the formatter Variation add to cart form.

Also, see this thread https://www.drupal.org/node/2834812

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.