0

I have a drupal 8 commerce website. The Orders page is a view that comes with commerce where all the orders are listed. Is it possible to add/create ( on the website or programatically ) an exposed filter based on a PRODUCT ATTRIBUTE to show all the orders containing a value of that product attribute?

For example: for a product attribute called ORIGIN, I would like an exposed filter in the orders view that would allow me to choose between 2 values: Los Angeles or San Francisco.

Some orders will show up in both because they will have different products with different ORIGIN value product attributes.

I tried to modify the orders view but I couldnt find any product attributes nor a relationship to products. I tried to add a relationship to order item but that didn't help expose any of the product attribute fields.

0

Product's attributes are set through the product variation. You need to add the Variations through a relationship and you will have attributes available there.

Products Variation form

After that your attributes can be added as exposed filters.

A view

Sorry I don´t have any English sites available but pay close attention to captures.

  • thanks man... for some reason the product variation did not show up in the relationship unless i added order_item first... thanks, you're the man – Nathan Jan 13 at 21:24
  • 1
    Thats correct since orders are composed by order items and order items are linked to products variations no the product itself, I forgot to clarify that in my answer – d70rr3s Jan 14 at 7:45

Your Answer

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

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