Skip to content

Commit 31d9ed2

Browse files
Temporary fix for AncestorOrSelf being broken
1 parent 35f93ec commit 31d9ed2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Umbraco.Commerce.Checkout/Web/PublishedContentExtensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ namespace Umbraco.Commerce.Checkout.Web
88
{
99
public static class PublishedContentExtensions
1010
{
11+
// Temporary fix for AncestorOrSelf until https://github.com/umbraco/Umbraco-CMS/pull/17581 is merged in
12+
private static IPublishedContent? AncestorOrSelf2(this IPublishedContent content, string contentTypeAlias) =>
13+
content.ContentType.Alias == contentTypeAlias
14+
? content
15+
: content.Ancestor(contentTypeAlias);
16+
1117
public static StoreReadOnly GetStore(this IPublishedContent content)
1218
{
1319
return content.Value<StoreReadOnly>(Cms.Constants.Properties.StorePropertyAlias, fallback: Fallback.ToAncestors) ?? throw new StoreDataNotFoundException();
1420
}
1521

1622
public static IPublishedContent GetCheckoutPage(this IPublishedContent content)
1723
{
18-
return content.AncestorOrSelf(UmbracoCommerceCheckoutConstants.ContentTypes.Aliases.CheckoutPage);
24+
return content.AncestorOrSelf2(UmbracoCommerceCheckoutConstants.ContentTypes.Aliases.CheckoutPage)!;
1925
}
2026

2127
public static IPublishedContent GetCheckoutBackPage(this IPublishedContent content)

0 commit comments

Comments
 (0)