Rest API determine if product has variants or no variants

New Member
5 0 0

I understand in the Shopify api a product will always have 1 variant even if the end user doesn't setup variations in the admin panel. I need to be able to detect if the product coming back from rest API has 1 real variation OR just the default variation (used when a product does NOT have any variations)

What I am doing now is

//if we have more than 1 variation I know it is using real variations...But if an end user sets up a product with 1 variation I want to detect that also. So I check the title field NOT being Default Title

if (count($result['product']['variants']) > 1 || $result['product']['variants'][0]['title'] != 'Default Title')

This feels really hacky; but there isn't a field in the product rest api I can use.