Display order line items as menu items in dropdown menu for logged in customers on product pages

We sell custom framed illustrated prints. I’m offering a collection of matching companion products (pint glasses, placemats, etc) to those customers who have purchased a print in the past.

To order one of these products, the customer must be logged in and have an order in their account that contains a framed print. Once that criteria is met, the product page will display a menu that allows the customer to select the order line containing the print they would like to apply to the product. The selected order is passed as a line item property on the order.

I solved this down to the order level using custom metafields with this code:

{% if customer %}
{%- if customer.metafields.custom.buyer != true -%}

Sorry. You don't seem to have any Custom Half Hull Print orders in our system to choose from.

{%- else -%}

I have a flow setup that sets the customer Buyer metafield to true when a customer orders a print, and another that sets the order Art metafield to true at the same time.

Works great for orders with only one print, but need a solution for orders that contain more than one custom print. I need the menu to paint out each order line that contains a print.

Any ideas?

HI @Michael_Boardm1 ,

We can fetch all orders and for each order, we check the custom art metafield.

Similarly, we create a select option with multiple selection.

It may solve your issue.

Thank you

Thank you. I’ve written the code to check the art metafield, but don’t know how to identify the order lines that contain print orders and make them options in the select menu.

I need to access the code. Without the code, I cannot help you out.

Thank you

Something similar to this?

The product type condition is for example only – you should use the one that matches your setup.

{% if customer and customer.metafields.custom.buyer == true %}
  
{% else %}
  

Sorry. You don't seem to have any Custom Half Hull Print orders in our system to choose from.

{% endif %}