How to call a metafield value on the checkout page in shopify - 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.

Related

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

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.

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.

Passing data to shopify product/cart from a custom page

I have made this page https://tns.webwars.eu. This is a form that creates a skymap in away by filling the fields and then posts the data to https://the-night-sky.com/cart. I am using the cart.attributes feature at the moment but this applies for the whole cart and I want individual data for each item. Eg. If someone tries to add another map with different information.
Is there another way to pass the field values to the cart and therefore to checkout and confirmation email?
Thank you in advance
You should use Line Item Properties as described in good detail here: https://help.shopify.com/en/themes/customization/products/features/get-customization-information-for-products
That technique is per product, works perfect with the cart, checkout and admin, and is much easier to maintain than cart attributes.
You can use Shopify's Ajax API for that purpose:
https://help.shopify.com/en/themes/development/getting-started/using-ajax-api
Shopify provides shop-owners with an Ajax API that returns JSON-encoded responses.
This Ajax API makes it possible to add items to the cart, update quantities in the cart, and fetch information about the cart, without a page refresh. With this API, you can also fetch information about a particular product using its handle.
For example, on site: https://weedrepublic.com

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.

Shopify Using Cart Cookie to track cart id

This is cross posted from the shopify api forum-
I have an app that relies on identifying the cart order as it is created, and then matching up that id with any order that comes in (assuming that a cart ultimately becomes an order). Per #HunkyBill's advice, this is accomplished by reading the 'cart' cookie. This does work, however it seems like a fragile way to do something that seems like it should be done with the cart object. I have two questions:
What happens if the user has cookies turned off (is there no way then to access cart id while it is still a cart.. pre-order)?
and
Is it possible to simply add the CartId as a variable to the cart object?
Every other object has its own id, which can be accessed through Liquid... EVERY one. Except for the cart object- which is the ONLY object that links directly to another object, the Order. I do fully understand that Shopify may need a cookie variable to perform some of its functionality- and I am not suggesting modifying that process in any way. However the addition of the Cart Id to the cart object would solve all of these issues (for app developers) and provide a simple way to line up cart activity with converted orders. It also would not affect any products already built using the cart cookie.
If there is a better solution/technique for identifying a cart and then later associating it with a order, I am all ears. I am a bit stunned that this critical functionality (essentially tracking conversion) is not handled in a more robust and consistent way.
If the user has cookies turned off, then you're hosed regardless. They won't be able to build a cart without the session id from the cookie.
For the cart: You're correct, on the front end the liquid cart object doesn't have the token included. It's only available through the cookie.
This is for a couple of reasons for the omission:
First, there's only ever one cart active in a view at the time, so there's no need to differentiate it while rendering a page.
Second: Within the context of the view, the token is meaningless. The user is never going need to see it.
Personally I don't buy the argument that relying on cookies for data is fragile. Indeed, the cart variable that pops up in liquid is loaded based on the session id found in the very same cookie.
That said, I can't think of a good reason for it NOT to be included in the liquid object. I'm going to file it as a low priority feature request.