Best answer

Shopify multi line - "The merchandise variant referenced by this term condition could not be found"

  • 21 November 2023
  • 7 replies
  • 99 views

I am unable to create a draft order in shopify with multiple products on the same draft. It works if I only have one item per order. So, I know all my Product IDs are correct. When I try to add multiple Product IDs I get the following error: 
“The merchandise variant referenced by this term condition could not be found.”

I have tried listing the product IDs in the custom Product Line Item as
an array: [12345, 23456, 34567 ]
as a JSON format: line items: [ {id: ‘12345’, ‘23456’, ‘34567’}]
and by using a Javascript output for line items with a similar structure as the JSON format above.

 

 

icon

Best answer by Troy Tessalone 21 November 2023, 21:18

View original

7 replies

Userlevel 7
Badge +14

Hi @CMN1723 

Good question.

Some things to check.

  • Some Products may need a Product Variant specified.
  • The Product Quantities provided may not match the # of Product IDs provided.

 

NOTE: You should be able to replace all the Formatter steps with 1 Code step to save Zap Tasks.

 

 

Hi Troy! 

Thanks for the quick reply! 

I have all the product variant IDs as well and they all work when I test the Zap using only one product at a time. There are 16 products total and the product IDs and variant IDs never change. It’s when I try to have more than one product on the same order that I get this error.

I have a feeling I am formatting the line items improperly. 

Userlevel 7
Badge +14

@CMN1723 

You may need to use the Formatter > Utilities > options related to line items.

 

Make sure the Product field is getting an array of line items. (rather than a comma separated string)

 

Try removing all the extra spaces between mapped variables.

 

Hi @Troy Tessalone 

Thanks for your help. I have tried adding the product lines as a string sperated by commas and removed all the extra spaces, I also tried listing the products as an array (with and without spaces).

Unfortunately, I am still getting the same error. 
“The merchandise variant referenced by this term condition could not be found.”
 

 

Userlevel 7
Badge +14

@CMN1723

You may have to try process of elimination to determine if there is a specific product/variant that is causing the issue.

 

Did you try converting the list of IDs/Values for Product/Variant/Qty to an array of line items using the Formatter?

You may need to use the Zap action: Formatter > Utilities > Text to Line Items

Userlevel 7
Badge +14

@CMN1723

Putting the brackets [] around the string of values won’t work.

Formatting the string of text as a line item using Formatter > Utilities > text to Line Items worked! I did have to do some more formatting to account for 0 quantity choices but I was able to create a draft order with multiple products. 

Thank you so much, @Troy Tessalone!

Reply