I tried adding an add to cart button to my all products view by adding product variation and choosing the add to cart form formatter. When I choose Rendered entity the variations are rendered correctly. I checked the logs but could not find any related messages.

Comments

bdichgans created an issue. See original summary.

bbuchert’s picture

vasike’s picture

Title: Product View does not show add to cart button » AddToCartFormatter not working in Views
Version: 8.x-2.0-beta6 » 8.x-2.x-dev
Assigned: Unassigned » vasike

I'm looking at this

It seems the issue it's about using AddToCartFormatter for "variations" field in Views.
Re-titled.

vasike’s picture

Status: Active » Needs review

And there is a PR for this
https://github.com/drupalcommerce/commerce/pull/720

It seems that viewElements in formatter expects to return an Elements array
So i updated putting the "lazy_builder" inside "an element"
I also added some extra tests for MultipleCartFormsTest, using a second (new) View in "commerce_cart_test" module.
This view uses fields row type - variations field with "commerce_add_to_cart" formatter.

bbuchert’s picture

If I want to test this i need to use the latest dev version correct? I can't apply this to the latest release?

  • bojanz committed b9ef8d0 on 8.x-2.x authored by vasike
    Issue #2868637 by vasike: AddToCartFormatter not working in Views
    
bojanz’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bbuchert’s picture

It works for me only issue is that when I want to reuse the field as a token it seems not render. I opened another issue for this: https://www.drupal.org/node/2882542