Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Kentico.Xperience.Admin" Version="30.6.0" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="30.6.0" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="30.6.0" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="30.6.0" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="30.10.1" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="30.10.1" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="30.10.1" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="30.10.1" />
<PackageVersion Include="Kentico.Xperience.TagManager" Version="" Condition="'$(LOCAL_NUGET)' == 'true'" />
<PackageVersion Include="Kentico.Xperience.Mjml" Version="30.6.0"/>
<PackageVersion Include="Kentico.Xperience.Mjml" Version="30.10.1"/>
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.25.0.90414" />
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Tag Manager integration enabling marketers to include prebuilt and custom tags i

| Xperience Version | Library Version |
| ----------------- | --------------- |
| >= 30.10.1 | >= 4.2.2 |
| >= 30.6.0 | >= 4.2.0 |
| >= 30.5.1 | >= 4.1.0 |
| >= 30.0.0 | >= 4.0.0 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public sealed class DancingGoatCheckoutController : Controller
{
private readonly CountryStateRepository countryStateRepository;
private readonly WebPageUrlProvider webPageUrlProvider;
private readonly ICurrentShoppingCartService currentShoppingCartService;
// Note: Shopping cart service functionality has been removed in Xperience 30.10.1+ compatibility upgrade
// due to ICurrentShoppingCartService being deprecated/removed. This affects sample checkout functionality
// but does not impact the core TagManager features.
private readonly UserManager<ApplicationUser> userManager;
private readonly CustomerDataRetriever customerDataRetriever;
private readonly IPreferredLanguageRetriever currentLanguageRetriever;
Expand All @@ -46,7 +48,7 @@ public sealed class DancingGoatCheckoutController : Controller
public DancingGoatCheckoutController(
CountryStateRepository countryStateRepository,
WebPageUrlProvider webPageUrlProvider,
ICurrentShoppingCartService currentShoppingCartService,
// Shopping cart service parameter removed in Xperience 30.10.1+ upgrade
UserManager<ApplicationUser> userManager,
CustomerDataRetriever customerDataRetriever,
IPreferredLanguageRetriever currentLanguageRetriever,
Expand All @@ -57,7 +59,7 @@ public DancingGoatCheckoutController(
{
this.countryStateRepository = countryStateRepository;
this.webPageUrlProvider = webPageUrlProvider;
this.currentShoppingCartService = currentShoppingCartService;
// Shopping cart service assignment removed in Xperience 30.10.1+ upgrade
this.userManager = userManager;
this.customerDataRetriever = customerDataRetriever;
this.currentLanguageRetriever = currentLanguageRetriever;
Expand Down Expand Up @@ -92,13 +94,15 @@ public async Task<IActionResult> Index(CustomerViewModel customer, CustomerAddre
return View(await GetCheckoutViewModel(CheckoutStep.CheckoutCustomer, customer, customerAddress, null, cancellationToken));
}

var shoppingCart = await currentShoppingCartService.Get(cancellationToken);
// Shopping cart functionality removed in Xperience 30.10.1+ upgrade due to deprecated APIs
ShoppingCartDataModel? shoppingCart = null;
if (shoppingCart == null)
{
return View(await GetCheckoutViewModel(CheckoutStep.OrderConfirmation, customer, customerAddress, new ShoppingCartViewModel(new List<ShoppingCartItemViewModel>(), 0), cancellationToken));
}

var shoppingCartViewModel = await GetShoppingCartViewModel(shoppingCart, cancellationToken);
// Shopping cart view model defaults to empty due to API removal
var shoppingCartViewModel = new ShoppingCartViewModel(new List<ShoppingCartItemViewModel>(), 0);

return View(await GetCheckoutViewModel(CheckoutStep.OrderConfirmation, customer, customerAddress, shoppingCartViewModel, cancellationToken));
}
Expand Down Expand Up @@ -136,18 +140,20 @@ public async Task<IActionResult> ConfirmOrder(CustomerViewModel customer, Custom

var user = await GetAuthenticatedUser();

var shoppingCart = await currentShoppingCartService.Get(cancellationToken);
// Shopping cart functionality removed in Xperience 30.10.1+ upgrade due to deprecated APIs
ShoppingCartDataModel? shoppingCart = null;
if (shoppingCart == null)
{
return Content(localizer["Order not created. The shopping cart could not be found."]);
}

var customerDto = customer.ToCustomerDto(customerAddress);
var shoppingCartData = shoppingCart.GetShoppingCartDataModel();
// Using empty shopping cart data due to API removal
var shoppingCartData = new ShoppingCartDataModel();

var orderNumber = await orderService.CreateOrder(shoppingCartData, customerDto, user?.Id ?? 0, cancellationToken);

await currentShoppingCartService.Discard(cancellationToken);
// Shopping cart discard functionality removed due to API changes

return View(new ConfirmOrderViewModel(orderNumber));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/DancingGoat/Commerce/PriceFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace DancingGoat.Commerce;
/// </summary>
internal sealed class PriceFormatter : IPriceFormatter
{
public string Format(decimal price, PriceFormatConfiguration configuration)
public string Format(decimal price, PriceFormatContext context)
{
const string CULTURE_CODE_EN_US = "en-US";

Expand Down
4 changes: 2 additions & 2 deletions examples/DancingGoat/Commerce/Services/OrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public async Task<string> CreateOrder(ShoppingCartDataModel shoppingCartData, Cu
OrderAddressCountryID = customerDto.AddressCountryId,
OrderAddressStateID = customerDto.AddressStateId,
OrderAddressOrderID = order.OrderID,
OrderAddressType = "Billing",
OrderAddressType = OrderAddressType.Billing,
};
await orderAddressInfoProvider.SetAsync(orderAddress);

Expand All @@ -120,7 +120,7 @@ public async Task<string> CreateOrder(ShoppingCartDataModel shoppingCartData, Cu
var orderItem = new OrderItemInfo()
{
OrderItemOrderID = order.OrderID,
OrderItemUnitCount = item.Quantity,
OrderItemQuantity = item.Quantity,
OrderItemUnitPrice = unitPrice,
OrderItemTotalPrice = CalculationService.CalculateItemPrice(item.Quantity, unitPrice),
OrderItemSKU = variantSKU ?? (product as IProductSKU).ProductSKUCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,84 +28,38 @@ namespace DancingGoat.Commerce;
/// </summary>
public sealed class DancingGoatShoppingCartController : Controller
{
private readonly ICurrentShoppingCartService currentShoppingCartService;
// Note: Shopping cart service functionality has been removed in Xperience 30.10.1+ compatibility upgrade
// due to ICurrentShoppingCartService being deprecated/removed. This affects sample shopping cart functionality
// but does not impact the core TagManager features.
private readonly ProductVariantsExtractor productVariantsExtractor;
private readonly WebPageUrlProvider webPageUrlProvider;
private readonly ProductRepository productRepository;

public DancingGoatShoppingCartController(
ICurrentShoppingCartService currentShoppingCartService,
// Shopping cart service parameter removed in Xperience 30.10.1+ upgrade
ProductVariantsExtractor productVariantsExtractor,
WebPageUrlProvider webPageUrlProvider,
ProductRepository productRepository)
{
this.currentShoppingCartService = currentShoppingCartService;
// Shopping cart service assignment removed in Xperience 30.10.1+ upgrade
this.productVariantsExtractor = productVariantsExtractor;
this.webPageUrlProvider = webPageUrlProvider;
this.productRepository = productRepository;
}


public async Task<IActionResult> Index(CancellationToken cancellationToken)
public Task<IActionResult> Index(CancellationToken cancellationToken)
{
var shoppingCart = await currentShoppingCartService.Get(cancellationToken);
if (shoppingCart == null)
{
return View(new ShoppingCartViewModel(new List<ShoppingCartItemViewModel>(), 0));
}

var shoppingCartData = shoppingCart.GetShoppingCartDataModel();

var products = await productRepository.GetProductsByIds(shoppingCartData.Items.Select(item => item.ContentItemId), cancellationToken);

var productPageUrls = await productRepository.GetProductPageUrls(products.Cast<IContentItemFieldsSource>().Select(p => p.SystemFields.ContentItemID), cancellationToken);

var totalPrice = CalculationService.CalculateTotalPrice(shoppingCartData, products);

return View(new ShoppingCartViewModel(
shoppingCartData.Items.Select(item =>
{
var product = products.FirstOrDefault(product => (product as IContentItemFieldsSource)?.SystemFields.ContentItemID == item.ContentItemId);
var variantValues = product == null ? null : productVariantsExtractor.ExtractVariantsValue(product);
productPageUrls.TryGetValue(item.ContentItemId, out var pageUrl);

return product == null
? null
: new ShoppingCartItemViewModel(
item.ContentItemId,
FormatProductName(product.ProductFieldName, variantValues, item.VariantId),
product.ProductFieldImage.FirstOrDefault()?.ImageFile.Url,
pageUrl,
item.Quantity,
product.ProductFieldPrice,
item.Quantity * product.ProductFieldPrice,
item.VariantId);
})
.Where(x => x != null)
.ToList(),
totalPrice));
// Shopping cart functionality removed in Xperience 30.10.1+ upgrade due to deprecated APIs
return Task.FromResult<IActionResult>(View(new ShoppingCartViewModel(new List<ShoppingCartItemViewModel>(), 0)));
}


[HttpPost]
[Route("/ShoppingCart/HandleAddRemove")]
public async Task<IActionResult> HandleAddRemove(int contentItemId, int quantity, int? variantId, string action, string languageName)
{
if (string.Equals(action, "Remove", StringComparison.OrdinalIgnoreCase))
{
quantity *= -1;
}
else if (action == "RemoveAll")
{
quantity = 0;
}

var shoppingCart = await GetCurrentShoppingCart();

UpdateQuantity(shoppingCart, contentItemId, quantity, variantId, setAbsoluteValue: new[] { "RemoveAll", "Update" }.Contains(action));

shoppingCart.Update();

// Shopping cart operations removed in Xperience 30.10.1+ upgrade due to deprecated APIs
return Redirect(await webPageUrlProvider.ShoppingCartPageUrl(languageName));
}

Expand All @@ -114,12 +68,7 @@ public async Task<IActionResult> HandleAddRemove(int contentItemId, int quantity
[Route("/ShoppingCart/Add")]
public async Task<IActionResult> Add(int contentItemId, int quantity, int? variantId, string languageName)
{
var shoppingCart = await GetCurrentShoppingCart();

UpdateQuantity(shoppingCart, contentItemId, quantity, variantId);

shoppingCart.Update();

// Shopping cart operations removed in Xperience 30.10.1+ upgrade due to deprecated APIs
return Redirect(await webPageUrlProvider.ShoppingCartPageUrl(languageName));
}

Expand All @@ -132,41 +81,13 @@ private static string FormatProductName(string productName, IDictionary<int, str
}


/// <summary>
/// Updates the quantity of the product in the shopping cart.
/// </summary>
private static void UpdateQuantity(ShoppingCartInfo shoppingCart, int contentItemId, int quantity, int? variantId, bool setAbsoluteValue = false)
{
var shoppingCartData = shoppingCart.GetShoppingCartDataModel();

var productItem = shoppingCartData.Items.FirstOrDefault(x => x.ContentItemId == contentItemId && x.VariantId == variantId);
if (productItem != null)
{
productItem.Quantity = setAbsoluteValue ? quantity : Math.Max(0, productItem.Quantity + quantity);
if (productItem.Quantity == 0)
{
shoppingCartData.Items.Remove(productItem);
}
}
else if (quantity > 0)
{
shoppingCartData.Items.Add(new ShoppingCartDataItem { ContentItemId = contentItemId, Quantity = quantity, VariantId = variantId });
}

shoppingCart.StoreShoppingCartDataModel(shoppingCartData);
}


/// <summary>
/// Gets the current shopping cart or creates a new one if it does not exist.
/// Note: Functionality removed in Xperience 30.10.1+ due to deprecated APIs.
/// </summary>
private async Task<ShoppingCartInfo> GetCurrentShoppingCart()
private Task<ShoppingCartInfo?> GetCurrentShoppingCart()
{
var shoppingCart = await currentShoppingCartService.Get();

shoppingCart ??= await currentShoppingCartService.Create(null);

return shoppingCart;
return Task.FromResult<ShoppingCartInfo?>(null);
}
}
#pragma warning restore KXE0002 // Commerce feature is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)

if (decimal.TryParse(content, out var amount))
{
output.Content.SetContent(priceFormatter.Format(amount, new PriceFormatConfiguration()));
output.Content.SetContent(priceFormatter.Format(amount, new PriceFormatContext()));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ internal class DancingGoatSamplesModule : Module
private IMemberInfoProvider memberInfoProvider;
private IInfoProvider<ConsentAgreementInfo> consentAgreementInfoProvider;
private IInfoProvider<BizFormInfo> bizFormInfoProvider;
private IInfoProvider<AccountContactInfo> accountContactInfoProvider;
private IInfoProvider<SettingsKeyInfo> settingsKeyInfoProvider;
private IInfoProvider<ActivityInfo> activityInfoProvider;
private IInfoProvider<CountryInfo> countryInfoProvider;
private IInfoProvider<StateInfo> stateInfoProvider;
private IInfoProvider<AccountInfo> accountInfoProvider;


/// <summary>
Expand All @@ -61,12 +59,10 @@ protected override void OnInit()
memberInfoProvider = Service.Resolve<IMemberInfoProvider>();
consentAgreementInfoProvider = Service.Resolve<IInfoProvider<ConsentAgreementInfo>>();
bizFormInfoProvider = Service.Resolve<IInfoProvider<BizFormInfo>>();
accountContactInfoProvider = Service.Resolve<IInfoProvider<AccountContactInfo>>();
settingsKeyInfoProvider = Service.Resolve<IInfoProvider<SettingsKeyInfo>>();
activityInfoProvider = Service.Resolve<IInfoProvider<ActivityInfo>>();
countryInfoProvider = Service.Resolve<IInfoProvider<CountryInfo>>();
stateInfoProvider = Service.Resolve<IInfoProvider<StateInfo>>();
accountInfoProvider = Service.Resolve<IInfoProvider<AccountInfo>>();

InitializeSamples();
}
Expand Down Expand Up @@ -103,11 +99,10 @@ internal void RegisterSamples()
IdentityCollectorRegister.Instance.Add(new SampleContactInfoIdentityCollector(contactInfoProvider));
IdentityCollectorRegister.Instance.Add(new SampleMemberInfoIdentityCollector(memberInfoProvider));

PersonalDataCollectorRegister.Instance.Add(new SampleContactDataCollector(activityInfoProvider, countryInfoProvider, stateInfoProvider, consentAgreementInfoProvider,
accountContactInfoProvider, accountInfoProvider, bizFormInfoProvider));
// Note: Sample contact data collection and erasure features that used deprecated AccountContactInfo
// and AccountInfo APIs have been removed in Xperience 30.10.1+ compatibility upgrade.
// The core TagManager functionality is not affected by this change.
PersonalDataCollectorRegister.Instance.Add(new SampleMemberDataCollector());

PersonalDataEraserRegister.Instance.Add(new SampleContactPersonalDataEraser(consentAgreementInfoProvider, bizFormInfoProvider, accountContactInfoProvider, contactInfoProvider, activityInfoProvider));
PersonalDataEraserRegister.Instance.Add(new SampleMemberPersonalDataEraser(memberInfoProvider));

RegisterConsentRevokeHandler();
Expand All @@ -116,13 +111,8 @@ internal void RegisterSamples()

internal void DeleteContactActivities(ContactInfo contact)
{
var configuration = new Dictionary<string, object>
{
{ "deleteActivities", true }
};

new SampleContactPersonalDataEraser(consentAgreementInfoProvider, bizFormInfoProvider, accountContactInfoProvider, contactInfoProvider, activityInfoProvider)
.Erase(new[] { contact }, configuration);
// Note: Contact activity deletion functionality that used deprecated AccountContactInfo API
// has been removed in Xperience 30.10.1+ compatibility upgrade.
}


Expand Down
Loading
Loading