Skip to content

Commit 32cdf35

Browse files
authored
Match price formatting with google merchant center documentation (#8)
* Match price formatting with google merchant center documentation * Added missing using statement for Core.Services
1 parent 6ccea69 commit 32cdf35

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Umbraco.Commerce.ProductFeeds.Core/Features/FeedGenerators/Implementations/GoogleMerchantCenterFeedService.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Umbraco.Commerce.Cms.Models;
55
using Umbraco.Commerce.Core.Api;
66
using Umbraco.Commerce.Core.Models;
7+
using Umbraco.Commerce.Core.Services;
78
using Umbraco.Commerce.Extensions;
89
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedGenerators.Implementations;
910
using Umbraco.Commerce.ProductFeeds.Core.Features.FeedSettings.Application;
@@ -25,19 +26,22 @@ public class GoogleMerchantCenterFeedService : IProductFeedGeneratorService
2526
"Unable to find any product with these parameters: storeId = '{StoreId}', product key= '{ProductKey}', variant key = '{VariantKey}'.");
2627

2728
private readonly ILogger<GoogleMerchantCenterFeedService> _logger;
28-
private readonly IProductQueryService _productQueryService;
29+
private readonly ICurrencyService _currencyService;
30+
private readonly IProductQueryService _productQueryService;
2931
private readonly IUmbracoCommerceApi _commerceApi;
3032
private readonly ISingleValuePropertyExtractorFactory _singleValuePropertyExtractorFactory;
3133
private readonly IMultipleValuePropertyExtractorFactory _multipleValuePropertyExtractorFactory;
3234

3335
public GoogleMerchantCenterFeedService(
3436
ILogger<GoogleMerchantCenterFeedService> logger,
37+
ICurrencyService currencyService,
3538
IProductQueryService productQueryService,
3639
IUmbracoCommerceApi commerceApi,
3740
ISingleValuePropertyExtractorFactory singleValuePropertyExtractor,
3841
IMultipleValuePropertyExtractorFactory multipleValuePropertyExtractorFactory)
3942
{
4043
_logger = logger;
44+
_currencyService = currencyService;
4145
_productQueryService = productQueryService;
4246
_commerceApi = commerceApi;
4347
_singleValuePropertyExtractorFactory = singleValuePropertyExtractor;
@@ -192,7 +196,8 @@ private void AddPriceNode(XmlElement itemNode, Guid storeId, IPublishedElement p
192196
}
193197

194198
XmlElement priceNode = itemNode.OwnerDocument.CreateElement("g:price", GoogleXmlNamespaceUri);
195-
priceNode.InnerText = productSnapshot.CalculatePrice()?.Formatted();
199+
Price calculatedPrice = productSnapshot.CalculatePrice();
200+
priceNode.InnerText = $"{calculatedPrice.WithTax.ToString("0.00")} {_currencyService.GetCurrency(calculatedPrice.CurrencyId).Code}";
196201
itemNode.AppendChild(priceNode);
197202
}
198203

0 commit comments

Comments
 (0)