I've entered a few products into the WooCommerce Linked Products field for Upsells. I would now like to create a view to display these linked products on my product page.
Hi, WooCommerce stores this information in a serialized array and unfortunately Views is not designed to be able to loop over this kind of information directly. We do provide a shortcode that can be used to display upsell products on the single Product template using a standard WooCommerce format - wpv-woo-show-upsell-items. Unfortunately it is not customizable as a View. Documentation for this shortcode:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#vf-334617
Another User shared a custom code solution that creates a shortcode you can use to generate a list of upsell product IDs. If you can produce a list of upsell product IDs with a custom shortcode, I can show you how to use that shortcode in a View to generate a View of upsell products filtered by product ID using a shortcode attribute. However, since it is custom code I can't debug problems with it. Here is the ticket with more information about this custom code:
https://toolset.com/forums/topic/upsell-and-cross-sell-filter/
If you're able to use this custom code to produce a list of upsell product IDs, I can show you how to use that with a Post IDs Query Filter in a View of Products. Let me know how you would like to proceed.
Ok, maybe this can be done another way. Ultimately, I'm trying to create a many to many relationship between items in the same post type (products), is this possible? Create a field, a tag or category that is populated by the list of posts (products) that I can select from to make connections? Then I could create a view of those relationships for a single product?
Unfortunately Types Post Relationships and Post Reference fields can only be established between items in different post types. It's a limitation of the currently implemented Post Relationships feature. To relate items from the same post type, a taxonomy or a custom field is required. The main difference between those two options is that taxonomies get automatically created archives, but custom field values do not. I find taxonomies to be easier to manage in wp-admin and Forms, because they implement an autosuggest field so you can begin typing and choose the term easily from a list of suggestions. Custom fields do not implement this type of field, so it makes management more difficult.
Whether you choose to use a custom taxonomy or a custom field, you can then create a View filtered by that criteria and place it on the single Product template to display a list of similar products.
My issue is resolved now. Thank you!