We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

order file metafield url

order file metafield url

arlo1
Tourist
7 0 1

Hi I have a file metafield setup on my orders page that I add an image to and I am trying to fetch the publicly accessible  cdn link (so my customers can view the image) and add this to the order shipped email. 

 

I keep getting the gid: url which isnt publicly accessible.

 

All the Photos are uploaded to my internal Shopify files all of which have a public link.

 

Does anyone know of a way to fetch this public link and display it in a notification email?

 

Many thanks

Replies 5 (5)

tim
Shopify Partner
4812 598 1733

Can you share a code you're using?

I guess you're missing some .value properties and file_url filters....

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
arlo1
Tourist
7 0 1

Hi @tim  Ive tried this, which it doesnt display the photo in the email...

    {% assign safe_photo = order.metafields.my_fields.safe_place_photo %}
    {% if safe_photo != blank %}
      <p>
        <img src="{{ safe_photo | file_url }}" alt="Safe place photo" style="max-width: 100%; height: auto; border-radius: 8px;" />
      </p>
    {% endif %}

 and this, where it just returns the gid: link

{% assign file = order.metafields.my_fields.safe_place_photo %}
{% if file != blank %}
  <p>Photo URL: <a href="{{ file | file_url }}">{{ file | file_url }}</a></p>
{% endif %}

 

I'd really appreciate any suggestions on how to display public link.

 

Many thanks 

tim
Shopify Partner
4812 598 1733

Have you tried 

{% assign file = order.metafields.my_fields.safe_place_photo.value %}

Because it is .value actually turning a gid into an object.

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
arlo1
Tourist
7 0 1

I have just tried

{% assign file = order.metafields.my_fields.safe_place_photo.value %}
{% if file != blank %}
  <p>Photo URL: <a href="{{ file | file_url }}">{{ file | file_url }}</a></p>
{% endif %}

 

But unfortunately it didn't return anything.

 

If you have any other suggestions they would be greatly appreciated!

tim
Shopify Partner
4812 598 1733

Not much I can suggest from the outside. Try https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-file_reference ?

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com