5

Since setting up a Commerce 9 development environment, I've noticed an issue in which the totals for the cart are always 0.

I've customised the currencies across the board, but I've not specifically done anything to the ICalculateCartLinesPipeline.

Any thoughts as to what might cause this?

3

It turns out that this was another issue caused by critical pipeline code being defined in a sample plugin that I outlined in this question.

Basically, the cart plugin itself only registers two blocks: ClearCartLinesTotals and ClearCartTotals, with the rest of the functionality added by the AdventureWorks sample plugin. The reasons for this are unknown, but since neither specifies an order argument when registering their pipeline blocks it's basically luck (read: order of the dependencies during build) that makes the remaining blocks get added after the Clear* blocks. When I moved the blocks from the AdventureWorks sample to our own project, that luck ran out so the totals were being calculated and then subsequently cleared.

The solution is to register the blocks with an order specified that's greater than the default of 1000:

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>(),
        order: 1001 // This fixes the issue
    )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.