SaaS CMS has officially launched! Learn more now.

Incorrect activities order in CartPrepare workflow

Vote:
 

I'm currently testing different promotion combinations, specifically combining an Entry level and an Order level promotion. I have a problem where the Order level discount was incorrect, the Entry Level discount was subtracted twice from the order before the Order discount was calculated.

Examining the CartPrepare workflow I see that the 'CalculateTotals' activity runs before the 'RemoveDiscounts' activity. To me this seems illogical, I would expect the 'RemoveDiscounts' activity to run first, like in the PurchaseOrderRecalculate worklow. After reading the documentation (http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Commerce/75/Workflows/Workflows/), I think this is an error in the downloadable workflows.

#118192
Mar 02, 2015 13:20
Vote:
 

Hi,

Do you try with latest workflows package? Along with Commerce 8.7.1 we released new workflows package with many improvements and bug fixes - which I highly hope the "bug" you mentioned has been fixed.

It's here: http://world.episerver.com/download/Items/EPiServer-Commerce/episerver-commerce-8-tools-and-code-samples/

Regards.

/Q

#118204
Mar 02, 2015 14:23
Vote:
 

I cannot actually run the latest versions for the workflow since we are running EPiserver 7.1 at this moment, but I have looked at the code in the last version.

What I see in the CartPrepare workflow code (also in the last 8.7.1 version) is that the 'CalculateTotals' activity is run before the 'RemoveDiscounts' activity, while in the documentation is specifically states that the 'discounts are removed so that pre-discount and pre-tax totals can be calculated in the next step' (http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Commerce/8/Workflows/Workflows/)

Is this the way it was designed or possibly a bug?

When I switch the activities in my own code the discounts seem to be calculated correctly.

#118208
Mar 02, 2015 14:47
Vote:
 

Hi,

I can confirm the issue has been fixed in latest workflow package in the link I mentioned above. Track back in history and it looks like it has been that way (RemoveDiscount is run before CalculateDiscount) since this: http://world.episerver.com/download/Items/EPiServer-Commerce/EPiServer-Commerce-10-SP1/EPiServer-Commerce-Workflow-and-Provider-Integration-Samples/

Please note that the workflow /actitivies packages are open source and you're free to modify them as you need.

Regards.

/Q

#118220
Mar 03, 2015 3:33
Vote:
 

Hi, thank you for your quick responses.

I see that the issue is fixed in the latest workflow versions, however the solution is not what I expected. The 'CalculateDiscounts' activity now holds some code to calculate a runningTotal itself instead of using the Order.SubTotal property.

What I now see is a clear difference between these downloadable workflows and the documentation.

What I read in the Documentation:
- CartPrepareWorkflow: ... -> RemoveDiscountsActivity -> CalculateTotalsActivity -> CalculateDiscountsActivity (using Order.SubTotal) -> etc
(http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Commerce/8/Marketing/Using-calculate-discount-activity/)
(http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Commerce/8/Workflows/Workflows/)

What I see in the Downloaded Workflows:
- CartPrepareWorkflow: ... -> CalculateTotalsActivity -> RemoveDiscountsActivity -> CalculateDiscountsActivity (using custom code for subtotal/runningtotal) -> etc
(http://world.episerver.com/download/Items/EPiServer-Commerce/episerver-commerce-8-tools-and-code-samples/)

I think that both solutions will probably generate the same discounts, but it does make things very confusing when trying to understand the code using the documentation.

#118239
Mar 03, 2015 11:34
Vote:
 

Hi,

I'm not sure what is wrong but here's from my CartPrepareWorkflow.xoml:

<ns0:RemoveDiscountsActivity x:Name="removeDiscountsActivity1" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
<ns0:CalculateTotalsActivity x:Name="calculateTotalsActivity2" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
<ns0:CalculateDiscountsActivity x:Name="calculateDiscountsActivity1" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
<ns0:CalculateTotalsActivity x:Name="calculateTotalsActivity3" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />

So clearly it will remove discounts before calculating total and then discount. 

And I can confirm it has been that way since R1 SP1. :)

Regards.

/Q

#118240
Mar 03, 2015 11:44
Vote:
 

This is the one I downloaded 1 minute ago from EPiSErver world.

<SequentialWorkflowActivity x:Class="Mediachase.Commerce.Workflow.CartPrepareWorkflow" x:Name="CartPrepareWorkflow" xmlns:ns0="clr-namespace:Mediachase.Commerce.Workflow.Activities" xmlns:ns1="clr-namespace:Mediachase.Commerce.Workflow.Activities.PurchaseOrderActivities" xmlns:ns2="clr-namespace:Mediachase.Commerce.Workflow.Activities.Cart" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
 <ns0:ValidateLineItemsActivity x:Name="validateLineItemsActivity1" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
  <ns2:GetFulfillmentWarehouseActivity x:Name="getFulfillmentWarehouseActivity1" PickupWarehouseInShipment="{ActivityBind CartPrepareWorkflow,Path=PickupWarehouseInShipment}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" />
  <IfElseActivity x:Name="ifElseActivity1">
  <IfElseBranchActivity x:Name="ifElseBranchActivity1">
   <IfElseBranchActivity.Condition>
    <CodeCondition Condition="CheckInstoreInventory" />
   </IfElseBranchActivity.Condition>
   <ns1:CheckInstoreInventoryActivity PickupWarehouseInShipment="{ActivityBind CartPrepareWorkflow,Path=PickupWarehouseInShipment}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" Description="Checks Inventory for in-store pickup and reserves items accordingly." OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" x:Name="checkInstoreInventoryActivity1" />
  </IfElseBranchActivity>
  <IfElseBranchActivity x:Name="ifElseBranchActivity2">
   <ns0:CheckInventoryActivity Description="Checks Inventory and removes items if needed." x:Name="checkInventoryActivity2" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
  </IfElseBranchActivity>
 </IfElseActivity>
 <ns0:ProcessShipmentsActivity Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" x:Name="processShipmentsActivity1" />
 <ns0:CalculateTotalsActivity x:Name="calculateTotalsActivity1" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
 <ns0:RemoveDiscountsActivity x:Name="removeDiscountsActivity1" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
 <ns0:CalculateDiscountsActivity x:Name="calculateDiscountsActivity1" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
 <ns0:CalculateTotalsActivity x:Name="calculateTotalsActivity2" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
 <ns0:CalculateTaxActivity x:Name="calculateTaxActivity1" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
 <ns0:CalculateTotalsActivity x:Name="calculateTotalsActivity3" OrderGroup="{ActivityBind CartPrepareWorkflow,Path=OrderGroup}" Warnings="{ActivityBind CartPrepareWorkflow,Path=Warnings}" />
</SequentialWorkflowActivity>

#118241
Mar 03, 2015 11:51
Vote:
 

Ah yes. There is small bug fix recently which made the change. And my bad as I read it as RemoveDiscounts and CalculateDiscounts. 

I will notify the documentation team about this mismatch.

Thank you.

/Q

#118244
Mar 03, 2015 12:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.