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.

  • Bex 444 posts 555 karma points
    Aug 20, 2010 @ 12:17
    Bex
    0

    Need help creating a pipeline

    Hi

    I am still trying to get my head round Ucommerce, and must admit I am finding it quite difficult and am falling at just about every hurdle! (maybe because I am also quite new to umbraco and xslt?!)

    I have set up my shop (using the demo shop) and added some test products, one of my products is a ticket and when an order has been placed I need to send the ticket ordered to the customer by email.

    I am assuming I need to do this using a pipeline, and put it in the order status table to run on order complete?
    but I am having trouble understanding how I do that?

    I have read this blog http://blog.lasseeskildsen.net/post/uCommerce-Pipelines-Explained.aspx (also posted a message, but felt probably better to post here!), but I don't understand! I also need reference to the orderId, and user details so the ticket I create in code is unique.

    Are there any more examples around? or can someone help?

    Bex

  • Sean Mooney 131 posts 158 karma points c-trib
    Aug 20, 2010 @ 14:10
    Sean Mooney
    0

    Do you have the pipeline file setup in umbraco > UCommerce > Pipelines > [Name of Pipeline].config

    I have a setup that does the same thing but, sends an email when the Order has been processed. So, in the uCommerce_OrderStatus table I have an entry with name Processed and Pipeline value of : OrderStatus-Processed.config

    The pipeline file has the contents of:

    <configuration>
        <components>
            <!-- Pipeline Instance -->
            <component id="OrderStatus-Processed"
                       service="UCommerce.Pipelines.IPipeline`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"
                       type="WSC.Pipelines.OrderStatus.OrderStatusPipeline, WSC.UCommerce"
                       lifestyle="Thread">
                <parameters>
                    <tasks>
                        <array>
                            <value>${OrderStatus.OrderProcessed}</value>
                        </array>
                    </tasks>
                </parameters>
            </component>
    
            <!-- Pipeline Tasks-->
            <component id="OrderStatus.OrderProcessed"
                       service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"
                       type="WSC.Pipelines.OrderStatus.OrderProcessed, WSC.UCommerce"
                       lifestyle="Thread" />
    
            <!-- Add Quantity Management Here -->
    
        </components>
    </configuration>
    

     

    Where WSC.Pipelines.OrderStatys.OrderProcessed has my code to send the email.

    Hope that helps.

    -Sean

     

  • Bex 444 posts 555 karma points
    Aug 20, 2010 @ 14:33
    Bex
    0

    Hi Sean!

    Thanks so much for your reply!

    I must admit I'd so far got nowhere.. I was about to try decompiling ucommerce if I could to see if I could see how it was done in their code!
    Seemed the only way to go as I really want to use this and i'm so confused and documentation appears to be really lacking!


    Anyway..

    So to be clear;

    I have created a class that looks something like this:

    namespace

    
    

     

    test{ 

     

    public class CustomOrderComplete : IPipelineTask<PurchaseOrder>

    { 

     

    public PipelineExecutionResult Execute(PurchaseOrder order)

    {

     

     

    foreach (OrderLine line in order.OrderLines)

    {

    } 

     

    return PipelineExecutionResult.Success;

    }

    }

    }

    Is this correct? (I will do my emailing stuff in the foreach loop)
    I can get all details of the order here.. but can I also get the user details? if so how?

    Then I need to create myself a new config file like the checkout config and basket one. I will call it something like OrderProcessed.config and use your example above? Will the "PurchaseOrder" be passed in if I follow your example? If so which bit signifies this, and how do I pass in other stuff if needed?

    Then in the orderstatus table do I put "OrderProcessed.config" in the pipeline column, or do I put the class name or something else?
    I suppose my question is; is the xml referred to as the pipeline or is the actual code?

    Thanks in advance..

    Bex

  • Bex 444 posts 555 karma points
    Aug 20, 2010 @ 14:35
    Bex
    0

    Ps.. sorry about the code bit.. no idea what happen there and it wont let me edit it!

  • Bex 444 posts 555 karma points
    Aug 20, 2010 @ 15:53
    Bex
    0

    I have set up a pipe line in the way I think it should work but nothings happening.

    Can anyone let me know what I've done wrong? The code is as follows.

    Xml File (OrderProcessed.config)

    <configuration>
        <components>
            <!-- Pipeline Instance -->
            <component id="OrderProcessed"
                       service="UCommerce.Pipelines.IPipeline`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"
                       type="test,test"
                       lifestyle="Thread">
                <parameters>
                    <tasks>
                        <array>
                            <value>${OrderProcessed.CustomOrderComplete}</value>
                        </array>
                    </tasks>
                </parameters>
            </component>
    
            <!-- Pipeline Tasks-->
            <component id="OrderProcessed.CustomOrderComplete"
                       service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"
                       type="test.CustomOrderComplete.OrderProcessed.CustomOrderComplete,test"
                       lifestyle="Thread" />
    
        </components>
    </configuration>
    
    The cs class
    namespace test
    {
        public class CustomOrderComplete : IPipelineTask<PurchaseOrder>
    
        {
            public PipelineExecutionResult Execute(PurchaseOrder order)
            {
                Customer customer = order.Customer;
                foreach (OrderLine line in order.OrderLines)
                {
                   if(line.Sku.ToLower()=="adultticket")
                   {
                       string customerEmail = customer.EmailAddress;
                   }
                }
    
                return PipelineExecutionResult.Success;
            }
        }
    }

     

    I am putting OrderProcessed.config in the pipeline column under the Completed order status

    Bex

  • Sean Mooney 131 posts 158 karma points c-trib
    Aug 20, 2010 @ 15:57
    Sean Mooney
    0

    @Bex,

    That looks correct to me (I mainly develop in VB.Net)

    The type attribute in my pipeline.config file tells it what code to use:

    type="WSC.Pipelines.OrderStatus.OrderProcessed, WSC.UCommerce"

    This is where you would put the assembly and namespace of the class that you are created in your example.

    In order to get the email address you have a couple of options.

    You can get it from the customer by using:

    order.Customer.EmailAddress

    Or from the billing address using:

    order.GetBillingAddress().EmailAddress

    Or from the shipping address using:

    order.GetShippingAddress()().EmailAddress

    In my code I am using the billing address version, because I want to notify the person that is paying for it that their order has been processed.

     

    In the order status table you put the name of the config file without the .config.

    I make it a habit to make sure that the config file name (without the .config) matches the id attribute in the file:

    <component id="OrderStatus-Processed"

    So in the example I provided my file name is OrderStatus-Processed.config, component id is OrderStatus-Processed and the entry in the order status table is OrderStatus-Processed.

    The xml file is what is referred to as the "Pipeline" then each pipeline has "tasks" which are the individual classes that you create (like your example). So if you look at one of the default pipelines like Basket.config, you'll see that it has a number of task that it runs through.

    Hope that helps.

    -Sean

  • Sean Mooney 131 posts 158 karma points c-trib
    Aug 20, 2010 @ 16:05
    Sean Mooney
    0

    @Bex

    Everything looks correct, the order status table should be the name without the ".config"

    Also it doesn't look like you have your Pipeline instance setup properly.

    Here is a rough cut of my VB :

    Namespace WSC.Pipelines.OrderStatus
        Public Class OrderStatusPipeline
            Inherits Pipeline(Of PurchaseOrder)
            Public Sub New(ByVal tasks As IPipelineTask(Of PurchaseOrder)())
                MyBase.New(tasks)
            End Sub
    
        End Class
    
        Public Class OrderProcessed
            Implements IPipelineTask(Of PurchaseOrder)
    
            Public Function Execute(ByVal subject As UCommerce.Entities.PurchaseOrder) As UCommerce.Pipelines.PipelineExecutionResult Implements UCommerce.Pipelines.IPipelineTask(Of UCommerce.Entities.PurchaseOrder).Execute
                Utilities.SendEmail("from email", subject.Customer.EmailAddress, "Your order has been shipped", "/inc/email_templates/program_order_shipped.html", Nothing)
            End Function
        End Class
    
    End Namespace

     

    Notice that in my .config file there are both OrderStatusPipeline and OrderProcessed

    -Sean

     

  • Bex 444 posts 555 karma points
    Aug 20, 2010 @ 17:11
    Bex
    0

    Hi Sean!

     

    I really appreciate your helping me and I have translated your code to c#.. I have atually completely copied it to see if I can get it working.
    The only difference is that my dll is called test.
    But I think I must be missing something.

    my config called OrderStatus-Processed.config

    and contains the following

    <

     

     

    configuration>

    <

     

     

    components>

    <!--

     

     

    Pipeline Instance -->

    <

     

     

    component id="OrderStatus-Processed"

     

     

     

    service="UCommerce.Pipelines.IPipeline`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"

     

     

     

    type="WSC.Pipelines.OrderStatus.OrderStatusPipeline, test"

     

     

     

    lifestyle="Thread">

    <

     

     

    parameters>

    <

     

     

    tasks>

    <

     

     

    array>

    <

     

     

    value>${OrderStatus.OrderProcessed}</value>

    </

     

     

    array>

    </

     

     

    tasks>

    </

     

     

    parameters>

    </

     

     

    component>

    <!--

     

     

    Pipeline Tasks-->

    <

     

     

    component id="OrderStatus.OrderProcessed"

     

     

     

    service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"

     

     

     

    type="WSC.Pipelines.OrderStatus.OrderProcessed, test"

     

     

     

    lifestyle="Thread" />

    <!--

     

     

    Add Quantity Management Here -->

    </

     

     

    components>

    </

     

     

    configuration>

     

     

    My cs file now contains..

     

    namespace

     

     

    WSC.Pipelines.OrderStatus

    {

     

     

    public class OrderStatusPipeline : Pipeline<PurchaseOrder>

    {

     

     

    public OrderStatusPipeline(IPipelineTask<PurchaseOrder>[] tasks)

    :

     

    base(tasks)

    {

    }

    }

     

     

    public class OrderProcessed : IPipelineTask<PurchaseOrder>

    {

     

     

    public PipelineExecutionResult Execute(PurchaseOrder subject)

    {

     

     

    return PipelineExecutionResult.Success;

    }

    }

    }



    my pipe line column in my db contains "OrderStatus-Processed"

    I'm thinking this should be working? Can you see anything I'm missing? Are the references to my Dlls correct in my config?

    Bex

  • Bex 444 posts 555 karma points
    Aug 20, 2010 @ 17:12
    Bex
    0

    Good grief I have no idea what's happened with my code there..

     

    I'l try again:

    Config

    <

     

     

    configuration>

    <

     

     

    components>

    <!--

     

     

    Pipeline Instance -->

    <

     

     

    component id="OrderStatus-Processed"

     

     

     

    service="UCommerce.Pipelines.IPipeline`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"

     

     

     

    type="WSC.Pipelines.OrderStatus.OrderStatusPipeline, test"

     

     

     

    lifestyle="Thread">

    <

     

     

    parameters>

    <

     

     

    tasks>

    <

     

     

    array>

    <

     

     

    value>${OrderStatus.OrderProcessed}</value>

    </

     

     

    array>

    </

     

     

    tasks>

    </

     

     

    parameters>

    </

     

     

    component>

    <!--

     

     

    Pipeline Tasks-->

    <

     

     

    component id="OrderStatus.OrderProcessed"

     

     

     

    service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"

     

     

     

    type="WSC.Pipelines.OrderStatus.OrderProcessed, test"

     

     

     

    lifestyle="Thread" />

    <!--

     

     

    Add Quantity Management Here -->

    </

     

     

    components>

    </

     

     

    configuration>

     Cs

     

     

     

     

     

     

    namespace

     

     

     

    WSC.Pipelines.OrderStatus

    {

     

    public class OrderStatusPipeline : Pipeline<PurchaseOrder>

    {

     

    public OrderStatusPipeline(IPipelineTask<PurchaseOrder>[] tasks)

    :

     

    base(tasks)

    {

    }

    }

     

    public class OrderProcessed : IPipelineTask<PurchaseOrder>

    {

     

    public PipelineExecutionResult Execute(PurchaseOrder subject)

    {

     

    return PipelineExecutionResult.Success;

  • Bex 444 posts 555 karma points
    Aug 20, 2010 @ 17:14
    Bex
    0

    er.. can't get it to format right.. hope you can read it!

  • Sean Mooney 131 posts 158 karma points c-trib
    Aug 20, 2010 @ 17:37
    Sean Mooney
    0

    @Bex

    All the settings look correct to me.

    Next thing I would suggest is installing this project: http://our.umbraco.org/projects/developer-tools/falm-housekeeping

    This will allow you to look at the umbraco logs, or you could open the database and look at the "umbracoLog" table. All errors in an umbraco website are logged to this table, so you should be able to see what might be causing the problem.

     

    -Sean

     

  • Sean Mooney 131 posts 158 karma points c-trib
    Aug 20, 2010 @ 17:54
    Sean Mooney
    0

    @Bex,

    One thing that I forgot to mention, I have found that the Pipeline is not executed for the "New order" status. I think this is a bug and might have been fixed in a later version but doesn't work in the version that I have

    -Sean

  • Lasse Eskildsen 34 posts 57 karma points
    Aug 21, 2010 @ 23:10
    Lasse Eskildsen
    0

    Hi,

    @Bex - do you get any errors when changing the order status? Or can you verify by setting a breakpoint in the pipeline task that it runs?

    - Lasse

  • Bex 444 posts 555 karma points
    Aug 23, 2010 @ 10:00
    Bex
    0

    Sean.. that could be the reason it's not working? I assume new order is the same as "order complete".. hmmm

    Lasse, I've tried setting it all up in Visual Studio and sticking a breakpoint on my pipeline but it never reaches it.

    I don't see any errors happening, I have checked the log table.
    I am not manually changing the status to complete, it's when it does it it's self after the order is placed. Should this make a difference?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Aug 23, 2010 @ 20:46
    Søren Spelling Lund
    0

    Hi Bex,

    I created a quick pipeline component to test the scenario:

    Here's the code I used for the task:

     

    namespace MyUCommerceApp.Pipelines
    {
        public class MyPipelineTask : IPipelineTask<PurchaseOrder>
        {
            public PipelineExecutionResult Execute(PurchaseOrder subject)
            {
                subject["MyOrderProperty"] = DateTime.Now.ToString();
    
                return PipelineExecutionResult.Success;
            }
        }
    }

     

    I cheated a little bit and resued the basket pipeline stub already present in uCommerce for my pipeline config which I called OrderStatus.config and placed it in the pipelines folder:

    <configuration>
        <components>
            <!-- Pipeline Instance -->
            <component id="OrderStatus"
                       service="UCommerce.Pipelines.IPipeline`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"
                       type="UCommerce.Pipelines.Basket.BasketPipeline, UCommerce.Pipelines"
                       lifestyle="Thread">
                <parameters>
                    <tasks>
                        <array>
                            <value>${PO.SetOrderProperty}</value>
                        </array>
                    </tasks>
                </parameters>
            </component>
    
            <!-- Pipeline Tasks-->
            <component id="PO.SetOrderProperty"
                       service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.Entities.PurchaseOrder, UCommerce]], UCommerce"
                       type="MyUCommerceApp.Pipelines.MyPipelineTask, MyUCommerceApp.Pipelines"
                       lifestyle="Thread" />
        </components>
    </configuration>

    Finally I updated the order status that I'm updating the order to in the database to trigger the pipeline. I wanted to trigger it when going from New Order to Completed Order so I updated the Completed Order status with the pipeline name OrderStatus.

    With that complete I now get the date and time set on the order for when the order status was updated. Screenshots might be more helpful to look at though :)

    Here's the initial order:

     

    And the order status that I'm updating it to:

    And finally the order with the new order property:

    Hope this helps.

     

Please Sign in or register to post replies

Write your reply to:

Draft