How to base on Product handle to retriever all variant ID of option1

Hi Namphan,

Tks for your advice first. I actually able to capture the event in global.js file as below but fetch not work. Would you please help to advise how to amend below code to get all option1’s variant ID?

document.addEventListener(‘DOMContentLoaded’, function() {
// Function to handle clicks on product links
function handleProductLinkClick(event) {
const productHandle = this.getAttribute(‘data-selected-product-handle’);

// Retrieve the product data using Shopify’s frontend API endpoint
fetch(‘/products/’ + productHandle + ‘.js’).then(function(response){ return response.json() }).then(
function(product){
let variant = product.variants.find(function(variant){ return variant.id == variant_id })
// Do stuff with your product & variant objects
}
)
)