public void SetCurrentProduct(Product product, ProductVariant variant, int quantity) { gameObject.SetActive(true); info.text = ""; ProductTitle.text = product.title(); Quantity.text = quantity.ToString(); Price.text = "$ " + variant.price().ToString(); var options = variant.selectedOptions(); string sku = ""; string code = ""; if (options.Count > 0) { for (int i = 0; i < options.Count; i++) { info.text = info.text + options[i].value(); if (i == 0) { info.text = info.text + " / "; } } string tagColor = "color_code_map:" + options[0].value(); code = Utils.GetColorCodeMap(product.tags(), tagColor); sku = Utils.GetSKU(product.tags()); } try { foreach (Shopify.Unity.ImageEdge item in product.images().edges()) { string URLglobal = item.node().transformedSrc("large"); if (sku != "" && code != "") { string text = sku + "-" + code + "-F01"; if (URLglobal.Contains(text)) { Debug.Log("<color=blue> " + URLglobal + "</color>"); StartCoroutine(Utils.OnDownloadImage(URLglobal, (img) => { ProductImage.sprite = img; })); } } } } catch (NullReferenceException) { var images = (List <Shopify.Unity.Image>)product.images(); _imageSrc = images[0].transformedSrc(); Debug.Log("GG"); } _currentVariant = variant; }
public void TestCustomScalarMoney() { string json = @"{ ""price"": ""3.23"" }"; ProductVariant variant = new ProductVariant((Dictionary <string, object>)Json.Deserialize(json)); Assert.AreEqual(3.23M, variant.price()); }
/// <summary> /// Used internally by the SDK to construct a CartLineItem. /// </summary> /// <param name="variant">The variant this CartLineItem will be associated to</param> /// <param name="onChange">This function will be called whenever the CartLineItem is modified</param> /// <param name="quantity">The count of items to be ordered</param> /// <param name="customAttributes">Custom attributes for this line item used to customize and add meta data</param> public CartLineItem(ProductVariant variant, LineItemChangeHandler onChange, long quantity = 1, IDictionary <string, string> customAttributes = null) { _VariantId = variant.id(); _Quantity = quantity; _Price = variant.price(); OnChange = onChange; if (customAttributes != null) { CustomAttributes = new ObservableDictionary <string, string>(customAttributes, () => { OnChange(CartLineItems.LineItemChangeType.Update, this); }); } }
public void SetCurrentProduct(Product product, ProductVariant variant, int quantity) { gameObject.SetActive(true); ProductTitle.text = product.title(); VariantTitle.gameObject.SetActive(variant.title() != "Default Title"); VariantTitle.text = variant.title(); Quantity.text = quantity.ToString(); Price.text = variant.price().ToString("C"); try { _imageSrc = variant.image().transformedSrc(); } catch (NullReferenceException) { var images = (List <Shopify.Unity.Image>)product.images(); _imageSrc = images[0].transformedSrc(); } _currentVariant = variant; }
private void UpdateDetailsUsingVariant(ProductVariant variant) { Price.text = "$" + variant.price().ToString(); }