Hello.
In my theme liquid file, I’m trying to get my model model3d (.glb) file URL. I can get the file ID by doing.
var glbModelFileUrl = "{{ product.metafields.custom.canopy_model.value['3d_model_file'] }}";
//Reulst: gid://shopify/Model3d/idofmymodel
var glbModelFileUrl = "{{ product.metafields.custom.canopy_model.value['3d_model_file'] | file_url }}";
//Using this gives me this error: Cannot apply file_url to a 3D model, not supported.
var glbModelFileUrl = "{{ product.metafields.custom.canopy_model.value['3d_model_file'].sources[0].url }}";
//this gives empty string
I can’t figure out how to get the URL. I have the file attached to the product object in my metaobject.
HI @pzagor2 ,
Try assigning the object to a variable in liquid first like so:
{% assign glbModelFile = product.metafields.custom.canopy_model.value['3d_model_file'] %}
Then, try accessing the file url with that variable inside the output tag.
{{ glbModelFile| file_url }}
Let me know if this works.
If this was useful, a Like or marking it as a Solution is appreciated. Need more help? Feel free to reach out anytime using the email address/phone number in my signature.
Thank you for the suggestion, but unfortunately I get the same error:
Cannot apply file_url to a 3D model, not supported.
@pzagor2 Can you send me your 3D model here so I can try uploading it on my end and troubleshooting it?
I was able to get the URL with
window.model3dUrl = "{{ product.metafields.custom.canopy_model.value['3d_model_file'].value.sources[0].url}}";
@marcuswebexp Thank you for taking the time and helping.
Hi @pzagor2 ,
No problem. Happy to help!