public void SetCurrentProduct(Shopify.Unity.Product product, int index) { gameObject.SetActive(true); TitleText.text = product.title(); DescriptionText.text = StringHelper.Ellipsisize(product.description(), MaxDescriptionCharacters); var variants = (List <Shopify.Unity.ProductVariant>)product.variants(); PriceText.text = variants.First().priceV2().amount().ToString("C"); var images = (List <Shopify.Unity.Image>)product.images(); ClickRegionButton.onClick.AddListener(() => OnClick.Invoke()); if (images.Count > 0) { _imageSrc = images.First().transformedSrc("compact"); } }
public void SetCurrentProduct(Shopify.Unity.Product product) { ProductTitle.text = product.title(); // Reset the variants dropdown VariantsDropdown.ClearOptions(); // Parse variant titles into a list of strings and assign to the dropdown as the new options var options = new List <string>(); var variants = (List <Shopify.Unity.ProductVariant>)product.variants(); foreach (var variant in variants) { options.Add(variant.title()); } VariantsDropdown.AddOptions(options); // Only need to show the variants dropdown if there are more than one variant to choose from VariantsDropdown.gameObject.SetActive(variants.Count > 1); // Show the appropriately positioned description text ProductTitleDescription.gameObject.SetActive(variants.Count > 1); ProductTitleDescNoVariant.gameObject.SetActive(variants.Count <= 1); VariantsDropdown.onValueChanged.AddListener(HandleDropdownChange); // Assign the first product image to the main product image display var images = (List <Shopify.Unity.Image>)product.images(); StartCoroutine(ImageHelper.AssignImage(images[0].transformedSrc(), ProductImage)); RenderVariantImages(images); ProductPrice.text = variants[0].price().ToString("C"); ProductTitleDescription.text = product.description(); ProductTitleDescNoVariant.text = product.description(); CurrentProduct = product; CurrentVariant = variants[0]; }
public void SetCurrentProduct(Shopify.Unity.Product product, int index) { gameObject.SetActive(true); SetNameHat(product.title()); var variants = (List <Shopify.Unity.ProductVariant>)product.variants(); var List_color_code_map = product.tags(); colorDefault = Utils.GetColorDefault(List_color_code_map); sku = Utils.GetSKU(List_color_code_map); var img = product.images(); foreach (Shopify.Unity.ImageEdge item in img.edges()) { string URLglobal = item.node().transformedSrc("large"); if (colorDefault != "" && sku != "") { if (URLglobal.Contains(sku + "-" + colorDefault + "-F01")) { string _URLImage = URLglobal; URLImage = URLglobal; Debug.Log("<color=blue> " + "hat: " + product.title() + " URL" + _URLImage + "</color>"); StartCoroutine(Utils.OnDownloadImage(_URLImage, (spri) => { SetImageHat(spri); })); } } } string price = variants.First().price().ToString(); priceHat.text = "$ " + price; hatButton.onClick.AddListener(() => OnClick.Invoke()); }
public void SetCurrentProduct(Shopify.Unity.Product product) { if (hatData.GethatName() == hatName) { return; } else { ResetValue(); finishDownloadImage = false; //productImage.sprite = waitIcon; } this.product = product; hatName = product.title(); productTitle.text = hatName; var variants = (List <Shopify.Unity.ProductVariant>)product.variants(); string metafield = variants[0].metafields().edges()[0].node().value(); var splitData = metafield.Split('\v'); string data = ""; for (int i = 0; i < splitData.Length; i++) { data = data + splitData[i]; } info_JSON = JsonUtility.FromJson <Info_JSON>(data); //specifications for (int i = 0; i < info_JSON.specs_variant.Count; i++) { string title = "<b>" + info_JSON.specs_variant[i].title + "</b>" + " : "; string text = info_JSON.specs_variant[i].text; text = text.Replace(""", "''"); specifications.text = specifications.text + title + text + "\n"; } //materials for (int i = 0; i < info_JSON.materials.Count; i++) { string title = "<b>" + info_JSON.materials[i].title + "</b>" + " : "; string text = info_JSON.materials[i].text; materials.text = materials.text + title + text + "\n"; } //information basic for (int i = 0; i < info_JSON.summary_box.Count; i++) { string title = info_JSON.summary_box[i].title; string text = "<b>" + info_JSON.summary_box[i].text + "</b>"; var info = Instantiate(infoBasicPanel, contentInfoBasic); info.SetActive(true); info.GetComponent <InfoBasic>().title.text = title; info.GetComponent <InfoBasic>().text.text = text; if (i < info_JSON.summary_box.Count - 1) { var lin = Instantiate(line, contentInfoBasic); lin.SetActive(true); lines.Add(lin); } infoB.Add(info); } // Utils.GetBrimGruop(product, brimGruop , brimGruopTitle); // Utils.GetCrownShape(product, crown, crownTitle); // productImage.sprite = hatData.GethatImage(); var options = new List <string>(); var List_color_code_map = product.tags(); var img = product.images(); foreach (var variant in variants) { if (variant.availableForSale()) { string name = variant.title(); string[] names = name.Split('/'); var NameColor = names[0].Trim(); var NameSize = names[1].Trim(); if (m_ColorsAndSizes.Count > 0) { if (SearchColorName(m_ColorsAndSizes, NameColor) == false) { ColorsAndSizes d = new ColorsAndSizes(); d.NameColor = NameColor; d.sku = Utils.GetSKU(List_color_code_map); string tagColor = "color_code_map:" + NameColor; d.color_code_map = Utils.GetColorCodeMap(List_color_code_map, tagColor); List <ReferienceHats> m_ReferienceHats = new List <ReferienceHats>(); string _URLImage = ""; string _URLExperienceImage = ""; foreach (Shopify.Unity.ImageEdge item in img.edges()) { string URLglobal = item.node().transformedSrc("grande"); string URLExperienceglobal = item.node().transformedSrc("grande"); if (d.sku != "" && d.color_code_map != "") { string text = d.sku + "-" + d.color_code_map; if (URLglobal.Contains(text + "-F01")) { _URLImage = URLglobal; } //if(SearchReferienceceName(rh, URLglobal) == false) //{ //} SearchTypeViewHat(m_ReferienceHats, URLglobal, text); //ordenar la lista(vistas del sombrero) m_ReferienceHats = Utils.onSortReferienceList(m_ReferienceHats); string v = d.sku + "-" + d.color_code_map; if (URLExperienceglobal.Contains(v + "-HF01")) { _URLExperienceImage = URLExperienceglobal; } else if (URLExperienceglobal.Contains(v + "-HM01")) { _URLExperienceImage = URLExperienceglobal; } else if (URLExperienceglobal.Contains(v + "-MF01")) { _URLExperienceImage = URLExperienceglobal; } } } d.URLImage = _URLImage; d.URLExperience = _URLExperienceImage; d.sizes.Add(NameSize); d.ReferenceHats = m_ReferienceHats; m_ColorsAndSizes.Add(d); } else { AddSizes(m_ColorsAndSizes, NameColor, NameSize); } } else { ColorsAndSizes d = new ColorsAndSizes(); d.NameColor = NameColor; d.sku = Utils.GetSKU(List_color_code_map); string tagColor = "color_code_map:" + NameColor; d.color_code_map = Utils.GetColorCodeMap(List_color_code_map, tagColor); List <ReferienceHats> m_ReferienceHats = new List <ReferienceHats>(); string _URLImage = ""; string _URLExperienceImage = ""; foreach (Shopify.Unity.ImageEdge item in img.edges()) { string URLglobal = item.node().transformedSrc("grande"); string URLExperienceglobal = item.node().transformedSrc("grande"); if (d.sku != "" && d.color_code_map != "") { string text = d.sku + "-" + d.color_code_map; if (URLglobal.Contains(text + "-F01")) { _URLImage = URLglobal; } //if (SearchReferienceceName(rh, URLglobal) == false) //{ //} SearchTypeViewHat(m_ReferienceHats, URLglobal, text); //ordenar la lista(vistas del sombrero) m_ReferienceHats = Utils.onSortReferienceList(m_ReferienceHats); string v = d.sku + "-" + d.color_code_map; if (URLExperienceglobal.Contains(v + "-HF01")) { _URLExperienceImage = URLExperienceglobal; } else if (URLExperienceglobal.Contains(v + "-HM01")) { _URLExperienceImage = URLExperienceglobal; } else if (URLExperienceglobal.Contains(v + "-MF01")) { _URLExperienceImage = URLExperienceglobal; } } } d.URLImage = _URLImage; d.URLExperience = _URLExperienceImage; d.sizes.Add(NameSize); d.ReferenceHats = m_ReferienceHats; m_ColorsAndSizes.Add(d); } options.Add(variant.title()); } } //if (m_ColorsAndSizes.Count > 1) // tryButton.interactable = true; //else // tryButton.interactable = false; //GetImages OnGetHatImageColors(); OnGetHatReferience(); OnGetHatExperience(); //instantiate colors if (m_ColorsAndSizes.Count <= 0) { addToCartButton.interactable = false; ChangeColorAddCartButton(false); } for (int i = 0; i < m_ColorsAndSizes.Count; i++) { var colorLocalButton = Instantiate(colorButton.gameObject, colorButton.gameObject.transform.parent); colorLocalButton.name = m_ColorsAndSizes[i].NameColor; int indexHat = i; colors.Add(colorLocalButton); colorLocalButton.GetComponent <Button>().onClick.AddListener(delegate { InstantiateSizes(true, colorLocalButton.name, indexHat); }); colorLocalButton.SetActive(true); nameLocal = m_ColorsAndSizes[0].NameColor; } CurrentProduct = product; CurrentVariant = variants[0]; if (m_ColorsAndSizes.Count > 0) { InstantiateSizes(true, m_ColorsAndSizes[0].NameColor, 0); } else { onlyHat.sprite = hatData.GethatImage(); productImage.sprite = hatData.GethatImage(); onlyHat.gameObject.SetActive(true); iconMask.SetActive(false); } }