Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Feb 20, 2013 @ 16:58
    Marc Love (uSkinned.net)
    0

    Inventory Management not working when order cancelled

    I have setup simple inventory management and have successfuly got this to work when checkout is complete.

    I have added the pipeline tasks for ToCancelled as below however the Inventory isnt being incremented when I cancel. Anyone got any ideas why this may not be working:

     <value>${ToCancelled.IncrementInventoryOnHand}</value>

      <component id="ToCancelled.IncrementInventoryOnHand"
               service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce"
               type="UCommerce.Pipelines.OrderProcessing.IncrementInventoryOnHandTask, UCommerce.Pipelines" />   

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Feb 20, 2013 @ 17:06
    Nickolaj Lundgreen
    0

    What kind of error do you get in the umbraco log?

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Feb 22, 2013 @ 13:01
    Marc Love (uSkinned.net)
    0

    Hi Nickolaj,

    Not getting any error in umbracoLog for this step.

    Cheers,

    Marc

  • Morten Skjoldager 440 posts 1499 karma points
    Feb 25, 2013 @ 09:51
    Morten Skjoldager
    0

    The productdefinitionField it's looking for in the task is "InventoryOnHand". Is your inventory property called that ? Does it work when it is decreasing inventory on hand on checkout as it is supposed to do? 

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Feb 25, 2013 @ 11:51
    Nickolaj Lundgreen
    0

    I just made the same task you describe for a client.

    This i how i made it:

    The pipeline

    public class InventoryIncrease : IPipelineTask<UCommerce.EntitiesV2.PurchaseOrder>
        {
            public PipelineExecutionResult Execute(PurchaseOrder order)
            {
                //Call on order cancel
                PipelineLogic.ChangeInventoryStatus(order,false);
                return PipelineExecutionResult.Success;
            }
    
    
        }

    The pipeline logic:

            internal static void ChangeInventoryStatus(PurchaseOrder order, bool decrease = true)
            {
                const string inventoryOnHandAlias = "InventoryOnHand";
                foreach (var orderLine in order.OrderLines)
                {
                    Product product = null;
                    //Fetch product or definition
                    product = !string.IsNullOrEmpty(orderLine.VariantSku) ? Product.FirstOrDefault(x => x.VariantSku == orderLine.VariantSku) : Product.FirstOrDefault(x => x.Sku == orderLine.Sku);
    
                    //Check if alias is on the product
                    if (!product.IsVariant && product.ProductDefinition.ProductDefinitionFields.Any(x => x.Name == inventoryOnHandAlias)
                        || product.IsVariant && product.ProductDefinition.ProductDefinitionFields.Any(x => x.Name == inventoryOnHandAlias && x.IsVariantProperty))
                    {
                        var rawStockValue = product.GetProperty(inventoryOnHandAlias).GetValue().ToString();
    
                        var parsedStockValue = 0;
                        var converted = int.TryParse(rawStockValue, out parsedStockValue);
                        if (converted)
                        {
                            if (decrease)
                            {
                                product.GetProperty(inventoryOnHandAlias).SetValue(parsedStockValue - orderLine.Quantity);
                            }
                            else
                            {
                                product.GetProperty(inventoryOnHandAlias).SetValue(parsedStockValue + orderLine.Quantity);
                            }
                            product.Save();
                        }
    
                    }
    
                }
            }

    And the ToCancelled.config

    <array>
                <value>${XXX.InventoryUpdate}</value>
            <!--<value>${ToCancelled.CancelPaymentTask}</value>-->
    </array>
    ...
        <component id="XXX.InventoryUpdate"
                       service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce"
                       type="MYNAMESPACE.Pipeline.InventoryIncrease, myDLL" />

     

    Hope this helps you out :)

  • Morten Skjoldager 440 posts 1499 karma points
    Feb 25, 2013 @ 12:56
    Morten Skjoldager
    1

    There's built-in support for that. At least in 3.0 

    UCommerce.Pipelines.Common.InventoryTask does the trick well. And as you have registered, there's also tasks built-in for both calling it with increase and decrease. The question is weather it works also on Increase. And that you've configured it the right way using InventoryOnHand property.

     

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Feb 25, 2013 @ 13:57
    Nickolaj Lundgreen
    0

    Great info Morten - didn't notice the new pipelinetasks in 3.0.

    I'll have a look in dotPeak and see if it does everything I need it to do :)

  • Morten Skjoldager 440 posts 1499 karma points
    Feb 25, 2013 @ 14:50
    Morten Skjoldager
    0

    dicking deeper into it, it actually looks like it's been around since 1.1.1.0 :) It also states that you only need to add a product definition field and your'e good to go. 

    http://ucommerce.dk/en/support/release-notes.aspx

     

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Feb 25, 2013 @ 17:30
    Marc Love (uSkinned.net)
    0

    Hi Morten,

    I have the "InventoryOnHand" property setup and the decrement is working on checkout. When I cancel an order the increment isnt working.

    Any ideas?

    Cheers,

    Marc

  • Morten Skjoldager 440 posts 1499 karma points
    Feb 26, 2013 @ 09:01
    Morten Skjoldager
    0

    And the toCancelled pipeline are running as it should ? 

    Sounds strange. What uCommerce version are you running on ? 

     

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Feb 26, 2013 @ 13:00
    Marc Love (uSkinned.net)
    0

    Hi Morten, using 3.0, not sure where to look to see why this is not working. Everything seems to be setup correctly and not receiving any errors.

    Cheers,

    Marc

  • Morten Skjoldager 440 posts 1499 karma points
    Feb 26, 2013 @ 13:37
    Morten Skjoldager
    0

    Can you please try to paste your entire ToCancelled.config file here :) 

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Feb 26, 2013 @ 14:50
    Marc Love (uSkinned.net)
    0

    <configuration>
        <components>
            <!-- Pipeline Instance -->
            <component id="ToCancelled"
                       service="UCommerce.Pipelines.IPipeline`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce"
                       type="UCommerce.Pipelines.OrderProcessing.OrderProcessingPipeline, UCommerce.Pipelines">
                <parameters>
                    <tasks>
                        <array>
                            <!--
                                Payment processing vendors ussually require additional subscription fees for you to be able to access their API.
                                Please consult your agreement to see if API access is supported for your particular plan.
                            -->
                            <!--<value>${ToCancelled.CancelPaymentTask}</value>-->
                <value>${ToCancelled.IncrementInventoryOnHand}</value>
                        </array>
                    </tasks>
                </parameters>
            </component>

            <!-- Pipeline Tasks-->
            <component id="ToCancelled.CancelPaymentTask"
                       service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce"
                       type="UCommerce.Pipelines.OrderProcessing.CancelPaymentTask, UCommerce.Pipelines" />
        <component id="ToCancelled.IncrementInventoryOnHand"
               service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce"
               type="UCommerce.Pipelines.OrderProcessing.IncrementInventoryOnHandTask, UCommerce.Pipelines" />   
        </components>
    </configuration>

  • Morten Skjoldager 440 posts 1499 karma points
    Feb 26, 2013 @ 15:06
    Morten Skjoldager
    100

    First of all. 

    You do know that <value>${ToCancelled.CancelPaymentTask}</value> are not run because it is outcommented right? 

     

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Feb 26, 2013 @ 16:56
    Marc Love (uSkinned.net)
    0

    AHHHHHHHHHHHHHH, jesus, never noticed.

    Cheers, Morten

  • Morten Skjoldager 440 posts 1499 karma points
    Feb 27, 2013 @ 08:15
    Morten Skjoldager
    0

    No problem. Did it also solve the increament issue ? 

  • Marc Love (uSkinned.net) 445 posts 1787 karma points
    Feb 27, 2013 @ 11:09
    Marc Love (uSkinned.net)
    0

    Hi Morten, thats it sorted thanks for the extra pair of eyes.

  • Morten Skjoldager 440 posts 1499 karma points
    Feb 28, 2013 @ 12:00
    Morten Skjoldager
    0

    Glad to help out :)

Please Sign in or register to post replies

Write your reply to:

Draft