public string GetJsonString(GTMProductPart part) { if (part == null) { return(string.Empty); } FillPart(part); return(GetJsonString(new GTMProductVM(part))); }
public IGAProductVM GetViewModel(GTMProductPart part) { if (UseGA4()) { return(new GA4ProductVM(part)); } else { return(new GTMProductVM(part)); } }
public GA4ProductVM( GTMProductPart part) { PartId = part.Id; Id = part.ProductId; Name = part.Name; Brand = part.Brand; Category = part.Category; Variant = part.Variant; Price = part.Price; }
public void FillPart(GTMProductPart part) { if (part == null) { throw new ArgumentNullException("part"); } if (part.ContentItem == null) { throw new ArgumentNullException("part.ContentItem"); } var product = part.As <ProductPart>(); if (product == null) { throw new ArgumentNullException("part.As<ProductPart>()"); } var partSetting = part.Settings.GetModel <GTMProductSettingVM>(); var tokens = new Dictionary <string, object> { { "Content", part.ContentItem } }; if (partSetting.Id == TypeId.Id) { part.ProductId = product.Id.ToString(); } else { part.ProductId = product.Sku; } part.Name = FillString(partSetting.Name, tokens); part.Brand = FillString(partSetting.Brand, tokens); part.Category = FillString(partSetting.Category, tokens); part.Variant = FillString(partSetting.Variant, tokens); // consider discounts if (product.DiscountPrice >= 0 && product.DiscountPrice < product.Price) { part.Price = _productPriceService.GetDiscountPrice(product); } else { part.Price = _productPriceService.GetPrice(product); } }
public string GetJsonString(GTMProductPart part) { if (part == null) { return(string.Empty); } FillPart(part); if (UseGA4()) { return(GetJsonString(new GA4ProductVM(part))); } else { return(GetJsonString(new GTMProductVM(part))); } }