Skip to content

Instantly share code, notes, and snippets.

@websterian
Last active October 9, 2017 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save websterian/f48c8b5369c3900e26c6d63bb0474f44 to your computer and use it in GitHub Desktop.
Save websterian/f48c8b5369c3900e26c6d63bb0474f44 to your computer and use it in GitHub Desktop.
namespace Sitecore.Commerce.Plugin.AdventureWorks
{
using Microsoft.Extensions.DependencyInjection;
using Sitecore.Commerce.Plugin.AdventureWorks.Pipelines.Blocks;
using Sitecore.Commerce.Plugin.Carts;
using Sitecore.Commerce.Plugin.Catalog;
using Sitecore.Commerce.Plugin.Catalog.Cs;
using Sitecore.Commerce.Plugin.Coupons;
using Sitecore.Commerce.Plugin.Fulfillment;
using Sitecore.Commerce.Plugin.Inventory.Cs;
using Sitecore.Commerce.Plugin.Orders;
using Sitecore.Commerce.Plugin.Payments;
using Sitecore.Commerce.Plugin.Promotions;
using Sitecore.Commerce.Plugin.Tax;
using Sitecore.Framework.Pipelines.Definitions.Extensions;
/// <summary>
/// The services extensions.
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// The configure cart pipelines.
/// </summary>
/// <param name="services">
/// The services.
/// </param>
/// <returns>
/// The <see cref="IServiceCollection"/>.
/// </returns>
public static IServiceCollection ConfigureCartPipelines(this IServiceCollection services)
{
services.Sitecore().Pipelines(config => config
.ConfigurePipeline<ICalculateCartLinesPipeline>(builder => builder
.Add<PopulateCartLineItemsBlock>()
.Add<CalculateCartLinesPriceBlock>()
.Add<ValidateCartLinesPriceBlock>()
.Add<CalculateCartLinesSubTotalsBlock>()
.Add<CalculateCartLinesFulfillmentBlock>()
.Add<ValidateCartCouponsBlock>()
.Add<CalculateCartLinesPromotionsBlock>()
.Add<CalculateCartLinesTaxBlock>()
.Add<CalculateCartLinesTotalsBlock>())
.ConfigurePipeline<ICalculateCartPipeline>(builder => builder
.Add<CalculateCartSubTotalsBlock>()
.Add<CalculateCartFulfillmentBlock>()
.Add<CalculateCartPromotionsBlock>()
.Add<CalculateCartTaxBlock>()
// Registers the block that executes the custom pricing logic based on our new flag
.Add<CalculateCartVIPBlock>()
.Add<CalculateCartTotalsBlock>()
.Add<CalculateCartPaymentsBlock>())
.ConfigurePipeline<IAddPaymentsPipeline>(builder => builder.Add<ValidateCartHasFulfillmentBlock>().After<ValidateCartAndPaymentsBlock>()));
return services;
}
/// <summary>
/// The configure orders pipelines.
/// </summary>
/// <param name="services">
/// The services.
/// </param>
/// <returns>
/// The <see cref="IServiceCollection"/>.
/// </returns>
public static IServiceCollection ConfigureOrdersPipelines(this IServiceCollection services)
{
services.Sitecore().Pipelines(config => config
.ConfigurePipeline<IItemOrderedPipeline>(builder => builder
.Add<UpdateItemsOrderedInventoryBlock>()));
return services;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment