I’m using schema to customize the way user can set things on Shopify. So my code is like this:
{
"type": "number",
"id": "product_variant_id",
"label": "Product ID"
}
If I run a console log on this i’m getting product handle:
product-handle-from-collection-x
It is possible to retrieve the first product variant ID of this product?
- I tried to use {{ all_products[“product-handle-from-collection-x”].first_available_variant.id }}
- It works on Product Page. Not on Checkout
Anyone knows if the Checkout.liquid Page doesn’t accepts this?
Is your section installed on checkout? Be aware that checkout.liquid is a different template from theme.liquid.
A bit more info would help us to understand better the issue.
Thanks for your attention Mircea,
Yes. The section is now rendering inside of the Checkout.liquid
Basically all I want is to allow the admin to pick a product via Shopify Customizer and then I get the product variant from it.
Right now when I console.log
the section.settings.gwp_product
I get the product Handle.
I was wondering if I should do a json /admin/api/2021-01
and filtering by Product Handle or if there is a simple way that I’m not seeing.