1

I am building a shop on Drupal 9 ,Commerce 2, and want to implement a "my favorite products"-bookmark, so that a user can bookmark products and save them for later. So, I installed flag module and created a flag for product variations which shows up in my products -> variations types -> variation -> manage display as follows:

enter image description here

I flushed all caches, went to the site, and it throws the "the website encountered an unexpected error"-error. In the logs, it says:

"DomainException: When a #lazy_builder callback is specified, no properties can exist; all properties must be generated by the #lazy_builder callback. You specified the following properties: #attributes, #ajax_replace_class, #type, #optional, #process, #pre_render, #theme_wrappers, #defaults_loaded. in Drupal\Core\Render\Renderer->doRender() (line 335 of /home/domain.com/public_html/core/lib/Drupal/Core/Render/Renderer.php)."

When I set a bookmark flag for a product type (not product variation type), It doesn't break my site, but the bookmark link simply doesn't render (in Bartik theme).

Does anybody face similar problems with flag and commerce or can anyone point me any way to make it work? Should I build products as content type nodes instead of commerce products, to make it work?

Thank you very much in advance! Everything I can find is old patches and discussions about Drupal 7 and commerce...

6
  • Flags haven't worked on variations for some time. We use them on the product level and use content for displays as a work around. – tonytheferg Jan 15 at 23:15
  • 1
    Actually, better yet, see this issue. They are working on it. A new patch was posted yesterday. drupal.org/project/commerce/issues/3120117 – tonytheferg Jan 15 at 23:26
  • @tonytheferg Man, thanks for replying! I'd be good with rendering the link on product level. But could you specify "to use content for displays as workaround"? Do you have a content type and add it for each product as a reference? – what ever Jan 15 at 23:46
  • You can reference a product on content as a rendered entity, but I would not make that decision just based on flags scenario. If you don't want to/ need to use content types as your display, you can just use the patch so that you can flag the variation. All depends on your use case. – tonytheferg Jan 16 at 3:09
  • see the docs here on adding a product reference to a content type. You could then flag the product instead of the variation. docs.drupalcommerce.org/commerce2/developer-guide/products/… – tonytheferg Jan 16 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.