Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1459 posts 1880 karma points
    Aug 26, 2012 @ 16:53
    Gordon Saxby
    0

    New order being created during checkout phase

    I am using (most of) the XSLT from your demo shop (I think!) to handle the checkout process. The customer is able to click on the product (in step 1) and return to the product, to alter their selected options and "add" the product to the basket again. This works fine and they return to the basket (step 1).

    The problem comes when they go from step 2 to step 3 ... for some reason a new order is being created.

    The new order has all of the properties added to the original order, but because the order number has changed, it breaks the link to the associated order images (images are created per order and named with the related order number).

    Each step XSLT file has this line:

        <xsl:variable name="order" select="teacommerce:GetOrderXml()" />

    but I cannot see what is different between step 1, 2 and 3 or why step 3 would decide to create a new order.

    I am a bit lost on where to look / how to solve this at the moment!

     

     

  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 27, 2012 @ 08:45
    Rune Grønkjær
    0

    Hi Gordon,

    That sounds highly unusual. If your cart setup is totally standard Starter Kit xslt and JavaScript, that should not be able to happen. When going from step 2 to step 3, the only thing that happens is that the customers information is saved to the orders properties.

    Do you have some custom .NET code?

    Normally the only scenario that the order id can change is if the user have gone to payment and then aborted the payment. Then if the customer makes any changes to the order the orders id will also change.

    /Rune

  • Gordon Saxby 1459 posts 1880 karma points
    Aug 27, 2012 @ 11:38
    Gordon Saxby
    0

    Yes, unusual indeed! I suspect I have some dodgy code somewhere, I just can't track it down!

    When a customer returns to the product from the basket, I pass the order id and line number on the url and use the following (simplified) code to ensure it is the "current" order:

    string oid = this.Request.QueryString["oid"]
    long oidint = Convert.ToInt64(oid);
    this.order = TeaCommerce.GetOrder(oidint);
    SessionController.CurrentOrderId = oidint;
    however, this is working fine because I have monitored the latest order number during each step of the process and returning to the product and "adding" it to the basket again does not cause a new order to be created.
    The site template (master page) has the following code, to ensure the basket details are up to date:
                // Shopping Basket
                // Get the current Order, or create a new one
                Order order;
                string oid = this.Request.QueryString["oid"];
                if (oid != null)
                {
                    long oidint = Convert.ToInt64(oid);
                    order = TeaCommerce.GetOrder(oidint);
                    this.headerBasketQty.Text = order.OrderLines.Count().ToString();
                    this.headerBasketTotalCost.Text = order.TotalPriceFormatted;
                }
                else
                {
                    if (TeaCommerce.HasOrder())
                    {
                        order = TeaCommerce.GetOrder();
                        this.headerBasketQty.Text = order.OrderLines.Count().ToString();
                        this.headerBasketTotalCost.Text = order.TotalPriceFormatted;
                    }
                    else
                    {
                        this.headerBasketQty.Text = "0";
                        this.headerBasketTotalCost.Text = "£0.00";
                    }
                }
    I just don't understand how a new order is being created between step 2 and 3. The website is not your complete starter kit, rather I took elements of it to build into my customers site. 
    I would rather not give the URL here, but I can email it to you if that would help. I can also give you an admin login ... and send you the full source if necessary!
  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 27, 2012 @ 15:44
    Rune Grønkjær
    0

    I don't think there's anything wrong with the above code, without being sure. What I would do is start ripping out stuff until it works again. Tea Commerce can only change the order id if the current order is finalized or, as I wrote above, is sent to payment.

    /Rune

  • Anders Burla 2560 posts 8256 karma points
    Sep 04, 2012 @ 13:20
    Anders Burla
    0

    Hi Gordon

    Got it fixed?

    Kind regards
    Anders

  • Gordon Saxby 1459 posts 1880 karma points
    Sep 04, 2012 @ 16:45
    Gordon Saxby
    0

    Not yet ... haven't had much time to look at the issue yet.

  • Gordon Saxby 1459 posts 1880 karma points
    Sep 05, 2012 @ 10:28
    Gordon Saxby
    0

    still not found the issue ... still stripping out code! :-(

  • Gordon Saxby 1459 posts 1880 karma points
    Sep 09, 2012 @ 17:00
    Gordon Saxby
    0

    I still can't get to the bottom of this ... it is quite hard to replicate, it does happen but it's difficult to see what steps are acausing it.

    One thing I don't understand - a new order number is being created and the details from the original order are being copied to the new order - why? Why is the new order not blank?

     

  • Gordon Saxby 1459 posts 1880 karma points
    Sep 09, 2012 @ 17:34
    Gordon Saxby
    0

    OK, when going from step 2 to 3 if the latest order (?) is set to Payment Status = "initial" then a NEW order is created. All details appear to be copied to the new order.

    When going from step 3 to 4, the Payment Status is set to "initial".

    So, if we get to step 4 and then go elsewhere (back to order details page, other site page, etc) and then start the order process again, a new order is created between step 2 and 3!

    As far as I can see - none of my code sets the Payment Status.

  • Rune Grønkjær 1372 posts 3103 karma points
    Sep 10, 2012 @ 08:39
    Rune Grønkjær
    0

    Hi Gordon,

    What's happening is that the order is cloned! When that happens the order will get a new order id.

    What will cause this is the following two steps:

    1. The Payment status is set to anything but null
    2. The order is being changed. This can be anything from adding an order line or property or anything else that just changes the data of the order. Furthermore it will only happen when using the Tea Commerce base. The javascript is using the Tea Commerce base.

    ONLY time Tea Commerce will set the payment status is when it generates the payment form using either the JavaScript method goToPayment or the xslt library method GetPaymentForm. In other words, after calling one of those the order will be cloned if changed.

    And why is that, you may ask.
    It's because of the payment gateways. Most of them recieve a checksum of the entire order which is created by Tea Commerce. If the same order is sent twice, they will throw an error telling us that the same order cannot be payed for twice. By cloning the changed order we make sure this does not happen.

    /Rune

  • Gordon Saxby 1459 posts 1880 karma points
    Sep 10, 2012 @ 09:58
    Gordon Saxby
    0

    OK ... now I understand the process ... I think!

    I am working with TC via the C# API - I assume that is also using Base?

    I think my only solution is to add a unique key (guid) to each order and use that to link to the images for the specific order (rather than the order number). That won't get round the cloning of orders, etc but it will mean that the order won't lose connection to its images.

    Thanks for your help Rune.

  • Gordon Saxby 1459 posts 1880 karma points
    Sep 11, 2012 @ 13:49
    Gordon Saxby
    0

    OK, the solution I went for was to add a guid property to both the order and order lines. I then used those guids to name (hence link) images for the order.

    When / if the order gets cloned - which means the order Id AND order line Ids get updated - the images still link via the guids!

    I am still testing but it seems to work ...

  • Bjørn Fridal 274 posts 784 karma points
    May 14, 2013 @ 16:13
    Bjørn Fridal
    0

    I had a related problem and thought I would share my take on it.

    I have some custom data for each order line that I keep in a separate table, since I didn't want to modify the Tea Commerce tables. However when an order is cloned I no longer have access to that custom data. So to work around that, I first store my custom data in the TeaCommerce_CustomOrderLineProperty as JSON and then on the OrderLinesAdded event I grap it from there and save it to my own table. That also works when cloning happens.

    Cheers
    Bjørn 

  • Rune Grønkjær 1372 posts 3103 karma points
    May 14, 2013 @ 16:24
    Rune Grønkjær
    0

    Sounds like a lot of hacking Bjørn. :)

    The problem you have experienced sounds real. Remember that the Custom properties on the order or order lines kan be hidden from the client by making them server side only. You can also make them read only. Both of these only affects the JavaScript API.

    /Rune

  • Bjørn Fridal 274 posts 784 karma points
    May 14, 2013 @ 16:53
    Bjørn Fridal
    1

    Hi Rune,

    Yes :) The reason I did it this way, was so that I can easily query orders by my custom data. That didn't work as smoothly with the custom properties.

    Cheers
    Bjørn 

Please Sign in or register to post replies

Write your reply to:

Draft