{{ product.metafields.myfields.myfield.updated_at }} | Shopify Liquid | Metafields - shopify

I wanted to ask if it is possible to show the time when a metafield was updated using Shopify Liquid. I tried these ways:
{{ product.metafields.myfields.myfield.updated_at }}
{{ product.metafields.myfields.myfield.updatedAt }}
But neither of those work.
I would very hope someone can help me.
Bye!

It is not possible with Liquid. Shopify does not expose the updated_at date of a resource like a Metafield. You get access to the Metafield attributes they figure matter.
If you absolutely had to know, the long-winded approach would be to render the Metafield ID (not sure you can do that, but you can try anyway), and assuming you got that, you could call an App Proxy with that ID and assuming your App installed in the store had any permissions on the resources assigned the Metafield, you might be able to read the updated_at date using an API call. You could then respond with JSON and do as you wish with that date. Like I said. Long-Winded
TL:DR; No. You do not get to play with dates on metafield resources.

Related

How to call a metafield value on the checkout page in shopify

I'm trying to display the item data from the metafield on the checkout page using this code-
{{ pages.package-urls.metafields.custom.checkout_message }} on checkout.liquid file.
We are using Shopify Plus and the metafields are displaying on other templates fine.
As usual, you are falling victim to the documentation. Since you want to display a metafield, if you truly know it has a value, you have to express you want the value. I think your attempt at using the pages object is mis-guided, as checkout is not a page, but, you may be right there, and it may in fact be available in checkout. Anyway, tack on a value.
{{ pages.package-urls.metafields.custom.checkout_message.value }}
As you read your metafield out backwards though, you will see that you are breaking all kinds of rules. Specifically. A metafield resource has a value. It has a key (checkout_message), it has a namespace (custom) and it has a parent resource (metafields in Shop, or Product, or Page).
So what are you doing with package-urls and pages? Strange stuff. I think you might want to anchor this to the Shop. That will likely work a lot better.

How to create 2 unique Headers with complete different navigations on Venture Free Theme of shopify?

I just want to ask the community if you have any idea, how to create a unique header for a specific page on shopify.
Theme is Venture(Free Version)
I want to have UK page and US page on my shopify store. My index page is UK based or international clients. While the US page is for US customers only. I want to have a different header and navigation for US page since there are products that are not available for US customers. I just want to post US only products.
Anyone can help me with this? Thank you!
This will require more than just a header change, but it is possible to have two separate headers.
However, the localization may be tricky.
According to Shopify docs:
Your theme's primary language cannot be a regional variant when using
Shopify Markets. For example, you should not change your primary
language to English (United States). It should be English.
This can be done by assigning an array of IP addresses to an variable that is placed in several conditionals.
This process is far too advanced for laymen. If you are not comfortable with liquid and javscript, You can use Nosto or the app Geo-targeting.
If you are looking to do this yourself, please refer to the docs regarding the ‘browsing_context_suggestions.json’ endpoint.
This will then need to be compared to an array of some sort that will assign your customers to a region.
Then, assign that endpoint to a variable and use that variable as a conditional to display your menu with:
{% assign menu = [british menu] %}
I know how to do this, so if you need help I can set it up. It just won't be free, and I recommend trying the apps before you hire unless you are scaled properly for development.
You will then need to lock your products by region, which is done in ruby. You have limited access to ruby through liquid, and backend editing of this sort requires an app. You cannot region lock products in front end without a ton of work and it will be extremely unstable, expensive, and will not lock search results regionally.
So try Locksmith to region lock products. I haven't used it, so my suggestion is blind there, and some experimentation may be required.

Get Products metafields with rest api in shopify react-app

I am trying to access shopify product metafields same like products getting with rest-api and also i am using shopify-api npm package to get metafields but we are receing empty metafields array
enter image description here
enter image description here
Please help me to resolve that..
There are a couple of potential reasons. One, perhaps that product actually has no metafields. Or two, perhaps your API has no permission to read the metafields assigned to the product.
A sure fire way for you to establish if your code is working or not, is to use your API key to write a metafield. Verify it exists. Then use your code to read the metafield you created. With that, you know your code is working.

How to add a metafield to a customer in Shopify

I'm creating a signup form on my Shopify store, for customers. I'm willing to have them enter their basic credentials (email) plus additional info. I'd like to have that additional info stored in the customer's metafields.
I've seen here: http://docs.shopify.com/manual/configuration/store-customization/capture-additional-information-in-the-account-registration-form I can ask customers for additional information in the form of notes, but found no path to insert metafields.
I think this is possible, but I don't know how I could do.
Could someone help me, please?
See here:
For the time being, you can only add these metafields and edit them using the Shopify API. Some time from now, we will make it possible for a shop owner to manage them from the admin interface.
As far as I am aware this is still the case, and you must use the API to create/access metafields. See the Shopify doco on Metafields here.
Alternatively, there are apps that can help with the process.
Since it isn't possible to create a new area in the admin to hold the user's information, so technically you can't add a metafield to a customer.
But you can add a new field on registration page as a customer note.
All additional collected information will be displayed on the customer account page.
Add following lines inside {% form 'create_customer' %} and {% endform %} to add your custom field. Replace the [Label] with your own unique label.
<label>The text shown as label in the form</label>
<input type="text" name="customer[note][Label]" placeholder="Placeholder text" />
The attribute name="customer[note][Label]" is essential here. With it, the information will be submitted as a customer note. Without it, nothing will be submitted.

Getting current Product ID with Shopify API for a Javascript API call

I'm toying with developing a Shopify App that uses the DaisyAPI dynamic image service for Shopify. In order to make the correct call to the Daisy API, I need to know what Product the customer is looking at. It seems like, to reliably do that, I will need to manipulate their product.liquid theme to insert a hidden value containing the Product ID so that Jquery can pick up that value and insert it into the API call.
What's the best way to ensure every product page contains the product ID in such a way jQuery can reliably find it? Am I overlooking something obvious?
Many thanks!
Another option would be to use the Ajax API to request the product. Of you know you're on a product page simple make a request to the same URL and append .json. You will then have a json representation of the product that you can do whatever yo want with.
To get you js into the theme you can use a script tag which will load js from you server onto the shop.
You are missing a very obvious and cool Liquid filter.
In Liquid, pump the Object for it's JSON.
var p = {{ product | json }};
And then go to town... you cannot go far on the client without this concept. Get the JSON man.. get the JSON...