Skip to content

Commit f86aacb

Browse files
authored
Merge pull request #194 from RachBreeze/v13-ShopifyPrice
Added support for displaying prices and filtering on products picked
2 parents 4cbbf97 + 9a8a790 commit f86aacb

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

src/Umbraco.Cms.Integrations.Commerce.Shopify/Editors/ShopifyProductPickerValueConverter.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public override object ConvertSourceToIntermediate(IPublishedElement owner, IPub
3838
if (source == null) return null;
3939

4040
return source.ToString()
41-
.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
41+
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
4242
.Select(long.Parse)
4343
.ToArray();
4444
}
@@ -60,7 +60,20 @@ public override object ConvertIntermediateToObject(IPublishedElement owner, IPub
6060
Id = p.Id,
6161
Title = p.Title,
6262
Body = p.Body,
63-
Image = p.Image?.Src
63+
Image = p.Image?.Src,
64+
Tags = p.Tags,
65+
ProductType = p.ProductType,
66+
PublishedScope = p.PublishedScope,
67+
Status = p.Status,
68+
Variants = from v in p.Variants
69+
select new VariantViewModel
70+
{
71+
InventoryQuantity = v.InventoryQuantity,
72+
Position = v.Position,
73+
Price = v.Price,
74+
Sku = v.Sku,
75+
Taxable = v.Taxable
76+
}
6477
};
6578

6679
return products.ToList();

src/Umbraco.Cms.Integrations.Commerce.Shopify/Models/Dtos/ProductDto.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System.Collections.Generic;
2-
3-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
43

54
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Models.Dtos
65
{
@@ -29,6 +28,12 @@ public class ProductDto
2928

3029
[JsonProperty("image")]
3130
public ProductImageDto Image { get; set; }
31+
32+
[JsonProperty("product_type")]
33+
public string ProductType { get; set; }
34+
35+
[JsonProperty("published_scope")]
36+
public string PublishedScope { get; set; }
3237
}
3338

3439

src/Umbraco.Cms.Integrations.Commerce.Shopify/Models/Dtos/ProductVariantDto.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@ public class ProductVariantDto
1818

1919
[JsonProperty("inventory_quantity")]
2020
public int InventoryQuantity { get; set; }
21+
22+
[JsonProperty("taxable")]
23+
public bool Taxable { get; set; }
24+
2125
}
2226
}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11

2+
using System.Collections.Generic;
3+
24
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Models.ViewModels
35
{
46
public class ProductViewModel
57
{
68
public long Id { get; set; }
7-
89
public string Title { get; set; }
9-
1010
public string Body { get; set; }
1111

1212
public string Image { get; set; }
13+
public string ProductType { get; set; }
14+
public string Tags { get; set; }
15+
public string Status { get; set; }
16+
public string PublishedScope { get; set; }
17+
public IEnumerable<VariantViewModel> Variants { get; set; }
1318
}
1419
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+

2+
namespace Umbraco.Cms.Integrations.Commerce.Shopify.Models.ViewModels
3+
{
4+
public class VariantViewModel
5+
{
6+
public string Price { get; set; }
7+
public string Sku { get; set; }
8+
public int Position { get; set; }
9+
public int InventoryQuantity { get; set; }
10+
public bool Taxable { get; set; }
11+
12+
}
13+
}

0 commit comments

Comments
 (0)